From 4ce20e5b60e977d66e5ab6fb0fa3ead4f6b9f93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Fri, 29 Oct 2010 07:50:57 +0000 Subject: [PATCH] - Clear MSB of data read on 7-bit serial port, as it looks necessary with 7S1 - Do read unwanted response in prm80_transaction(). git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@3001 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- prm80/prm80.c | 15 +++++++-------- src/iofunc.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/prm80/prm80.c b/prm80/prm80.c index 5545b0b79..a47beb58c 100644 --- a/prm80/prm80.c +++ b/prm80/prm80.c @@ -43,7 +43,7 @@ #define PROMPT ">" -#define BUFSZ 32 +#define BUFSZ 64 /* [0] = Reset. @@ -83,20 +83,19 @@ static int prm80_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, if (retval != RIG_OK) return retval; - /* no data expected, check for OK returned */ + /* no data wanted, but flush it anyway */ if (!data || !data_len) { -#if 0 char retbuf[BUFSZ+1]; - /* - * Does transceiver sends back ">" ? - */ - retval = read_string(&rs->rigport, retbuf, BUFSZ, PROMPT, strlen(PROMPT)); + retval = read_string(&rs->rigport, retbuf, BUFSZ, LF, strlen(LF)); if (retval < 0) return retval; retbuf[retval] = '\0'; - +#if 0 + /* + * Does transceiver sends back ">" ? + */ if (strstr(retbuf, PROMPT)) return RIG_OK; else diff --git a/src/iofunc.c b/src/iofunc.c index ded909b75..4b7110f9a 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -181,9 +181,20 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type) */ static ssize_t port_read(hamlib_port_t *p, void *buf, size_t count) { - if (p->type.rig == RIG_PORT_SERIAL) - return win32_serial_read(p->fd, buf, count); - else if (p->type.rig == RIG_PORT_NETWORK) + int i; + ssize_t ret; + + if (p->type.rig == RIG_PORT_SERIAL) { + ret = win32_serial_read(p->fd, buf, count); + if (p->parm.serial.data_bits == 7) { + unsigned char *pbuf = buf; + /* clear MSB */ + for (i=0; itype.rig == RIG_PORT_NETWORK) return recv(p->fd, buf, count, 0); else return read(p->fd, buf, count); @@ -223,7 +234,26 @@ static int port_select(hamlib_port_t *p, int n, fd_set *readfds, fd_set *writefd #else /* POSIX */ -#define port_read(p,b,c) read((p)->fd,(b),(c)) + +static ssize_t port_read(hamlib_port_t *p, void *buf, size_t count) +{ + int i; + ssize_t ret; + + if (p->type.rig == RIG_PORT_SERIAL && p->parm.serial.data_bits == 7) { + unsigned char *pbuf = buf; + + ret = read(p->fd, buf, count); + /* clear MSB */ + for (i=0; ifd, buf, count); + } +} + #define port_write(p,b,c) write((p)->fd,(b),(c)) #define port_select(p,n,r,w,e,t) select((n),(r),(w),(e),(t))