MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / port_read_generic

Function port_read_generic

src/iofunc.c:609–657  ·  view source on GitHub ↗

On MinGW32/MSVC/.. the appropriate accessor must be used * depending on the port type, sigh. */

Source from the content-addressed store, hash-verified

607 * depending on the port type, sigh.
608 */
609static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count,
610 int direct)
611{
612 int fd = p->fd;
613 int i;
614 ssize_t bytes_read;
615
616 if (!direct)
617 {
618 return port_read_sync_data_pipe(p, buf, count);
619 }
620
621 /*
622 * Since WIN32 does its special serial read, we have
623 * to catch the microHam case to do just "read".
624 * Note that we always have RIG_PORT_SERIAL in the
625 * microHam case.
626 */
627 if (is_uh_radio_fd(fd))
628 {
629 return read(fd, buf, count);
630 }
631
632 if (p->type.rig == RIG_PORT_SERIAL)
633 {
634 bytes_read = win32_serial_read(fd, buf, (int) count);
635
636 if (p->parm.serial.data_bits == 7)
637 {
638 unsigned char *pbuf = buf;
639
640 /* clear MSB */
641 for (i = 0; i < bytes_read; i++)
642 {
643 pbuf[i] &= ~0x80;
644 }
645 }
646
647 return bytes_read;
648 }
649 else if (p->type.rig == RIG_PORT_NETWORK || p->type.rig == RIG_PORT_UDP_NETWORK)
650 {
651 return recv(fd, buf, count, 0);
652 }
653 else
654 {
655 return read(fd, buf, count);
656 }
657}
658
659static ssize_t port_write(hamlib_port_t *p, const void *buf, size_t count)
660{

Callers 2

read_block_genericFunction · 0.85
read_string_genericFunction · 0.85

Calls 3

port_read_sync_data_pipeFunction · 0.85
is_uh_radio_fdFunction · 0.85
win32_serial_readFunction · 0.85

Tested by

no test coverage detected