I bought the PCAN Ethernet Gateway DR IPEH-004010 and I need to write a program to communicate with it. So I need to send a CAN frame. First I need to understand how to calculate the CRC32. I have been going through the PEAK developer documentation.
Start value: 0x0
Polynomial: 0x04c11db7
crc32([0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88]) = 0x20861949
There is no XOR with 0xFFFFFFFF at the end of the calculation. The CRC32 result is added to the message in little endian byte order.
Now I tried this with different online calculators and some sample programs i downloaded from the internet and no where do I get the same answer. Why is this. I have used the same start value and polynomial as this one. But the answer is different. So, how do you calculate the CRC32. Thank you.
In the document page 17, it is explained about the CRC32 calculation but i am not experienced with CAN technology or CRC checksum to know exactly what kind of CRC check is this. So in this page an example is given.Calculate CRC32
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: Calculate CRC32
Hello,
This example is a custom CRC-32, there are some caviats as to why you receive a different result:
- The Input is not reflected
- The Result is not reflected
- The is no final XOR with 0XFFFFFFFF
There is a javascript crc calculator (Sunshine2k), which you can find easily find online,
you can check the values yourself and the aformentioned properties and schould receive the same result.
However:
Why exactly do you need CRC-32? it is optional and not required for communication by default.
If you want to disable it, change CRC_ON to 0 (JSON interface) or use_crc_frm = 0 (ini) for the route.
Best Regards
Marvin
This example is a custom CRC-32, there are some caviats as to why you receive a different result:
- The Input is not reflected
- The Result is not reflected
- The is no final XOR with 0XFFFFFFFF
There is a javascript crc calculator (Sunshine2k), which you can find easily find online,
you can check the values yourself and the aformentioned properties and schould receive the same result.
However:
Why exactly do you need CRC-32? it is optional and not required for communication by default.
If you want to disable it, change CRC_ON to 0 (JSON interface) or use_crc_frm = 0 (ini) for the route.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: Calculate CRC32
Thank you for your reply. I was finally able to get the CRC32. But you say it is not needed. So do I have to turn it off or i can just ignore. Because after calculating CRC, I want to use the PCAN ethernet adapter to send a CAN frame programmatically. This is the CAN frame that I created by refering to the example above.
So this is the CAN frame I am sending. In PCAN View it can be seen like this
And in PCAN view it works. In my program I send the CAN frame via TCP to the address and port of the ethernet adapter. And try to read from the same connection. Writing is working correctly without any problem because in my program has successfuly set up connection with the ethernet adapter. But the read output is giving no output. I am not getting any value from read after writing. So I am assuming something is wrong with the CAN frame I am sending. Can you please help me where I am wrong. Thank you.
Code: Select all
0028 0081 0000 0000 0000 0000 0000 0000 0000 0000 0008 0000 0209 0000 7A00 0000 0000 0000 B75D 1CF8 .
0028 = Size
0081 = Type
0000 0000 0000 0000 = Tag (not used in current version - so dont know whether I should leave it blank or enter all 0s like in the example)
0000 0000 0000 0000 = Timestamp (No effect on transmission - so I left all 0)
00 = Channel (not used in current version - so dont know whether I should leave it blank or enter all 0s like in the example)
08 = DLC (Not sure whether this is 08 or 01. CAN Data I am sending is 7A, but with 08, I would leave everythig else as 0. With PCAN view 08 and
adding 0s work as well as 01 and just sending 7A. I dont know how it is here)
0000 = Flags (My CAN frame doesnt have a remote transmission request and also no extended id, i set both to false in PCAN view, so here i set this value to 0x00)
0209 0000 = CAN ID (209h is CAN ID and RTR and Extended frame are both 0)
7A00 0000 0000 0000 = CAN Data( As I said CAN Data is 7A and to make it 8 byte, I add 0s to the end)
B75D 1CF8 = CRC in little endian (F81C5DB7 is the CRC value and will be added in little endian format)
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: Calculate CRC32
So you are writing a socket-base application?
Would some examples help you?
We have examples for this which we could send to you.
Just contact support@peak-system.com and we send you the examples for this.
Best Regards
Marvin
Would some examples help you?
We have examples for this which we could send to you.
Just contact support@peak-system.com and we send you the examples for this.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: Calculate CRC32
Well I am writing the application in LabVIEW. So if the examples are in labview it will be good. If not, I am not very comfortable with other programming languages. So if you send me another language, then I will need to come here again asking for help in understanding the example. But I will try.
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: Calculate CRC32
We do not have LabView examples for this, sorry.
Did you know that there is a a LabView Driver for PCANBasic by KDI?
https://www.peak-system.com/LabVIEW-CAN ... .html?&L=1
If you use the PCAN-Virtual Gateway in conjunction with your phyiscal Gateway you could skip
all the socket-based logic and use it like a regular PCAN-interface, which is alot less complex.
Best Regards
Marvin
Did you know that there is a a LabView Driver for PCANBasic by KDI?
https://www.peak-system.com/LabVIEW-CAN ... .html?&L=1
If you use the PCAN-Virtual Gateway in conjunction with your phyiscal Gateway you could skip
all the socket-based logic and use it like a regular PCAN-interface, which is alot less complex.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team