Hello,
I want to control a program running on a Teensy 3.2 from my computer over the serial port (USB) with structured messages, that is trigger/control specific functions with matching messages, the messages also containing parameters. I plan to use ASCII strings with variable lengths as identifiers rather than using cryptic numeric codes.
Ex :
getstatus board 0xAF
reset
config wordlength 8
config interval 10
Therefore, I have a few questions:
1. Is the principle a bad idea, that is, would branching with short, fixed-length messages like *abc* be much more efficient?
2. What's the most efficient branching structure for control messages? A suite of if+else statements or a switch? In the latter case, is there a simple solution to make it compatible with strings?
3. Even before branching, I need a way to split the message and its arguments and store them. What's the most efficient way to do it? Currently, I plan to insert a special character (for instance an asterisk) to identify the end of the identifier (this would allow functions names with different lengths) then use spaces to separate the identifier and the first parameter or the first and eventuel additional parameters.
Thank you in advance.
I want to control a program running on a Teensy 3.2 from my computer over the serial port (USB) with structured messages, that is trigger/control specific functions with matching messages, the messages also containing parameters. I plan to use ASCII strings with variable lengths as identifiers rather than using cryptic numeric codes.
Ex :
getstatus board 0xAF
reset
config wordlength 8
config interval 10
Therefore, I have a few questions:
1. Is the principle a bad idea, that is, would branching with short, fixed-length messages like *abc* be much more efficient?
2. What's the most efficient branching structure for control messages? A suite of if+else statements or a switch? In the latter case, is there a simple solution to make it compatible with strings?
3. Even before branching, I need a way to split the message and its arguments and store them. What's the most efficient way to do it? Currently, I plan to insert a special character (for instance an asterisk) to identify the end of the identifier (this would allow functions names with different lengths) then use spaces to separate the identifier and the first parameter or the first and eventuel additional parameters.
Thank you in advance.