add serial_flush()
This commit is contained in:
parent
e1aac2319a
commit
06d64eb880
|
@ -95,6 +95,13 @@ int serial_close(int fd)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int serial_flush(int fd)
|
||||||
|
{
|
||||||
|
|
||||||
|
tcflush(fd, TCIOFLUSH);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void *serial_backup_params(int fd)
|
void *serial_backup_params(int fd)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#define NUM_TRIGGER_STAGES 4
|
#define NUM_TRIGGER_STAGES 4
|
||||||
#define TRIGGER_TYPES "01"
|
#define TRIGGER_TYPES "01"
|
||||||
#define SERIAL_SPEED B115200
|
#define SERIAL_SPEED B115200
|
||||||
/* TODO: SERIAL_ bits, parity, stop bit */
|
|
||||||
#define CLOCK_RATE 100000000
|
#define CLOCK_RATE 100000000
|
||||||
|
|
||||||
/* Command opcodes */
|
/* Command opcodes */
|
||||||
|
@ -243,12 +242,7 @@ static int hw_init(char *deviceinfo)
|
||||||
* respond with g_poll().
|
* respond with g_poll().
|
||||||
*/
|
*/
|
||||||
g_message("probing %s...", (char *)l->data);
|
g_message("probing %s...", (char *)l->data);
|
||||||
#ifdef _WIN32
|
|
||||||
// FIXME
|
|
||||||
// hdl = serial_open(l->data, 0);
|
|
||||||
#else
|
|
||||||
fd = serial_open(l->data, O_RDWR | O_NONBLOCK);
|
fd = serial_open(l->data, O_RDWR | O_NONBLOCK);
|
||||||
#endif
|
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
serial_params[devcnt] = serial_backup_params(fd);
|
serial_params[devcnt] = serial_backup_params(fd);
|
||||||
serial_set_params(fd, 115200, 8, 0, 1, 2);
|
serial_set_params(fd, 115200, 8, 0, 1, 2);
|
||||||
|
@ -631,10 +625,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
||||||
}
|
}
|
||||||
free(raw_sample_buf);
|
free(raw_sample_buf);
|
||||||
|
|
||||||
#ifndef _WIN32
|
serial_flush(fd);
|
||||||
/* TODO: Move to serial.c? */
|
|
||||||
tcflush(fd, TCIOFLUSH);
|
|
||||||
#endif
|
|
||||||
serial_close(fd);
|
serial_close(fd);
|
||||||
packet.type = DF_END;
|
packet.type = DF_END;
|
||||||
packet.length = 0;
|
packet.length = 0;
|
||||||
|
|
Loading…
Reference in New Issue