Re: [Discuss-gnuradio] Packet mod/demod race condition?

2007-09-17 Thread Thomas Tsou
Hi Steven,

 If I uncomment the sleep, I never see this message. So:
 Q1) Any idea what this error is all about? Is this a race condition that
 needs to be addressed, or am I doing something wrong?

This part I'm not sure about.

 Q2) The original audio file is 350.0KB. Sometimes the resulting audio file
 is complete, other times it never gets the last few KB (ends up 341.0KB, for
 example). How do I ensure that all the bytes make it across successfully?

The benchmark loopback code makes no guarantee of delivery. In order
to do so, you need some method or higher level protocol to detect and
retransmit any dropped frames. Though in your case, I wouldn't expect
the received file to vary per run. Again, I'm not sure here.

 Q3) What is the effect of packet size? Is there an optimum size? A max size?
 For USRP, packets need to be padded to a multiple of XXX?

The optimal size depends on the given application. Latency and
overhead might be two considerations. The max packet size is limited
by the length of the whitener PN sequence. I don't believe there are
any restrictions beyond that. The USRP will view the data in a stream
form; it won't have any notion of the data packet length at that
point.

 Q4) Some examples use gr.enable_realtime_scheduling(). What is the effect of
 this, and do I need it? I note that it requires a sudo.

Realtime scheduling changes the scheduling policy of selected threads
to a priority over normal threads. In Linux, root access is required
in order to do so. It should result in more lower latencies and more
deterministic behavior.

 Thanks for your time!
 -Steven

Anytime.

-TT


___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


[Discuss-gnuradio] Packet mod/demod race condition?

2007-09-13 Thread Steven Clark
Hi all-

I am testing out the blks2.mod_pkts  blks2.demod_pkts with something
similar to what is in the benchmark_loopback example, only I do not use the
USRP at all. Basically, I am transfering the contents of one audio file to
another by way of a mod/demod packet chain, and hoping to see the same
complete, intact audio file come out the other side. Relevant code follows:

class gmsk_tester(gr.top_block):
def __init__(self, rx_callback):
gr.top_block.__init__(self, gmsk_tester)

self.mod = gmsk_mod()
self.pkt_tx = mod_pkts(self.mod)

self.demod = gmsk_demod()
self.pkt_rx = demod_pkts(self.demod, callback=rx_callback)

self.connect(self.pkt_tx, self.pkt_rx)


def main():
src_fn = 'data.ogg'
dst_fn = 'data2.ogg'

src_file = file(src_fn, 'r')
src_data = src_file.read()
src_file.close()

global dst_file
dst_file = file(dst_fn, 'w')

def rx_callback(ok, payload):
global dst_file
dst_file.write(payload)

gt = gmsk_tester(rx_callback)

gt.start()

try:
i = 0
pkt_size = 800
pkt_data = src_data[i:i+pkt_size]
while len(pkt_data)  0:
print len(pkt_data)
gt.pkt_tx.send_pkt(pkt_data)
i = i+pkt_size
pkt_data = src_data[i:i+pkt_size]
except:
pass

gt.pkt_tx.send_pkt('')

gt.pkt_tx.send_pkt(eof=True)

gt.wait()

#time.sleep(1)

dst_file.flush()

if __name__ == '__main__':
main()


Sometimes this code runs to completion without complaint, sometimes at the
end I get:
Exception in thread Thread-1 (most likely raised during interpreter
shutdown):
Traceback (most recent call last):
  File threading.py, line 460, in __bootstrap
  File /usr/local/lib/python2.5/site-packages/gnuradio/blksimpl2/pkt.py,
line 153, in run
type 'exceptions.AttributeError': 'NoneType' object has no attribute
'unmake_packet'
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:


If I uncomment the sleep, I never see this message. So:
Q1) Any idea what this error is all about? Is this a race condition that
needs to be addressed, or am I doing something wrong?

Q2) The original audio file is 350.0KB. Sometimes the resulting audio file
is complete, other times it never gets the last few KB (ends up 341.0KB, for
example). How do I ensure that all the bytes make it across successfully?

Q3) What is the effect of packet size? Is there an optimum size? A max size?
For USRP, packets need to be padded to a multiple of XXX?

Q4) Some examples use gr.enable_realtime_scheduling(). What is the effect of
this, and do I need it? I note that it requires a sudo.

Thanks for your time!
-Steven
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio