MCP2515 modifying message and sent it back

Hi, i am new to arduino, so i am not expert programing, i know some stuff, i need to create program that are able to sent back message with diferent byte 2, i received id 0x171 90 ff 83 and i need to filter this and sent the message back like this 0x171 90 90 83, so i need to copy byte 1 to byte 2 and sent it back every 50ms, the original message is received every 100ms, so i need to sent back on 50ms to overlap the original message, since i am not using double can. Can anyone point out what libary should i use that have some type of example of what i need. Thanks.

Good Question. All I can do is take a SWAG as there is no information in your question. Since you receive the data, the library should also have a module to send data. Beyond that we need more information, such as what micro you are using, what CAN interface is connected, what is the current library you are using. Since you are receiving I will assume at this point the bus is operational without problems. Posting your code (read directions on how to do it) will also help.

CAN isn't designed to allow two devices to transmit messages with the same id on the same CAN bus as that breaks the message id arbitration mechanism.

You as the programmer cannot reliably time the transmission of messages to avoid collisions as the CAN transport layer decides when messages get sent. The net result is that some messages may not arrive, or may be delayed by some random amount of time. Also some CAN controllers will shutdown if the error counters get too high.

Is this a student project? If so, perhaps your supervisor wants you to discover these problems for yourself,
however if this is for car hacking you need two CAN buses so you can do a man in the middle attack to replace the original message with a different message.

Is for car hacking, the porpose is to sent water temperature on oil temperature data, since the cluster does not have water temperature gauge but have oil temperature, but the car does not have oil temperature sensor, on id 171 i have first data water temperature and second data oil temperature that ecu sent always has FF since there is no oil temperature . I know that i need dual can setup to make this work perfect, this setup is just to test before i go dual can, i have sent manual message with 10ms and i can make the cluster not read the FF that way, but is just for test not for final use. But is probably easy to just use another mcp2515 and use like dual can setup were i can modify and sent the message just for the cluster and not for all devices on can. Sry my english

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.