kopia lustrzana https://github.com/Hamlib/Hamlib
win32termios: remove deadwood & keep naming space tidy
rodzic
cd79fca440
commit
9646b90a28
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(HAVE_TERMIOS_H)
|
#if defined(WIN32) && !defined(HAVE_TERMIOS_H)
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h> /* usleep() */
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#undef TRACE
|
#undef TRACE
|
||||||
|
|
||||||
|
@ -88,6 +92,8 @@ struct termios_list
|
||||||
};
|
};
|
||||||
struct termios_list *first_tl = NULL;
|
struct termios_list *first_tl = NULL;
|
||||||
|
|
||||||
|
static struct termios_list *find_port( int );
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
serial_test
|
serial_test
|
||||||
|
|
||||||
|
@ -122,7 +128,7 @@ int win32_serial_test( char * filename )
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void termios_setflags( int fd, int termios_flags[] )
|
static void termios_setflags( int fd, int termios_flags[] )
|
||||||
{
|
{
|
||||||
struct termios_list *index = find_port( fd );
|
struct termios_list *index = find_port( fd );
|
||||||
int i, result;
|
int i, result;
|
||||||
|
@ -160,6 +166,7 @@ void termios_setflags( int fd, int termios_flags[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
get_fd()
|
get_fd()
|
||||||
|
|
||||||
|
@ -248,6 +255,7 @@ void dump_termios_list( char *foo )
|
||||||
printf( "============== %s end ===============\n", foo );
|
printf( "============== %s end ===============\n", foo );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
set_errno()
|
set_errno()
|
||||||
|
@ -260,7 +268,7 @@ set_errno()
|
||||||
comments: FIXME
|
comments: FIXME
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
void set_errno( int error )
|
static void set_errno( int error )
|
||||||
{
|
{
|
||||||
my_errno = error;
|
my_errno = error;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +285,7 @@ usleep()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
void usleep( unsigned long usec )
|
static void usleep( unsigned long usec )
|
||||||
{
|
{
|
||||||
Sleep( usec/1000 );
|
Sleep( usec/1000 );
|
||||||
}
|
}
|
||||||
|
@ -294,7 +302,7 @@ CBR_toB()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int CBR_to_B( int Baud )
|
static int CBR_to_B( int Baud )
|
||||||
{
|
{
|
||||||
ENTER( "CBR_to_B" );
|
ENTER( "CBR_to_B" );
|
||||||
switch ( Baud )
|
switch ( Baud )
|
||||||
|
@ -352,7 +360,7 @@ B_to_CBR()
|
||||||
comments: None
|
comments: None
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int B_to_CBR( int Baud )
|
static int B_to_CBR( int Baud )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ENTER( "B_to_CBR" );
|
ENTER( "B_to_CBR" );
|
||||||
|
@ -414,7 +422,7 @@ bytesize_to_termios()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int bytesize_to_termios( int ByteSize )
|
static int bytesize_to_termios( int ByteSize )
|
||||||
{
|
{
|
||||||
ENTER( "bytesize_to_termios" );
|
ENTER( "bytesize_to_termios" );
|
||||||
switch ( ByteSize )
|
switch ( ByteSize )
|
||||||
|
@ -438,7 +446,7 @@ termios_to_bytesize()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int termios_to_bytesize( int cflag )
|
static int termios_to_bytesize( int cflag )
|
||||||
{
|
{
|
||||||
ENTER( "termios_to_bytesize" );
|
ENTER( "termios_to_bytesize" );
|
||||||
switch ( cflag & CSIZE )
|
switch ( cflag & CSIZE )
|
||||||
|
@ -463,7 +471,7 @@ get_dos_port()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
const char *get_dos_port( char const *name )
|
static const char *get_dos_port( char const *name )
|
||||||
{
|
{
|
||||||
ENTER( "get_dos_port" );
|
ENTER( "get_dos_port" );
|
||||||
if ( !strcmp( name, "/dev/cua0" ) ) return( "COM1" );
|
if ( !strcmp( name, "/dev/cua0" ) ) return( "COM1" );
|
||||||
|
@ -486,7 +494,7 @@ ClearErrors()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int ClearErrors( struct termios_list *index, COMSTAT *Stat )
|
static int ClearErrors( struct termios_list *index, COMSTAT *Stat )
|
||||||
{
|
{
|
||||||
unsigned long ErrCode;
|
unsigned long ErrCode;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -545,6 +553,7 @@ int ClearErrors( struct termios_list *index, COMSTAT *Stat )
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
FillDCB()
|
FillDCB()
|
||||||
|
|
||||||
|
@ -556,7 +565,7 @@ FillDCB()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
BOOL FillDCB( DCB *dcb, unsigned long *hCommPort, COMMTIMEOUTS Timeout )
|
static BOOL FillDCB( DCB *dcb, unsigned long *hCommPort, COMMTIMEOUTS Timeout )
|
||||||
{
|
{
|
||||||
|
|
||||||
ENTER( "FillDCB" );
|
ENTER( "FillDCB" );
|
||||||
|
@ -601,6 +610,7 @@ BOOL FillDCB( DCB *dcb, unsigned long *hCommPort, COMMTIMEOUTS Timeout )
|
||||||
LEAVE( "FillDCB" );
|
LEAVE( "FillDCB" );
|
||||||
return ( TRUE ) ;
|
return ( TRUE ) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
serial_close()
|
serial_close()
|
||||||
|
@ -708,7 +718,7 @@ void cfmakeraw( struct termios *s_termios )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
init_termios()
|
init_serial_struct()
|
||||||
|
|
||||||
accept:
|
accept:
|
||||||
perform:
|
perform:
|
||||||
|
@ -718,7 +728,7 @@ init_termios()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
BOOL init_serial_struct( struct serial_struct *sstruct )
|
static BOOL init_serial_struct( struct serial_struct *sstruct )
|
||||||
{
|
{
|
||||||
ENTER( "init_serial_struct" );
|
ENTER( "init_serial_struct" );
|
||||||
|
|
||||||
|
@ -779,7 +789,7 @@ init_termios()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
BOOL init_termios(struct termios *ttyset )
|
static BOOL init_termios(struct termios *ttyset )
|
||||||
{
|
{
|
||||||
ENTER( "init_termios" );
|
ENTER( "init_termios" );
|
||||||
if ( !ttyset )
|
if ( !ttyset )
|
||||||
|
@ -820,7 +830,7 @@ port_opened()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int port_opened( const char *filename )
|
static int port_opened( const char *filename )
|
||||||
{
|
{
|
||||||
struct termios_list *index = first_tl;
|
struct termios_list *index = first_tl;
|
||||||
|
|
||||||
|
@ -859,7 +869,7 @@ open_port()
|
||||||
structure in Serial_select.
|
structure in Serial_select.
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int open_port( struct termios_list *port )
|
static int open_port( struct termios_list *port )
|
||||||
{
|
{
|
||||||
ENTER( "open_port" );
|
ENTER( "open_port" );
|
||||||
port->hComm = CreateFile( port->filename,
|
port->hComm = CreateFile( port->filename,
|
||||||
|
@ -934,7 +944,7 @@ termios_list()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
struct termios_list *find_port( int fd )
|
static struct termios_list *find_port( int fd )
|
||||||
{
|
{
|
||||||
|
|
||||||
char message[80];
|
char message[80];
|
||||||
|
@ -973,7 +983,7 @@ get_free_fd()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int get_free_fd()
|
static int get_free_fd()
|
||||||
{
|
{
|
||||||
int next, last;
|
int next, last;
|
||||||
struct termios_list *index = first_tl;
|
struct termios_list *index = first_tl;
|
||||||
|
@ -1022,7 +1032,7 @@ add_port()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
struct termios_list *add_port( const char *filename )
|
static struct termios_list *add_port( const char *filename )
|
||||||
{
|
{
|
||||||
struct termios_list *index = first_tl;
|
struct termios_list *index = first_tl;
|
||||||
struct termios_list *port;
|
struct termios_list *port;
|
||||||
|
@ -1114,7 +1124,7 @@ check_port_capabilities()
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int check_port_capabilities( struct termios_list *index )
|
static int check_port_capabilities( struct termios_list *index )
|
||||||
{
|
{
|
||||||
COMMPROP cp;
|
COMMPROP cp;
|
||||||
DCB dcb;
|
DCB dcb;
|
||||||
|
@ -1810,7 +1820,7 @@ termios_to_DCB()
|
||||||
win32api: None
|
win32api: None
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
int termios_to_DCB( struct termios *s_termios, DCB *dcb )
|
static int termios_to_DCB( struct termios *s_termios, DCB *dcb )
|
||||||
{
|
{
|
||||||
ENTER( "termios_to_DCB" );
|
ENTER( "termios_to_DCB" );
|
||||||
s_termios->c_ispeed = s_termios->c_ospeed = s_termios->c_cflag & CBAUD;
|
s_termios->c_ispeed = s_termios->c_ospeed = s_termios->c_cflag & CBAUD;
|
||||||
|
@ -1884,7 +1894,7 @@ DCB_to_termios()
|
||||||
win32api: None
|
win32api: None
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
void DCB_to_termios( DCB *dcb, struct termios *s_termios )
|
static void DCB_to_termios( DCB *dcb, struct termios *s_termios )
|
||||||
{
|
{
|
||||||
ENTER( "DCB_to_termios" );
|
ENTER( "DCB_to_termios" );
|
||||||
s_termios->c_ispeed = CBR_to_B( dcb->BaudRate );
|
s_termios->c_ispeed = CBR_to_B( dcb->BaudRate );
|
||||||
|
@ -1903,7 +1913,7 @@ show_DCB()
|
||||||
win32api: None
|
win32api: None
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
void show_DCB( myDCB )
|
static void show_DCB( DCB myDCB )
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DEBUG_HOSED
|
#ifdef DEBUG_HOSED
|
||||||
|
@ -2553,6 +2563,8 @@ int tcflush( int fd, int queue_selector )
|
||||||
struct termios_list *index;
|
struct termios_list *index;
|
||||||
int old_flag;
|
int old_flag;
|
||||||
|
|
||||||
|
ENTER( "tcflush" );
|
||||||
|
|
||||||
index = find_port( fd );
|
index = find_port( fd );
|
||||||
if( !index)
|
if( !index)
|
||||||
{
|
{
|
||||||
|
@ -2566,12 +2578,6 @@ int tcflush( int fd, int queue_selector )
|
||||||
SetCommMask( index->hComm, index->event_flag );
|
SetCommMask( index->hComm, index->event_flag );
|
||||||
index->tx_happened = 1;
|
index->tx_happened = 1;
|
||||||
*/
|
*/
|
||||||
ENTER( "tcflush" );
|
|
||||||
if ( !index )
|
|
||||||
{
|
|
||||||
LEAVE( "tcflush" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
index->tx_happened = 1;
|
index->tx_happened = 1;
|
||||||
switch( queue_selector )
|
switch( queue_selector )
|
||||||
|
@ -3116,7 +3122,7 @@ fcntl()
|
||||||
comments: FIXME
|
comments: FIXME
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int fcntl( int fd, int command, ... )
|
int win32_serial_fcntl( int fd, int command, ... )
|
||||||
{
|
{
|
||||||
int arg, ret = 0;
|
int arg, ret = 0;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -3161,6 +3167,7 @@ int fcntl( int fd, int command, ... )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
termios_interrupt_event_loop()
|
termios_interrupt_event_loop()
|
||||||
|
|
||||||
|
@ -3171,7 +3178,7 @@ termios_interrupt_event_loop()
|
||||||
win32api:
|
win32api:
|
||||||
comments:
|
comments:
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
void termios_interrupt_event_loop( int fd, int flag )
|
static void termios_interrupt_event_loop( int fd, int flag )
|
||||||
{
|
{
|
||||||
struct termios_list * index = find_port( fd );
|
struct termios_list * index = find_port( fd );
|
||||||
if ( !index )
|
if ( !index )
|
||||||
|
@ -3189,6 +3196,7 @@ void termios_interrupt_event_loop( int fd, int flag )
|
||||||
index->interrupt = flag;
|
index->interrupt = flag;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
Serial_select()
|
Serial_select()
|
||||||
|
@ -3446,6 +3454,7 @@ fail:
|
||||||
#endif /* asdf */
|
#endif /* asdf */
|
||||||
#endif /* __LCC__ */
|
#endif /* __LCC__ */
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
termiosSetParityError()
|
termiosSetParityError()
|
||||||
|
|
||||||
|
@ -3457,7 +3466,7 @@ termiosSetParityError()
|
||||||
comments: No idea how to do this in Unix (handle in read?)
|
comments: No idea how to do this in Unix (handle in read?)
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
int termiosGetParityErrorChar( int fd )
|
static int termiosGetParityErrorChar( int fd )
|
||||||
{
|
{
|
||||||
struct termios_list *index;
|
struct termios_list *index;
|
||||||
DCB dcb;
|
DCB dcb;
|
||||||
|
@ -3485,12 +3494,12 @@ termiosSetParityError()
|
||||||
comments: No idea how to do this in Unix (handle in read?)
|
comments: No idea how to do this in Unix (handle in read?)
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
void termiosSetParityError( int fd, char value )
|
static void termiosSetParityError( int fd, char value )
|
||||||
{
|
{
|
||||||
DCB dcb;
|
DCB dcb;
|
||||||
struct termios_list *index;
|
struct termios_list *index;
|
||||||
|
|
||||||
ENTER( "termiosGetParityErrorChar" );
|
ENTER( "termiosSetParityErrorChar" );
|
||||||
index = find_port( fd );
|
index = find_port( fd );
|
||||||
if ( !index )
|
if ( !index )
|
||||||
{
|
{
|
||||||
|
@ -3500,8 +3509,10 @@ void termiosSetParityError( int fd, char value )
|
||||||
GetCommState( index->hComm, &dcb );
|
GetCommState( index->hComm, &dcb );
|
||||||
dcb.ErrorChar = value;
|
dcb.ErrorChar = value;
|
||||||
SetCommState( index->hComm, &dcb );
|
SetCommState( index->hComm, &dcb );
|
||||||
LEAVE( "termiosGetParityErrorChar" );
|
LEAVE( "termiosSetParityErrorChar" );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------- END OF LIBRARY -----------------*/
|
/*----------------------- END OF LIBRARY -----------------*/
|
||||||
|
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
|
@ -122,6 +122,7 @@ int win32_serial_close(int fd);
|
||||||
int win32_serial_read(int fd, void *b, int size);
|
int win32_serial_read(int fd, void *b, int size);
|
||||||
int win32_serial_write(int fd, const char *Str, int length);
|
int win32_serial_write(int fd, const char *Str, int length);
|
||||||
int win32_serial_ioctl(int fd, int request, ... );
|
int win32_serial_ioctl(int fd, int request, ... );
|
||||||
|
int win32_serial_fcntl(int fd, int command, ...);
|
||||||
/*
|
/*
|
||||||
* lcc winsock.h conflicts
|
* lcc winsock.h conflicts
|
||||||
*/
|
*/
|
||||||
|
@ -135,12 +136,14 @@ int win32_serial_select(int, struct fd_set *, struct fd_set *, struct fd_set *,
|
||||||
#define READ win32_serial_read
|
#define READ win32_serial_read
|
||||||
#define WRITE win32_serial_write
|
#define WRITE win32_serial_write
|
||||||
#define IOCTL win32_serial_ioctl
|
#define IOCTL win32_serial_ioctl
|
||||||
|
#define FCNTL win32_serial_fcntl
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* local functions */
|
||||||
void termios_interrupt_event_loop( int , int );
|
void termios_interrupt_event_loop( int , int );
|
||||||
void termios_setflags( int , int[] );
|
void termios_setflags( int , int[] );
|
||||||
struct termios_list *find_port( int );
|
struct termios_list *find_port( int );
|
||||||
int usleep(unsigned int usec);
|
int usleep(unsigned int usec);
|
||||||
int fcntl(int fd, int command, ...);
|
|
||||||
const char *get_dos_port(const char *);
|
const char *get_dos_port(const char *);
|
||||||
void set_errno(int);
|
void set_errno(int);
|
||||||
char *sterror(int);
|
char *sterror(int);
|
||||||
|
@ -148,6 +151,8 @@ int B_to_CBR(int);
|
||||||
int CBR_to_B(int);
|
int CBR_to_B(int);
|
||||||
int termios_to_bytesize(int);
|
int termios_to_bytesize(int);
|
||||||
int bytesize_to_termios(int);
|
int bytesize_to_termios(int);
|
||||||
|
#endif
|
||||||
|
|
||||||
int tcgetattr(int Fd, struct termios *s_termios);
|
int tcgetattr(int Fd, struct termios *s_termios);
|
||||||
int tcsetattr(int Fd, int when, struct termios *);
|
int tcsetattr(int Fd, int when, struct termios *);
|
||||||
speed_t cfgetospeed(struct termios *s_termios);
|
speed_t cfgetospeed(struct termios *s_termios);
|
||||||
|
@ -165,8 +170,10 @@ int tcsendbreak ( int , int );
|
||||||
int fstat(int fd, ... );
|
int fstat(int fd, ... );
|
||||||
*/
|
*/
|
||||||
void cfmakeraw(struct termios *s_termios);
|
void cfmakeraw(struct termios *s_termios);
|
||||||
|
#if 0
|
||||||
int termiosGetParityErrorChar( int );
|
int termiosGetParityErrorChar( int );
|
||||||
void termiosSetParityError( int, char );
|
void termiosSetParityError( int, char );
|
||||||
|
#endif
|
||||||
|
|
||||||
#define O_NOCTTY 0400 /* not for fcntl */
|
#define O_NOCTTY 0400 /* not for fcntl */
|
||||||
#define O_NONBLOCK 00004
|
#define O_NONBLOCK 00004
|
||||||
|
|
Ładowanie…
Reference in New Issue