I wanna turn to diverse functional entry acording to the received datas. The datas received from the serial port are at the length of 2 bytes . so I can't simply use Switch sentence. How can I make it?
robintu 0 Newbie Poster
Recommended Answers
Jump to PostIf the data received is 2 bytes, why can't you use a switch?
#define SWITCH_DATA( L, R ) ((L << 8) | R)
switch (SWITCH_DATA( firstByte, secondByte ))
case SWITCH_DATA( 'A', 'B' ):
<do stuff for the "AB" command>
break;and so on. Make sure the …
All 4 Replies
jwenting 1,905 duckman Team Colleague
Chainsaw 12 Posting Pro in Training
robintu 0 Newbie Poster
robintu 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.