CanBus, How to send a single byte?

Using a SeedStudio board i can read a lot of Can Messages from my bike(Bmw k51 GS).
Now a further step :
i know that ID 120 is : FF A1 59 24 FF FF FF FF

but i want to modify just the "59" and change it to " 69".

Is there any way or i have to send the entire string , in my case FF A1 69 24 FF FF FF FF ??

The original string is not ever the same or, better, i dont know what is . I only know that i want to modify that byte without modifyng the others .

Thanks
Rob
( sorry for my English :slight_smile: )

Explain what you are trying to achieve ...

Rob52:
Using a SeedStudio board i can read a lot of Can Messages from my bike(Bmw k51 GS).
Now a further step :
i know that ID 120 is : FF A1 59 24 FF FF FF FF

but i want to modify just the "59" and change it to " 69".

Is there any way or i have to send the entire string , in my case FF A1 69 24 FF FF FF FF ??

The original string is not ever the same or, better, i dont know what is . I only know that i want to modify that byte without modifyng the others .

Thanks
Rob
( sorry for my English :slight_smile: )

if ID 120 consists for 8 bytes as it seem to be then you have to send all 8 byte ie from your post FF A1 69 24 FF FF FF FF

J-M-L:
Explain what you are trying to achieve ...

Thanks for replies and sorry if i didn't explain.

Well, i'm trying to control high beam and low beam of the bike. In ID120 "59" means low beam and "69" high beam. The others bytes run and i'm not interested in them but i dont know their values when i send the value "69".

SHERZAAD wrote that i have to send all the 8 bytes, so i have to read ID120 and send back all the 8 bytes with "69" instead "59".

My question was whether i could send the value "69" only.

Thanks. Rob

well if the protocol requires all the bite then you need to send the whole thing

the Bosch Canbus specification states
The Data Field consists of the data to be transferred within a DATA FRAME. It can contain from 0 to 8 bytes

for example the CANSendMsgExtended() function used with PIC24 microcontrollers

* Function:        BOOL CANSendMsgExtended( int Channel, UINT16 Identifier, 
 * UINT8* Msg, UINT8 MsgSize )
 *
 * Input: Channel: SPI channel number, 1 based
 * Identifier: 29bit data for identifier
 * Msg: Data bytes, 8 bytes max
 * MsgSize: number of data bytes

have a look at CAN_BUS_Shield

CAN.sendMsgBuf(INT32U id, INT8U ext, INT8U len, INT8U *buf);

Hi,
It will be interesting to see what happens.

If you are reading the canbus through the ODBII socket.

You will not be intercepting/blocking the packet and modifying it and sending it on.

You are reading the canbus, then ADDING a packet with modified data, but that packet MUST have the same ID for the changed data to be recognized by the system as a HIGH/LOW beam change.

What will happen is, the original packet ID120 will be present on the bus with 59, then you will insert another packet with ID120 with 69, then the other source will send 59, then yours will send 69.

So all that will happen is the system will try and turn from HIGH to LOW to HIGH as fast as the interval between 59 and 69 packets.

To do what you need, you need find the device that has ID120, isolate it from the canbus and then make a 2way repeater between ID120 and the main canbus, then program the repeater to pass all data to the ID120 from the bus and modify any data from ID120 to the bus.

And I would not like to do it unless I was a canbus expert, and I ain't.

Why do you want to change HI/LOW BEAM this way, why not hack into the HI/LOW BEAM switch.

Tom.... :slight_smile:

@ TomGeorge

Hi,
i think you're right.....but there is a solution for this, which one i dont know :slight_smile:

I know other guys has achieved the solution , but they did not share a single clue and i understand them.

What I'd like is to control some functions: i.e. when pressing horn button there should be a flashing beam ( low/high/low/high) . I think arduino is the best start to create a such device .

Rob

Rob52:
What I'd like is to control some functions: i.e. when pressing horn button there should be a flashing beam ( low/high/low/high) . I think arduino is the best start to create a such device .

essentially what you need is to put the arduino between the CAN network and the component transmitting that CAN ID (dont forget the terminator resistors!)

for that you need 2 CAN sheilds and your arduino code to transfer messages between the 2 sheild AND modify that byte you are interested in CAN message 120.

the only problem I can see here is if you want to influence the output of more that one component... might be more of a challenge there! :slight_smile: