rsudp.t_testdata (test pre-producer)
- class rsudp.t_testdata.TestData(q, data_file, port)
Added in version 0.4.3.
A simple module that reads lines formatted as Raspberry Shake UDP packets from a file on disk, and sends them to the specified localhost port. Designed to quit on seeing a
TERMstring as the last line of the file or when anENDTESTpacket arrives on this thread’s queue.For a diagram of
TestData’s position in the data hierarchy, see Data flow during testing.- Parameters:
q (queue.Queue) – queue of data and messages sent by
rsudp.c_consumer.Consumerdata_file (str) – data file to read from disk
port (str or int) – network port to pass UDP data to (at
localhostaddress)
- run()
Start the thread. First, opens a file, determines the speed of data flow, then opens a socket and begins sending data at that transmission rate.
Continues sending data until an
ENDTESTpacket arrives on the queue, or until the reader reaches the end of the file. Then, sends aTERMmessage to the localhost port and exits.
- send()
Send the latest line in the open file to the specified port at localhost. If the next line’s timestamp is the same, that line will also be sent immediately. If the next line does not contain the same timestamp, the program will seek back to the last line read and then break for a new loop.
If the line contains
TERM, the program will setself.alive = Falseand prepare to exit.