Hello, there is a function Serial.read () which gives information on bytes (I work in C for the first time so maybe I'm wrong), the data type on the output is char , I want to find the end of the line (the lines are separated \ r \ n) those. make a check:

if (Serial.read()== ...) { // это конец строки } 

What should I write instead ... what would my check work?

  • one
    You persistently post questions that are not even remotely related to the C language, under the tag [C]. Is this intentional trolling? - AnT

1 answer 1

Obviously, you cannot check two bytes with just one function call that returns one byte - so why try? Read two bytes and check.

  • Well, let's say I will write the last byte into a separate constant, however this does not change the question, I tried to make a check (Serial.read () == (char) '\ n'), but it did not help, how can I check them? - GeneralProger
  • The @GeneralProger check will not have the same form as your question. Try to do it first, if it does not work out, then ask a question with a more specific code and a description of what you have tried. - Alexei Averchenko
  • Well, what's the difference? I will allow every byte to be written, if byte goes second in the list, then we get the last byte from the char cmd [128] array, i.e. cmd [index] == Serial.read (); index ++; if ((index> 2) && (cmd [(index - 2)] == RBYTE && cmd [(index - 1)] == NBYTE)), what should be in RBYTE and NBYTE for the required comparison? - GeneralProger
  • @GeneralProger '\ r' and '\ n'. Byte = char - Alexei Averchenko
  • For files in text mode, the pair \r\n is replaced by \n . What is Serial and how it works is unknown. - Qwertiy