I'm trying to flash some code to my Nordic Semiconductor nRF52832 32-bit MCU which is integrated on an DWM1001 UWB module. The module sends formatted (MAVLink v1 protocol with a message size of 101 bytes) position data as unsigned chars to its serial port using printf()
. The problem is, whenever a new line (\n
) command is sent to the port there always is a carriage return (\r
) put in front of \n
. Now, sometimes one of the bytes in the message can have the same value as the \n
command, which is 0x0A as HEX or 10 as a decimal. In this case, an additional \r
byte is sent automatically to the port, which screws up my protocol. How can I get rid of this?
As an example, I attached a picture that shows the output of the serial port of the module. It’s just a uint8_t
type counter counting from 0 to 254 and then resets itself (see code below). The function on_dwm_evt
is regularly called by a loop in the main function. When the counter reaches 10 (decimal for \n
) it puts a \r
(= 13 as decimal, 0x0D in HEX) in front of it and I don't want that. Any help is appreciated.
I should note that the custom code is "embedded" into the firmware environment (namely PANS) provided by the manufacturer Decawave.
I'm using the SEGGER Embedded Studio IDE on Windows 10 and the GNU Arm Embedded Toolchain Version 10.3-2021.10 to compile my code.
uint8_t sq = 0;
unsigned char count;
void on_dwm_evt(dwm_evt_t *p_evt) {
/* convert byte. (My actual message consists of multiple char arrays) */
count = sq & 0xFF;
/* print counter to serial */
printf("%c", count);
/* Increase sq counter +1 */
if (sq < 254) {
sq = sq + 1;
} else {
sq = 0;
}
}