kopia lustrzana https://github.com/Hamlib/Hamlib
- 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-79ac388436b8Hamlib-1.2.13
rodzic
ee55f04dd1
commit
4ce20e5b60
|
@ -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
|
||||
|
|
38
src/iofunc.c
38
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; i<ret; i++) {
|
||||
pbuf[i] &= ~0x80;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} else if (p->type.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; i<ret; i++) {
|
||||
pbuf[i] &= ~0x80;
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
return read(p->fd, 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))
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue