A
A
Artem Melnykov2021-05-14 08:39:04
Arduino
Artem Melnykov, 2021-05-14 08:39:04

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

2 answer(s)
1
12rbah, 2021-05-14
@12rbah

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

M
Maxim K, 2021-05-14
@mkvmaks

youtube channel arduino notes, there is just a big topic about parsing data from arduino

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question