static void serial_collect_samples(void *a_data __attribute__((unused))) { struct packet *data = (struct packet *)a_data; uint8_t size = 0x00; uint16_t buffs = (PWM_SAMPLES_BUFFER*PWM_BUFFERS); uint16_t avail = (buffs + g_head - g_tail) % buffs; if (avail > 192) { serial_poll_send("WAIT", 4); } if (0 >= (size = slip_recv((void *)data, sizeof(struct packet)))) { return; } // ignore incomplete data chunks, packet should contain at least 1 sample if (size < 4) { return; } // verify if the information is genuine if (!slip_verify_crc16((unsigned char *)data, size, 0)) { return; } g_head += data->num; }