Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • I appreciate all the details chrisl. I can't vote your answer as I am with low reputations yet. I will proceed as you suggested. Commented Jan 31, 2020 at 22:30
  • The only concern is about the position of the parser or finite state machine. Since the function "void receiveEvent(int howMany)" is called as an ISR routine following an interrupt, it should be as small as possible. So I shouldn't write the parser inside it. How to deal with this problem? Another question is: could I use the howMany number of byte to understand the correct length of the incoming current packet of byte? Thanks. Commented Jan 31, 2020 at 22:48
  • If the processing of the message would be too long for an ISR, the normal way is to buffer the message in an extra buffer and set a flag inside the ISR. This flag get's polled inside loop() and the processing is done there, when the flag is set. Commented Jan 31, 2020 at 23:55
  • Yes, the parameter howMany is the number of data bytes from the transmission, e.g. the number of bytes being received. Commented Jan 31, 2020 at 23:56
  • You can accept my answer, if you think it is correct. You don't need reputation for that. And you are the only one, that can accept an answer, since you asked this question. Commented Jan 31, 2020 at 23:57