Jan Breuer
2012-12-26 100e86891d03181d5a77639b903e799e97ffb187
Add output flush callback
3个文件已修改
41 ■■■■ 已修改文件
README.md 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/inc/scpi/types.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/parser.c 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md
@@ -45,16 +45,20 @@
Source codes are devided into few files to provide better portability to other systems.
- *scpi_parser.c* - provides the core parser library
- *scpi_error.c* - provides basic error handling (error queue of the instrument)
- *scpi_ieee488.c* - provides basic implementation of IEEE488.2 mandatory commands
- *scpi_minimal.c* - provides basic implementation of SCPI mandatory commands
- *scpi_utils.c* - provides string handling routines and conversion routines
- *scpi_units.c* - provides handling of special numners (DEF, MIN, MAX, ...) and units
- *scpi_fifo.c* - provides basic implementation of error queue FIFO
- *scpi_debug.c* - provides debug functions
- *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
- *test-parser.c* - is the basic non-interactive demo of the parser
- *examples/test-parser* - is the basic non-interactive demo of the parser
- *examples/test-interactive* - is the basic interactive demo of the parser
- *examples/test-tcp* - is the basic interactive tcp server (port 5025)
- *examples/common* - common examples commands
Implementation to your instrument
-------------
libscpi/inc/scpi/types.h
@@ -102,6 +102,7 @@
    struct _scpi_interface_t {
        scpi_error_callback_t error;
        scpi_write_t write;
        scpi_command_callback_t flush;
        scpi_command_callback_t reset;
        scpi_command_callback_t test;
        scpi_command_callback_t srq;
libscpi/src/parser.c
@@ -245,6 +245,19 @@
}
/**
 * Flush data to SCPI output
 * @param context
 * @return
 */
static inline int flushData(scpi_t * context) {
    if (context && context->interface && context->interface->flush) {
        return context->interface->flush(context);
    } else {
        return SCPI_RES_OK;
    }
}
/**
 * Write result delimiter to output
 * @param context
 * @return number of bytes written
@@ -263,8 +276,11 @@
 * @return pocet zapsanych znaku
 */
static inline size_t writeNewLine(scpi_t * context) {
    size_t len;
    if (context->output_count > 0) {
        return writeData(context, "\r\n", 2);
        len = writeData(context, "\r\n", 2);
        flushData(context);
        return len;
    } else {
        return 0;
    }