rsudp.t_testdata
(test pre-producer)
- class rsudp.t_testdata.TestData(q, data_file, port)
New 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
TERM
string as the last line of the file or when anENDTEST
packet 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.Consumer
data_file (str) – data file to read from disk
port (str or int) – network port to pass UDP data to (at
localhost
address)
- 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
ENDTEST
packet arrives on the queue, or until the reader reaches the end of the file. Then, sends aTERM
message 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 = False
and prepare to exit.