2023-02-06 11:57 AM
Hello All...
I am trying to send data to realterm using printf....I used cubemx to set up baud rate, etc. and have called MX_USART2_UART_Init. RealTerm is pointing to the correct serial port with the correct baud rate....A breakpoint validates the data is all good. I have included stdio.h. Can someone tell me why I am seeing nothing happen on RealTerm....Also I have tried creating a console in STMCubeIDE and also see nothing happen?? I overwrote the weak _write function (see below)
Thanks
for (uint8_t current = 0; current < NUMBER_MSMNTS; current++){
printf("CYCLE %d CURRENT %0.1f mA", ((readCycle > 0) ? readCycle : 3), DAC_C[current]);
printf("Vbias %0.2f", SensorDataPerCyclePublish.Vbias[current]);
printf("SiPM %0.2f", SensorDataPerCyclePublish.SiPMCurrent[current]);
printf("LED1 %0.2f", SensorDataPerCyclePublish.LED1Current[current]);
printf("LED2 %0.2f", SensorDataPerCyclePublish.LED2Current[current]);
printf("WaterT %0.2f", SensorDataPerCyclePublish.w_temp[current]);
printf("BoardT %0.2f", SensorDataPerCyclePublish.bd_temp[current]);
}
int _write(int file, char *ptr, int len)
{
HAL_UART_Transmit(&huart2, (uint8_t *)ptr, len, 50 );
return len;
}
Solved! Go to Solution.
2023-02-06 12:02 PM
stdout (what you redirect) is normally line buffered. So nothing shows up until you send a "\n" or maybe some "\r\n" depending on your terminal settings.
Keep also in mind, that floating point output will not work unless you enable it in the project settings (STM32CubeIDE) or set appropriate linker options explicitely.
hth
KnarfB
2023-02-06 12:02 PM
stdout (what you redirect) is normally line buffered. So nothing shows up until you send a "\n" or maybe some "\r\n" depending on your terminal settings.
Keep also in mind, that floating point output will not work unless you enable it in the project settings (STM32CubeIDE) or set appropriate linker options explicitely.
hth
KnarfB
2023-02-06 12:22 PM
Did what you suggested... Still not working??? I notice when I break on a printf and try to step INTO the code steps OVER?? wierd.....
for (uint8_t current = 0; current < NUMBER_MSMNTS; current++){
printf("CYCLE %d CURRENT %0.1f mA/n/r", ((readCycle > 0) ? readCycle : 3), DAC_C[current]);
printf("Vbias %0.2f/n/r", SensorDataPerCyclePublish.Vbias[current]);
printf("SiPM %0.2f/n/r", SensorDataPerCyclePublish.SiPMCurrent[current]);
printf("LED1 %0.2f/n/r", SensorDataPerCyclePublish.LED1Current[current]);
printf("LED2 %0.2f/n/r", SensorDataPerCyclePublish.LED2Current[current]);
printf("WaterT %0.2f/n/r", SensorDataPerCyclePublish.w_temp[current]);
printf("BoardT %0.2f/n/r", SensorDataPerCyclePublish.bd_temp[current]);
}
2023-02-06 05:44 PM
Solved..... \r\n NOT /r/n