I notice that the MPI3 protocol uses the Step7 0x7E framed serial communication. What information do you have about the CRC for this protocol? It doesn't look like standard CRC calculation code (it seems to do things in reverse from the usual way for one thing). What would be the CRC polynomial?
From looking at the code, I have 2 comments:
1. You include the initial 0x7E in the CRC calculation, which could be avoided by adjusting the values in the start table.
2. If that change were made, then the start table value for 0-length packets would be 0xCF87, which allows you to calculate the CRC for the heartbeat packets 0x88 to 0x8F, as well as the control packets 0xFC, 0xCE and 0xCA. Of course, having a lookup table for them would be faster.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I notice that the MPI3 protocol uses the Step7 0x7E framed serial communication. What information do you have about the CRC for this protocol? It doesn't look like standard CRC calculation code (it seems to do things in reverse from the usual way for one thing). What would be the CRC polynomial?
From looking at the code, I have 2 comments:
1. You include the initial 0x7E in the CRC calculation, which could be avoided by adjusting the values in the start table.
2. If that change were made, then the start table value for 0-length packets would be 0xCF87, which allows you to calculate the CRC for the heartbeat packets 0x88 to 0x8F, as well as the control packets 0xFC, 0xCE and 0xCA. Of course, having a lookup table for them would be faster.