Jan Breuer
2015-04-25 f8d0aa8ec41a50dee5b2b763b84c87c416eba5a7
README.md
@@ -3,7 +3,7 @@
[SCPI](http://en.wikipedia.org/wiki/Standard_Commands_for_Programmable_Instruments) Parser library aims to provide parsing ability of SCPI commands on instrument side. All commands are defined by their patterns eg: "STATus:QUEStionable:EVENt?".
Source codes are published with open source Simplified BSD license.
Source code is published with open source Simplified BSD license.
Command pattern definition
-----------
@@ -13,12 +13,17 @@
A command pattern is divided by colon ":" to show command hierarchy
    Pattern "SYSTem:VERsion?" mathes strings "SYST:version?", "system:ver?", "SYST:VER?", ...
    Pattern "SYSTem:VERsion?" matches strings "SYST:version?", "system:ver?", "SYST:VER?", ...
The SCPI standard also uses brackets "[]" to define optional parts of a command.
    Pattern "SYSTem:ERRor[:NEXT]?" mathes "SYST:ERR?", "system:err?" and also "system:error:next?", ...
    Pattern "SYSTem:ERRor[:NEXT]?" matches "SYST:ERR?", "system:err?" and also "system:error:next?", ...
Special character `#` represents number so it is possible to define pattern according to SCPI-99:6.2.5.2 Multiple Identical Capabilities
    Pattern "OUTput#:FREQuency" matches "OUT:FREQ" as well as "OUT3:FREQ" and "output10:frequency".
Appropriate numbers are available using function `SCPI_CommandNumbers`
Command callback
-----------
@@ -41,14 +46,14 @@
Source codes are divided into a few files to provide better portability to other systems.
- *libscpi/parser.c* - provides the core parser library
- *libscpi/error.c* - provides basic error handling (error queue of the instrument)
- *libscpi/ieee488.c* - provides basic implementation of IEEE488.2 mandatory commands
- *libscpi/minimal.c* - provides basic implementation of SCPI mandatory commands
- *libscpi/utils.c* - provides string handling routines and conversion routines
- *libscpi/units.c* - provides handling of special numners (DEF, MIN, MAX, ...) and units
- *libscpi/fifo.c* - provides basic implementation of error queue FIFO
- *libscpi/debug.c* - provides debug functions
- *libscpi/src/parser.c* - provides the core parser library
- *libscpi/src/error.c* - provides basic error handling (error queue of the instrument)
- *libscpi/src/ieee488.c* - provides basic implementation of IEEE488.2 mandatory commands
- *libscpi/src/minimal.c* - provides basic implementation of SCPI mandatory commands
- *libscpi/src/utils.c* - provides string handling routines and conversion routines
- *libscpi/src/units.c* - provides handling of special numners (DEF, MIN, MAX, ...) and units
- *libscpi/src/fifo.c* - provides basic implementation of error queue FIFO
- *libscpi/src/debug.c* - provides debug functions
- *examples/test-parser* - is the basic non-interactive demo of the parser
- *examples/test-interactive* - is the basic interactive demo of the parser
@@ -69,15 +74,15 @@
};
```
Then you need to initialize the interface callbacks' structure. If you don't want to provide some callbacks, just initialize it as `NULL`. The write callback is mandatory and is used to output data from the library.
Then you need to initialize the interface callbacks structure. If you don't want to provide some callbacks, just initialize it as `NULL`. The write callback is mandatory and is used to output data from the library.
```c
scpi_interface_t scpi_interface = {
   .write = myWrite,
   .error = NULL,
   .reset = NULL,
   .test = NULL,
   .srq = NULL,
   .reset = NULL, /* Called from SCPI_CoreRst */
   .test = NULL, /* Called from SCPI_CoreTstQ */
   .control = NULL,
};
```
@@ -116,7 +121,7 @@
A test implementation of function myWrite, which outputs everything to stdout, could be
```c   
size_t myWrite(scpi_context_t * context, const char * data, size_t len) {
size_t myWrite(scpi_t * context, const char * data, size_t len) {
   (void) context;
   return fwrite(data, 1, len, stdout);
}