Hopefully this is the best Stack Exchange site for this - I think it's primarily a netcat question.
I'm developing a custom data acquisition device. It can probably be best thought of as a fancy sound card. It's currently running on Ubuntu 14.04. I'm trying to validate the performance of it in MATLAB on another system, and the simplest solution seems to be streaming the raw data from the driver to MATLAB over UDP.
I can generate signals in MATLAB and send them over UDP to the device with a netcat listener:
nc -ul 10000 > /dev/evio
But I'm having trouble getting data to go in the other direction:
nc -u devhost 10000 < /dev/evio
This and other variations I've tried all just fail silently. According to pv
no data moves through the pipe at all. The device only implements the read
, write
, open
, and release
fops, along with a handful of custom ioctl
. If the input buffer is empty, the read call blocks until a frame of data comes in from the hardware and it returns either as much as was requested or the entire frame if too much was requested.
If I just do a simple test like hexdump /dev/evio | less
I see the data I expect.
Sending a regular file over nc seems to work fine, according to pv
.
I don't actually have a listener set up on the other side, but that shouldn't matter because this is UDP, right? I plan on having this just spamming my dev PC with raw data on that port so MATLAB can fire up a listener and tap into whenever it needs to. (I know this is a bad solution in the long run, but I'm just looking for a simple device to MATLAB bridge for hardware validation.)
Update:
Using dd seems to get a little through the pipe, but I don't know why it works differently. I set the reads to the frame size of the device:
dd if=/dev/evio bs=6144 | pv | nc -u devhost 10000
16kB 0:00:00 [1.57MB/s] [<=>
And then I had to ctrl+C to close it. Taking nc out of the loop seems to let it run properly forever:
dd if=/dev/evio bs=6144 | pv > /dev/null
Gives a constantly updating pv result, with exactly the data rate I know the device is generating. pv < /dev/evio > /dev/null
also gives the same results, which makes sense. I shouldn't have to read one frame at a time.