/****************************** Main function ***************************/
void main()
{
 init_devices();
 xbee_reset();
 xbee();
 while(1)
 {
    if(DATA_RECEIVED == 1)
    {
	   int val;
	   val=RECEIVE();
      xbee_I_RECEIVE(val);
    }
    xbee_I_FRONT_IR_VALUE(FRONT_IR);
    xbee();
 }
}
Beispiel #2
0
static void* main_loop_routine(void* arg) {
    int rc;
    Notification notification;

    while (loop_count--) {
        rc = SEND(request_queue, request);
        CHECK_QUEUE(rc);
        if (rc == QREMOVED) {
            fprintf(stderr, "%s\n", queue_removed);
            break;
        } else {
            CHECK_VALUE(rc, QSUCCESS, rc);
        }

        pthread_cleanup_push(cancel_server_thread, NULL);

        rc = RECEIVE(notify_client_queue, notification, (long) getpid());
        CHECK_QUEUE(rc);
        if (rc == QREMOVED) {
            fprintf(stderr, "%s\n", queue_removed);
            break;
        } else {
            CHECK_VALUE(rc, QSUCCESS, rc);
        }

        sleep(sleep_time);

        rc = SEND(notify_server_queue, notification);
        CHECK_QUEUE(rc);
        if (rc == QREMOVED) {
            fprintf(stderr, "%s\n", queue_removed);
            break;
        } else {
            CHECK_VALUE(rc, QSUCCESS, rc);
        }

        pthread_cleanup_pop(false);
    }

    synchronized_cancel(&signal_handler);
    return NULL;
}
Beispiel #3
0
// rv=1 == got a line, 0= call me again
unsigned char getline_mc(unsigned char* buf, uint8_t len)
{
	static uint8_t i=0;
	unsigned char v;
	if (i==0) memset(buf,0,len);
	for(; i<len; i++) {
		if (uart_isdata()) {
			v = RECEIVE();
			if (((v == BS)||(v == DEL))&&(i)) { SEND(BS); SEND(SPACE); SEND(BS); i = i-2; continue; }; // Understand BS or DEL
			if (v == CR) { SEND(CR); SEND(LF); buf[i] = 0; i=0; return 1; }; // Understand CR
			if ((v < 32)||(v == DEL)) { i--; continue; }; // Filter ASCII control codes
			buf[i] = v;
			SEND(v);
		} else {
			return 0;
		}
	}
	buf[len-1] = 0;
	i=0;
	return 1;
}