We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I need to syntax check incomming queries/commands on the UART and i would like some idears on how to do it. The syntax of the commands are as follow:
Syntax required for a query is: @<device address><query>?;FF
Syntax required for a command is: @<device address><command>!<parameter>;FF
Examples: Query current baud rate: @253BR?;FF Change baud rate to 19200: @253BR!19200;FF where: @ <attention character> 253 <device address> BR? <query> (for query syntax) BR!19200 <command>!<parameter> (for command syntax) ;FF <terminator>
Please note the termination is ;FF and not CR or LF.
Is it possible to use the scanf() function for this task? Something like this perhaps:
scanf("@%3s%2s?;FF", adr, command);
Is it possible to use the scanf() function for this task? possibly, but why even try. 1) it is fairly simple to do it 'by hand" 2) someone is going to make a small change some day that makes the answer "no" instead of "possibly"
Ha' en rar dag
Erik