Exemplo n.º 1
0
void msel_rfile_step_queue()
{
    rfile_empty = 0;

    // Messages from session 0 pre-empt anything in rq
    if (s0_rq.size > 0)
    {
        msel_memset(&s0, 0, sizeof(ffs_packet_t));
        s0.data[0] = (*s0_rq.start >> 8);
        s0.data[1] = (*s0_rq.start);
        if (msel_ffs_rfile_write(&s0) == MSEL_OK)
            CBUF_REM(s0_rq);
    }
Exemplo n.º 2
0
/**
 * Column callback
 */
static inline void cb_col(void *s, size_t len, void *data) {
    struct csv_context *ctx = (struct csv_context *)data;
    size_t cnt;

    // Put a comma if we should
    if(ctx->put_comma) {
        ctx->csv_buf = cbuf_putc(ctx->csv_buf, ',');
    }
    ctx->put_comma = 1;

    // If we are keeping same columns together see if we're on one
    if(ctx->gcol > -1 && ctx->col == ctx->gcol) {
        // Don't treat header columns as a group column
        if(!ctx->use_header || ctx->header_len) {
            // If we have a last column value and we're in overflow, check
	    	// the new row's value against the last one
            if(ctx->gcol_buf && ctx->opos && memcmp(ctx->gcol_buf, s, len) != 0) {
                // Flush the data we have!
                flush_file(ctx, 1);
            } else if(!ctx->gcol_buf) {
                // Initialize a new group column buffer
                ctx->gcol_buf = cbuf_init(len);
            }

            // Update our last group column value
            ctx->gcol_buf = cbuf_setlen(ctx->gcol_buf, (const char*)s, len);
        }
    }

    // Make sure we can write all the data
    while((cnt = csv_write(CBUF_PTR(ctx->csv_buf), CBUF_REM(ctx->csv_buf), s, len)) > CBUF_REM(ctx->csv_buf)) {
        // We didn't have room, reallocate
        ctx->csv_buf = cbuf_double(ctx->csv_buf);
    }

    // Increment where we are in our buffer
    CBUF_POS(ctx->csv_buf)+=cnt;

    // Increment our column
    ctx->col++;
}
Exemplo n.º 3
0
msel_status msel_ffs_session_recv(ffs_packet_t *pkt)
{
    // Find out which queue to get the next message from
    uint8_t sid;
    uint8_t task_id = msel_active_task_num;
    for (sid = 1; sid <= MAX_NUM_SESSIONS; ++sid)
        if (wq_1[sid].active && wq_1[sid].task_id == task_id) break;

    // Copy the message and advance the array index (the data's now in the task's
    // hands, if it throws it away there's no getting it back).
    if (sid > 0 && sid <= MAX_NUM_SESSIONS && wq_1[sid].size > 0)
    {
        msel_memcpy(pkt, wq_1[sid].start, sizeof(ffs_packet_t));

        // If the peripheral was told to retry, now we can say that we're ready
        if (sid == retry_session_id)
            clear_retry_id();

        CBUF_REM(wq_1[sid]);
        return MSEL_OK;
    }
    else return MSEL_ERESOURCE;
}