greppipecan-buscanutils

how to double pipe candump


when using candump to read can bus :

$ candump can0

if I grep it once :

$ candump can0 | grep <whatever>

It works perfectly :

  $ candump can0 | grep 1A8           
  can0  1A8   [8]  3C 53 C5 FF 0D C3 3A 01
  can0  1A8   [8]  3C 53 C5 FF 0D C3 3A 01

If I try to grep it twice :

candump can0 | grep 1A8 | grep 1A8

it returns nothing ...

Ps : it might be solved by using this ( candump can0,<whatever>,7ff | grep <whatever> but it only works in that precise case )

Edit: for clarity, if I grep twice the same things it's still not working


Solution

  • The issue does not come from candump but from grep that buffer the output.

    You can find a good explanation of this behavior here.