Esempio n. 1
0
void loop (void) {
    static int ctr = 0;
    uint16_t channels[8];

    hal.gpio->write(13, 1);

    /* Cycle between using the individual read method
     * and the multi read method*/
    if (ctr < 500) {
        multiread(hal.rcin, channels);
    } else {
        individualread(hal.rcin, channels);
        if (ctr > 1000)  ctr = 0;
    }

    hal.gpio->write(13, 0);
    hal.scheduler->delay(50);
    ctr++;
}
Esempio n. 2
0
int request_response(int operationid, char *bufreq, int lenreq, char *bufres, int *lenres)
{
	int sock;
	sock = create_socket(Operations[operationid].host, Operations[operationid].port);
	if (sock<0) {
		return sock;
	}
	if (lenreq != write(sock, bufreq, lenreq)) {
		close(sock);
		return 1;
	}
	*lenres = multiread(sock, bufres, BUF_RES_SIZE);
	close(sock);
	if (*lenres < 0) {
		*lenres = 0;
		return 2;
	}
	return 0;
}