|
5 years ago | |
---|---|---|
example | 5 years ago | |
include | 5 years ago | |
lib | 5 years ago | |
source | 5 years ago | |
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
Makefile | 5 years ago | |
README.md | 5 years ago | |
errorgen.php | 5 years ago | |
scpi.pro | 5 years ago | |
style.astylerc | 5 years ago |
This library provides a simple ("KISS") SCPI implementation for embedded devices (instruments).
The implementation is not 100% complete, but it's sufficient for basic SCPI communication.
SYSTem?
)Built-in commands can be overriden by matching user commands.
Feel free to propose a pull request implementing any missing features.
To test it with regular gcc, run the Makefile in the example
directory.
The main Makefile builds a library for ARM Cortex M4 (can be easily adjusted for others).
Here's an overview of stubs you have to implement (at the time of writing this readme):
#include "scpi.h"
// Receive byte - call:
// scpi_handle_byte()
// scpi_handle_string()
// ---- DEVICE IMPLEMENTATION ----
const SCPI_error_desc scpi_user_errors[] = {
{10, "Custom error"}, // add your custom errors here (positive numbers)
{/*END*/} // <-- end marker
};
void scpi_send_byte_impl(uint8_t b)
{
// send the byte to master (over UART?)
}
const char *scpi_device_identifier(void)
{
// fill in your device info
// possible to eg. read a serial # from EEPROM
return "<manufacturer>,<product>,<serial#>,<version>";
}
/* Custom commands */
const SCPI_command_t scpi_commands[] = {
// see the struct definition for more details. Examples:
{
.levels = {"APPLy", "SINe"},
.params = {SCPI_DT_INT, SCPI_DT_FLOAT, SCPI_DT_FLOAT},
.callback = cmd_APPL_SIN_cb
},
{
.levels = {"DATA", "BLOB"},
.params = {SCPI_DT_BLOB},
.callback = cmd_DATA_BLOB_cb, // <-- command callback
.blob_chunk = 4,
.blob_callback = cmd_DATA_BLOB_data // <-- data callback
},
{/*END*/} // <-- important! Marks end of the array
};
// ---- OPTIONAL CALLBACKS ----
void scpi_service_request_impl(void)
{
// Called when the SRQ flag in Status Byte is set.
// Device should somehow send the request to master.
}
// Device specific implementation of common commands
// (status registers etc are handled internally)
void scpi_user_CLS(void) { /*...*/ }
void scpi_user_RST(void) { /*...*/ }
void scpi_user_TSTq(void) { /*...*/ }
See the header files for more info.