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

Function win32_serial_select

lib/termios.c:3702–3859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3700----------------------------------------------------------*/
3701#ifndef __LCC__
3702int win32_serial_select(int n, fd_set *readfds, fd_set *writefds,
3703 fd_set *exceptfds, struct timeval *timeout)
3704{
3705
3706 unsigned long dwCommEvent, wait = WAIT_TIMEOUT;
3707 int fd = n - 1;
3708 struct termios_list *index;
3709 char message[80];
3710 COMSTAT Stat;
3711 int ret;
3712
3713 ENTER("serial_select");
3714
3715 if (fd <= 0)
3716 {
3717 /* Baby did a bad baad thing */
3718 goto fail;
3719 }
3720
3721 index = win32_serial_find_port(fd);
3722
3723 if (!index)
3724 {
3725 goto fail;
3726 }
3727
3728#define DATA_AVAILABLE 1
3729
3730 //nativeSetEventFlag( fd, SerialPortEvent.DATA_AVAILABLE, enable );
3731 if (readfds)
3732 {
3733 int eventflags[12];
3734 memset(eventflags, 0, sizeof(eventflags));
3735
3736 eventflags[DATA_AVAILABLE] = 1;
3737 termios_setflags(fd, eventflags);
3738 }
3739
3740 if (!index->event_flag)
3741 {
3742 /* still setting up the port? hold off for a Sec so
3743 things can fire up
3744
3745 this does happen. loops ~twice on a 350 Mzh with
3746 hl_usleep(1000000)
3747 */
3748 /* hl_usleep(10000); */
3749 LEAVE("serial_uselect");
3750 return (0);
3751 }
3752
3753 ResetEvent(index->wol.hEvent);
3754 ResetEvent(index->sol.hEvent);
3755 ResetEvent(index->rol.hEvent);
3756 ret = ClearErrors(index, &Stat);
3757#if 1
3758
3759 if (ret == 0)

Callers 1

port_selectFunction · 0.85

Calls 5

win32_serial_find_portFunction · 0.85
termios_setflagsFunction · 0.85
ClearErrorsFunction · 0.85
hl_usleepFunction · 0.85
set_errnoFunction · 0.85

Tested by

no test coverage detected