2019-01-28 01:56 AM
HAL_UART_Receive(&huart2, (uint8_t*)msgToTransmit, MESSAGE_SIZE, HAL_MAX_DELAY);
int index = 0;
for (index = 0; index < MESSAGE_SIZE; index++) {
PRINTF("\n\rmsg to transmit is hex: %x", msgToTransmit[index]);
PRINTF("\n\rmsg to transmit is char: %c", msgToTransmit[index]);
}
I am developing an application to send data using LoRa. I use an STM32 L073RZ (with LoRa shield) connected to a Raspberry Pi via USB. Everything works fine: there is a Python script that every 10 minutes sends data to the STM32 board, and then the board sends the LoRa message.
I would like now to "analyze" the message before sending. I tried to print on terminal the message that I send and:
if I send: abcdefgh
the result of PRINTF() with hex is:
index = 0 --> 64636261
index = 1 --> 68676665
the result of PRINTF() with char is:
index = 0 --> a
index = 1 --> e
Any suggestion/idea?
2019-01-28 03:25 AM
Hi
Print the data as bytes and not unsigned words and you will have no problems.
Don't forget that the processor is little-endian and so the first byte appears at the 3th byte position in the word when displayed as a long word (big-endian processors would display it in the first byte location in the long word).
https://en.wikipedia.org/wiki/Endianness
https://www.youtube.com/watch?v=NcaiHcBvDR4
Regards
Mark
2019-01-28 05:04 AM
Start by looking at the definition of the array msgToTransmit, you don't show it but assuming it is an array of 32-bit words.