HexToDecimal

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Matrixv8
Posts: 23
http://meble-kuchenne.info.pl
Joined: Mon Jun 03, 2024 2:51 am
Been thanked: 4 times

HexToDecimal

Post by Matrixv8 »

Hi everyone, I search the forum and could not find a way to convert HexToDecimal, function or otherwise that I could use while reading UART data. IE: receiving bytes and convert so I can read Hex data and convert it to a usable form. Does someone have a solution?

Thank you for your help.

Regards,
Pierre

chipfryer27
Valued Contributor
Posts: 1954
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 425 times
Been thanked: 647 times

Re: HexToDecimal

Post by chipfryer27 »

Hi

Not sure I know what you want to do as you don't say what a usable form actually is.

You want to take a hex number arriving over your UART, then do what with it?

Regards

mnfisher
Valued Contributor
Posts: 1877
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 154 times
Been thanked: 886 times

Re: HexToDecimal

Post by mnfisher »


Steve-Matrix
Matrix Staff
Posts: 1797
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 258 times
Been thanked: 415 times

Re: HexToDecimal

Post by Steve-Matrix »

As @chipfryer27 says, it depends on what you are actually receiving. If you are receiving string data in a human-readable form that is represented as a hexadecimal string, then you can convert it using the example in @mnfisher's post.

But often you may be receiving bytes that are actually numbers (rather than a string representation of a number). In this case, it's just a number. For example, the number might be 255 (in decimal) or 0xFF (in hexadecimal), but behind the scenes it is still the same number and requires no actual conversion. Conversion is only necessary when you are transferring string data. There is a discussion about this here:
https://www.flowcode.co.uk/forums/viewtopic.php?p=14518

Post Reply