cancel
Showing results for 
Search instead for 
Did you mean: 

hexdecimal number to send UART

cjaya.2
Associate II

Hi,

I wanted to send hexadecimal numbers through UART. I am using STM32F405. Can it be done.

If I am sending float number as 1.3456 string (text) to windows COM port to  english language windows application field. If for example regional settings being changed on the windows to german language and return float number as 1,3456.Sending the float number as hexadecimal will that sort out the problem. Any suggestions?

 

 

 

3 REPLIES 3
STTwo-32
ST Employee

Hello @cjaya.2 

For sending hexadecimal number over UART, yes this is possible. But for the language problem that you are facing, we don't have any idea on that because it depends on the application on your PC and not the STM32.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Surely generating hex, or other bases, is a very basic task, should be able to do from first-principles.

itoa() is a frequently used library method https://cplusplus.com/reference/cstdlib/itoa/

I tend to use table/shift methods for high efficiency.

For numeric formatting look at locale settings.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I think the proposed method is to send IEEE-754 floats/double in an ASCII form. Obviously that would immediately double the size of transmitted data.

One could send arrays of floats/doubles directly as 8-bit bytes, a 32-bit float would take 4-bytes and 64-bit double would take 8-bytes. The sort of way we'd normally store in memory, or in a file.

The byte ordering would depend on the endian ordering, but ARM and PC are typically small/little endian

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..