Jan Breuer
2013-04-28 929b7b909a37181407336af0d602b608a5161bd8
Better handling of SRQ, LwIP example typo
2个文件已修改
38 ■■■■ 已修改文件
examples/test-LwIP-netconn/scpi_server.c 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/ieee488.c 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/test-LwIP-netconn/scpi_server.c
@@ -54,6 +54,13 @@
#define SCPI_THREAD_PRIO (tskIDLE_PRIORITY + 2)
#define SCPI_MSG_TEST                   1
#define SCPI_MSG_IO_LISTEN              2
#define SCPI_MSG_CONTROL_IO_LISTEN      3
#define SCPI_MSG_IO                     4
#define SCPI_MSG_CONTROL_IO             5
#define SCPI_MSG_SET_ESE_REQ            6
typedef struct {
    struct netconn *io_listen;
    struct netconn *control_io_listen;
@@ -71,7 +78,6 @@
    .control_io = NULL,
    .evtQueue = 0,
};   
size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
    if (context->user_context != NULL) {
@@ -98,9 +104,16 @@
    (void) context;
    // BEEP
    iprintf("**ERROR: %ld, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
    if (err != 0) {
        /* New error */
        /* Beep */
        /* Error LED ON */
    } else {
        /* No more errors in the queue */
        /* Error LED OFF */
    }
    return 0;
}
scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) {
    char b[16];
@@ -139,19 +152,19 @@
}
#define SCPI_MSG_TEST                   1
#define SCPI_MSG_IO_LISTEN              2
#define SCPI_MSG_CONTROL_IO_LISTEN      3
#define SCPI_MSG_IO                     4
#define SCPI_MSG_CONTROL_IO             5
#define SCPI_MSG_SET_ESE_REQ            6
static void setEseReq(void) {
    SCPI_RegSetBits(&scpi_context, SCPI_REG_ESR, ESR_REQ);
}
void SCPI_RequestControl(void) {
    uint32_t msg = SCPI_MSG_SET_ESE_REQ;
    /* Avoid sending evtQueue message if ESR_REQ is already set
    if((SCPI_RegGet(&scpi_context, SCPI_REG_ESR) & ESR_REQ) == 0) {
        xQueueSend(user_data.evtQueue, &msg, 1000);
    }
    */
    xQueueSend(user_data.evtQueue, &msg, 1000);
}
@@ -207,7 +220,6 @@
    return rc;
}
static int processIoListen(user_data_t * user_data) {
    struct netconn *newconn;
libscpi/src/ieee488.c
@@ -100,11 +100,14 @@
void SCPI_RegSet(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t val) {
    bool_t srq = FALSE;
    scpi_reg_val_t mask;
    scpi_reg_val_t old_val;
    if ((name >= SCPI_REG_COUNT) || (context->registers == NULL)) {
        return;
    }
    
    /* store old register value */
    old_val = context->registers[name];
    /* set register value */
    context->registers[name] = val;
@@ -116,7 +119,10 @@
            mask &= ~STB_SRQ;
            if (val & mask) {
                val |= STB_SRQ;
                /* avoid sending SRQ if nothing has changed */
                if (old_val != val) {
                srq = TRUE;
                }
            } else {
                val &= ~STB_SRQ;
            }