0

I am running a script which is given below,

sudo  hexdump -v -e '1/1 "%02x\n"' /dev/ttyUSB0  | Many Pipes | gawk '{ print strftime(":: %s"), $0 }'

Here the data is being hex dumped with timestamp and its given below,

:: 1461680718 ::ED.DATA

:: 1461680718 ::ED.DATA

:: 1461680718 ::ED.DATA

:: 1461680718 ::ED.DATA

:: 1461680718 ::ED.DATA

:: 1461680718 ::ED.DATA

:: 1461680719 ::ED.DATA

As you can see the time doesn't change for all the packets. I think that is because I am dumping the data rather than doing read line. Is there any way to script and make sure I get different value for each packet (in seconds)

0

The same time comes from buffering. Try to find the command which buffers in the in the queue and try the command unbuffer.

  • I tried stdbuf ( i am using raspberry pi wheezy os ), and that did not work ! – RajuBhai Apr 26 '16 at 15:46
0

I tried the following on a jessie pi and had no problem with stdbuf -oL in front of hexdump working as intended.

while sleep .5;do echo -n x;done |
stdbuf -oL hexdump -v -e '1/1 "%02x\n"' |
ts %.s |
cat

The while is to simulate slow input, ts timestamps each line, and the cat is just to provide another pipe. The output is regular and the timestamps differ by about .5 seconds, after the first 2 lines. The ts command is from the moreutils package.

Try using stdbuf -oL on each of your commands in the pipe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.