Maybe someone can help me

I’m using this code as an example but I’m trying to wait for a certain id to pop up then send my own right after it.
heres the code I’m using but I’m not getting any output when I send the can frames to test it.
candump can0 | grep " 123 " | while read line; do cansend can0 456#12345678; done

I got the code from a an article here

@dubb45, I don’t see your code … can you add it in so we can take a look?

In the meantime, I assume you are running candump / cansend on some form of unix machine. I also assume you are using a Carloop to do the USB/CANbus interface between your unix machine and the car.

Can you do some checks to ensure your unix machine and Carloop are communicating properly with each other? I would suggest having the Carloop echo back messages to the unix machine so you can check if Carloop is seeing the cansend correctly?

Give that a try and let us know how it goes!

I have proper communication between my raspberry pi and the carloop working fine, I’m able to send commands no problem and it works. what I’m trying to do is wait for a certain ID to pop up then send my own ID right after.
I assumed from using the command (not code sorry) below it would read the ID then send my command. I haven’t got to make it into full blown code just yet still trying to get it working. I have made it work once but now can’t get it working again I’m assuming I did something by mistake I’m looking over.
candump can0 | grep " 123 " | while read line; do cansend can0 456#8021C0071B101000; done

I got it to work with this line but got a few errors
candump can0 | grep "123" while read line; cansend can0 123#1234 grep: while: No such file or directory grep: read: No such file or directory grep: line: No such file or directory

but once the command reads the ID once it quits. if I pull up one terminal with “candump” and another one to run the code, I can see it see the original ID then send the custom ID, after that it closes the command, almost there to figuring it out.


I am guessing at this point, but my only 2 guesses are:

  • is there some sort of exception occurring when/after sending the custom ID that causes an error condition that causes the command to close?
  • is there something in the logic that causes an exit after sending the custom ID, instead of going back to watching for the next id to pop up?

Keep working at it; often it is a tiny detail that causes behaviour like this.

appreciate it ill keep at it, I just got the 8.4" uconnect screen upgrading from, the 4.3" screen in my Dodge Charger. now looking into a way for video input but a DIY way lol id rather not pay a ton just to get my raspberry pi to display on the screen lol I have it setup as a hotspot now and can connect to it via phone, laptop, iPad etc. to candump and it works great too. eventually I want to make my own interface once I get all the commands down packed.