Constructing RawCAN frames

3 years 4 months ago #29534997 by Peter_Walton
To send 4-byte variable in a rawCAN frame doesn't each byte need to be separately entered as a payload byte? If you mask off 1 byte from the variable and assign it to a user variable for transfer to a payload byte don't you have the same problem? i.e. you've still got 4 bytes, but you only need 1? What should the process be please?

Please Log in or Create an account to join the conversation.

3 years 3 months ago - 3 years 3 months ago #29535002 by Athanasios
Hi Peter
see below an example of a code that I hope will clarify your question

dim BY[8] as integer
wait (500)
Variable=0xabcdef 'enter the hex value abcdef to the variable
can_id=0x601' enter as can id hex value 601
command=0x40' enter command hex value 40
length=3
by[6]=Variable
Variable=Variable>>8 'right shift one byte
by[5]=Variable
setcommand(_cs,1,can_id)
setcommand(_cs,3,Command)
setcommand(_cs,4,by[6])
setcommand(_cs,5,by[5])
setcommand(_cs,2,length)

when I run the code I get from the can sniffer what you see at the attached file.
Attached you can find the code also in a .txt file

It is only the less significant byte that is send from the BY[x] variable
Does this reply to your question?
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds