Question about uint32_t data type
Posted: Tue Apr 26, 2022 2:59 pm
Hi,
I am playing with several ESP32s linked together via a CAN bus. The simple prototype I have made is working well with 3 nodes, they are exchanging messages successfully. For the ones who don't know about CAN, the frames exchanged can contain a maximum of 8 bytes of data.
For one specific type of frame that contains instructions to activate a stepper motor, the 8 bytes of data are composed like this:
In the node that is sending the frame, I set dir to 'R', and rev to 2. The length of the message is also set to 5, so the last 3 bytes are not sent. The receiving node understands the frame correctly and spins the stepper motor backwards for 2 revolutions.
Then I decided the plug my oscilloscope to the CAN bus to decode the frames, and for this specific frame, I have the following data (in hex):
0x52 79 11 01 02
0x52 is correct, as it corresponds to 'R'. But the next 4 bytes are a mystery for me, I was expecting to find 00 00 00 01. Is this linked to the way ESP32 is implementing uint32_t?
I am playing with several ESP32s linked together via a CAN bus. The simple prototype I have made is working well with 3 nodes, they are exchanging messages successfully. For the ones who don't know about CAN, the frames exchanged can contain a maximum of 8 bytes of data.
For one specific type of frame that contains instructions to activate a stepper motor, the 8 bytes of data are composed like this:
- typedef struct {
- uint8_t dir; // 'F' = CW, 'R' = CCW
- uint32_t rev; // number of revolutions
- uint8_t filler[3]; // filler
- } stepper_data_t;
Then I decided the plug my oscilloscope to the CAN bus to decode the frames, and for this specific frame, I have the following data (in hex):
0x52 79 11 01 02
0x52 is correct, as it corresponds to 'R'. But the next 4 bytes are a mystery for me, I was expecting to find 00 00 00 01. Is this linked to the way ESP32 is implementing uint32_t?