Example #1
0
/**
 * Push error to queue
 * @param context
 * @param err - error number
 * @param info - additional text information or NULL for no text
 * @param info_len - length of text or 0 for automatic length
 */
void SCPI_ErrorPushEx(scpi_t * context, int16_t err, char * info, size_t info_len) {
    int i;
    /* automatic calculation of length */
    if (info && info_len == 0) {
        info_len = SCPIDEFINE_strnlen(info, SCPI_STD_ERROR_DESC_MAX_STRING_LENGTH);
    }
    scpi_bool_t queue_overflow = !SCPI_ErrorAddInternal(context, err, info, info_len);

    for (i = 0; i < ERROR_DEFS_N; i++) {
        if ((err <= errs[i].from) && (err >= errs[i].to)) {
            SCPI_RegSetBits(context, SCPI_REG_ESR, errs[i].esrBit);
        }
    }

    SCPI_ErrorEmit(context, err);
    if (queue_overflow) {
        SCPI_ErrorEmit(context, SCPI_ERROR_QUEUE_OVERFLOW);
    }

    if (context) {
        context->cmd_error = TRUE;
    }
}
Example #2
0
/**
 * Push error to queue
 * @param context - scpi context
 * @param err - error number
 */
void SCPI_ErrorPush(scpi_t * context, int16_t err) {

    int i;

    SCPI_ErrorAddInternal(context, err);

    for (i = 0; i < ERROR_DEFS_N; i++) {
        if ((err <= errs[i].from) && (err >= errs[i].to)) {
            SCPI_RegSetBits(context, SCPI_REG_ESR, errs[i].bit);
        }
    }

    SCPI_ErrorEmit(context, err);

    if (context) {
        context->cmd_error = TRUE;
    }
}