Answer the question
In order to leave comments, you need to log in
How to programmatically implement the SCPI text protocol on a microcontroller?
Hello!
I am writing a program for a piece of iron on a microcontroller, language C.
Tell me how can I implement the SCPI text protocol programmatically? Data is received via UART. There are no problems with iron - I don’t know how to process it programmatically. There are synonyms for commands, there are optional parameters, there may or may not be parameters, there may be several at once. How to process all this and check whether the user is trying to enter a non-existent command?
For those not familiar with SCPI - description
Answer the question
In order to leave comments, you need to log in
First you need a parser that will split the string into a command and parameters. A command in a separate line is possible immediately with its capitalization, comparison and replacement with a digital code (for ease of comparison in the future) and an array of parameters (naturally with a length to take it into account in processing). through switch...case (convenient for synonyms) transfer of control and a pointer to an array of parameters to the required procedure.
Tell me how you can implement the SCPI text protocol programmatically?
There are synonyms for commands, there are optional parameters, there may or may not be parameters, there may be several at once. How to process all this and check whether the user is trying to enter a non-existent command?
In my opinion, the easiest way is to use a bunch of parser generator + lexical analyzer, bison + flex. Describe the grammar of the language in the bison language, describe the allowed tokens in the flex language, compile and get a parser for this language in C.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question