0
Convert a hex serial output into a normal integer
arduino putting out a hexadecimal, want to convert into a integer....
5 Réponses
+ 7
Just use int()
int(0xffffff) = 16777215
+ 4
@Nathan what is the output format then?
+ 4
What I meant was the exact format of a given string. Could you write what is the output of print(data)?
0
my current output is this: data = str(int ser.serial_readline(), 16) because the arduino converts an int before it sends it, I need to convert it back to an int to compare the 2 sets of data
0
@Kuba the arduino sends a number convets to hex, and sends via usb. the script stores it as an integer, ie the numbers are not the same as script is displaying hexadecimal numbers.
I would like to convert it back to an integer so I can compare notes.
from what I can see is that the script reads the serial, and puts it in a string,
here is the fetching code.
data = str(int ser.serial_readline(), 16)
so if I change the int to hex it does not communicate, what I can see is that the number becomes an integer and displayed in a string, but the current integer is set to the converted hex number, now I would like to convert it back to the original integer.