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)

2 Answers 2

0

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

1
  • I tried stdbuf ( i am using raspberry pi wheezy os ), and that did not work ! Commented Apr 26, 2016 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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.