예제 #1
0
/**************************
 * @function main
 ***************************/
int main( int argc, char* argv[] ) {
    
    // Call sns
    sns_init();
    sns_start();

    // 2. Open channels
    sns_chan_open( &chan_state_right, "state-right", NULL );

    {
	ach_channel_t *chans[] = {&chan_state_right, NULL};
	sns_sigcancel( chans, sns_sig_term_default );
    }

    // 3. Run
    while( !sns_cx.shutdown ) {
	update();
	aa_mem_region_local_release();
	usleep(0.5*1e6);
    }

    // 4. Leave
    sns_end();
    return 0;
}
예제 #2
0
파일: pirdump.c 프로젝트: ehuang3/piranha
int main( int argc, char **argv ) {

    ach_channel_t chan;
    sns_start();

    // open channel
    sns_chan_open( &chan,   "pir-state",   NULL );
    {
        ach_channel_t *chans[] = {&chan, NULL};
        sns_sigcancel( chans, sns_sig_term_default );
    }


    // state
    /* -- RUN -- */
    while (!sns_cx.shutdown) {
        struct pir_state state;
        size_t frame_size;
        ach_status_t r = ach_get( &chan, &state, sizeof(state), &frame_size,
                                  NULL, ACH_O_LAST );
        switch(r) {
        case ACH_OK:
        case ACH_MISSED_FRAME:
            dump(&state);
        case ACH_CANCELED:
        case ACH_TIMEOUT:
        case ACH_STALE_FRAMES:
            break;
        default:
            SNS_LOG(LOG_ERR, "Failed to get frame: %s\n", ach_result_to_string(r) );
        }
    }
}