hexdecimal number to send UART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-08 11:12 AM
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?
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-08 11:18 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-08 11:38 AM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-08 11:42 AM
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
Up vote any posts that you find helpful, it shows what's working..
