From b4bc96696a949f9bfd297cbe8f9fc481b3be01ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 7 Dec 2015 00:11:33 +0100 Subject: [PATCH] improved readme and added scpi.h with all headers included --- README.md | 51 ++++++++++++++++++++++++----------------- example/example.c | 2 +- include/scpi.h | 8 +++++++ include/scpi_builtins.h | 5 ---- include/scpi_parser.h | 4 ---- scpi.pro | 13 ++++++++--- 6 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 include/scpi.h diff --git a/README.md b/README.md index c921289..e264097 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,39 @@ This library provides a simple ("KISS") SCPI implementation for embedded devices The implementation is not 100% complete, but it's sufficient for basic SCPI communication. -## What's supported +- Easy configuration with one const array and callbacks +- Implements SCPI99 (minimal requirements) - including common commands and status registers +- Mandatory parts of the SYST and STAT subsystems are built in (ie. error handling) +- Easy, straightforward API -- The hierarchical header model (commands with colon) -- Long and short header variants (eg. `SYSTem?`) -- Easy configuration with one const array of structs and callback functions (see `main.c`) +## Feature overview + +### What's supported + +- Commands with colon (hierarchical header model) - Semicolon for chaining commands on the same level -- String, Int, Float, Bool arguments -- Block data argument with callback each N received bytes (configurable) -- Status Register model -- Error queue including error messages from the SCPI spec -- All mandatory SCPI commands (headers) are implemented as built-ins +- Long and short command variants (eg. `SYSTem?`) +- String, Int, Float, Bool, CharData arguments +- **Block data argument** with callback each N received bytes - allows virtually unlimite binary data length +- Status Registers +- Error queue with error numbers and messages (and the required SYST:ERR subsystem) + +Built-in commands can be overriden by matching user commands. + +### Limitations + +- Binary block must be the last argument of a command (callback is run after reading the binary block preamble) + +### What's missing + +- Number units (mV,V,kW,A,Ohm) and metric suffixes (k,M,G,m,u,n) +- DEF, MIN, MAX, INF, NINF argument values for numbers +- Numbered virtual instruments (DAC1:OUT, DAC2:OUT) - currently you need to define the commands twice + +Feel free to propose a pull request implementing any missing features. -Built-in commands can be overriden in user command array. -## How to use +## How to use it To test it with regular gcc, run the Makefile in the `example` directory. @@ -29,7 +47,7 @@ The main Makefile builds a library for ARM Cortex M4 (can be easily adjusted for Here's an overview of stubs you have to implement (at the time of writing this readme): ```c -#include "scpi_parser.h" +#include "scpi.h" // Receive byte - call: // scpi_handle_byte() @@ -93,12 +111,3 @@ void scpi_user_TSTq(void) { /*...*/ } ``` See the header files for more info. - -## What is missing - -- Number units and metric suffixes (k,M,G,m,u,n) -- DEF, MIN, MAX, INF, NINF argument values for numbers - -Support for units and "constants" (DEF etc) in numeric fields will need some larger changes to the numeric parser and `SCPI_argval_t`. - -Feel free to propose a pull request implementing any missing features. diff --git a/example/example.c b/example/example.c index d34cd0d..848b14a 100644 --- a/example/example.c +++ b/example/example.c @@ -2,7 +2,7 @@ #include #include -#include "scpi_parser.h" +#include "scpi.h" // ------- TESTING ---------- diff --git a/include/scpi.h b/include/scpi.h new file mode 100644 index 0000000..9c8ac9a --- /dev/null +++ b/include/scpi.h @@ -0,0 +1,8 @@ +#pragma once + +// Include this file when using the library + +#include "scpi_regs.h" +#include "scpi_errors.h" +#include "scpi_builtins.h" +#include "scpi_parser.h" diff --git a/include/scpi_builtins.h b/include/scpi_builtins.h index d39521b..d61844a 100644 --- a/include/scpi_builtins.h +++ b/include/scpi_builtins.h @@ -2,11 +2,6 @@ #include #include -#include "scpi_parser.h" -#include "scpi_errors.h" -#include "scpi_regs.h" - - /** *CLS command callback - clear non-SCPI device state */ extern __attribute__((weak)) void scpi_user_CLS(void); diff --git a/include/scpi_parser.h b/include/scpi_parser.h index ec0c392..93cecee 100644 --- a/include/scpi_parser.h +++ b/include/scpi_parser.h @@ -2,10 +2,6 @@ #include #include -#include "scpi_errors.h" -#include "scpi_builtins.h" -#include "scpi_regs.h" - #define SCPI_MAX_CMD_LEN 16 // 12 according to spec #define SCPI_MAX_STRING_LEN 64 // 12 according to spec #define SCPI_MAX_LEVEL_COUNT 4 diff --git a/scpi.pro b/scpi.pro index f111fa0..4dc37b7 100644 --- a/scpi.pro +++ b/scpi.pro @@ -3,14 +3,16 @@ CONFIG += console CONFIG -= app_bundle CONFIG -= qt -INCLUDEPATH += source/ +INCLUDEPATH += source/ \ + include/ SOURCES += \ main.c \ source/scpi_parser.c \ source/scpi_errors.c \ source/scpi_regs.c \ - source/scpi_builtins.c + source/scpi_builtins.c \ + example/example.c DISTFILES += \ style.astylerc \ @@ -23,4 +25,9 @@ HEADERS += \ source/scpi_parser.h \ source/scpi_errors.h \ source/scpi_regs.h \ - source/scpi_builtins.h + source/scpi_builtins.h \ + include/scpi_builtins.h \ + include/scpi_errors.h \ + include/scpi_parser.h \ + include/scpi_regs.h \ + include/scpi.h