Answer the question
In order to leave comments, you need to log in
Parsing and converting data from Serial?
Greetings. There is a question: how can you parse and convert bytes (0x..) data from Serial.
Example:
I enter w,01,00,00,00,00,00,00,3D; and bytes are written to the array (for example, in byte defaultID[8] = {..}
), as a result, something like this should come out:
byte defaultID[8] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D}
Answer the question
In order to leave comments, you need to log in
As I understand it, you need to convert the string representation of a byte to a number?
Here are ready -made solutions in c ++
You can also write your own crutch for this particular case:
1) check the string for correctness
2) divide it into two characters
3) convert each character into a number
4) multiply the first number by 16, the second by 1
5) add and write down the finished number where necessary
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question