summaryrefslogtreecommitdiff
path: root/spectro/icoms.c
diff options
context:
space:
mode:
Diffstat (limited to 'spectro/icoms.c')
-rwxr-xr-xspectro/icoms.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/spectro/icoms.c b/spectro/icoms.c
index 875f3b6..08ddd92 100755
--- a/spectro/icoms.c
+++ b/spectro/icoms.c
@@ -760,8 +760,12 @@ int frbw /* nz to Flush Read Before Write */
int debug = p->log->debug;
int bread;
+ p->ser_clearerr(p);
+
if (debug < 8)
p->log->debug = 0;
+ /* (Could use tcflush() or ioctl(TCFLSH) on *nix, */
+ /* except these don't work on USB serial ports!) */
for (;;) {
bread = 0;
p->read(p, tbuf, 500, &bread, NULL, 500, 0.02);
@@ -813,6 +817,11 @@ double tout /* Timeout for write and then read (i.e. max = 2 x tout) */
return icoms_write_read_ex(p, wbuf, nwch, rbuf, bsize, bread, tc, ntc, tout, 0);
}
+/* Default NOP implementation - Serial open or set_methods may override */
+static void icoms_ser_clearerr(icoms *p) {
+ return;
+}
+
/* Optional callback to client from device */
/* Default implementation is a NOOP */
static int icoms_interrupt(icoms *p,
@@ -907,6 +916,7 @@ icoms *new_icoms(
p->read = NULL;
p->write_read = icoms_write_read;
p->write_read_ex = icoms_write_read_ex;
+ p->ser_clearerr = icoms_ser_clearerr; /* Default NOP implementation */
p->interrupt = icoms_interrupt;
p->del = icoms_del;