6 #define GET_MSEC_TIME() ((DWORD) (fb_Timer() * 1000.0))
17 DWORD dwModemStatus = 0;
19 if( !GetCommModemStatus( hDevice, &dwModemStatus ) )
23 && ((dwModemStatus & dwMask)!=dwResult) )
25 if( !GetCommModemStatus( hDevice, &dwModemStatus ) )
28 return ((dwModemStatus & dwMask)==dwResult);
37 MS_RLSD_ON, MS_RLSD_ON,
53 const char *pszDevice,
void **ppvHandle )
55 DWORD dwDefaultTxBufferSize = 16384;
56 DWORD dwDefaultRxBufferSize = 16384;
57 DWORD dwDesiredAccess = 0;
58 DWORD dwShareMode = 0;
71 dwDesiredAccess = GENERIC_READ;
74 dwDesiredAccess = GENERIC_WRITE;
78 dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
82 switch( handle->
lock ) {
84 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
87 dwShareMode = FILE_SHARE_WRITE;
90 dwShareMode = FILE_SHARE_READ;
97 pszDev = calloc(strlen( pszDevice ) + 5, 1);
101 strcpy( pszDev,
"COM1:" );
106 strcpy(pszDev,
"\\\\.\\");
110 strcat(pszDev, pszDevice);
111 p = strchr( pszDev,
':');
119 if( !GetDefaultCommConfig( pszDev, &cc, &dwSizeCC ) ) {
135 if( hDevice==INVALID_HANDLE_VALUE )
141 if( !GetCommProperties( hDevice, &prop ) ) {
144 if( prop.dwCurrentTxQueue ) {
145 dwDefaultTxBufferSize = prop.dwCurrentTxQueue;
146 }
else if( prop.dwMaxTxQueue ) {
147 dwDefaultTxBufferSize = prop.dwMaxTxQueue;
150 if( prop.dwCurrentRxQueue ) {
151 dwDefaultRxBufferSize = prop.dwCurrentRxQueue;
152 }
else if( prop.dwMaxRxQueue ) {
153 dwDefaultRxBufferSize = prop.dwMaxRxQueue;
163 if( !SetupComm( hDevice,
164 dwDefaultRxBufferSize,
165 dwDefaultTxBufferSize ) )
174 COMMTIMEOUTS timeouts;
175 if( !GetCommTimeouts( hDevice, &timeouts ) ) {
179 timeouts.ReadIntervalTimeout = options->
DurationCTS;
180 timeouts.ReadTotalTimeoutMultiplier =
181 timeouts.ReadTotalTimeoutConstant = 0;
183 if( !SetCommTimeouts( hDevice, &timeouts ) ) {
192 if( !GetCommState( hDevice, &dcb ) ) {
195 dcb.BaudRate = options->
uiSpeed;
196 dcb.fBinary = !options->
AddLF;
199 dcb.fDtrControl = ( (options->
KeepDTREnabled) ? DTR_CONTROL_ENABLE : DTR_CONTROL_DISABLE );
203 dcb.fOutxDsrFlow =
FALSE;
211 dcb.fRtsControl = ( ( options->
SuppressRTS ) ? RTS_CONTROL_DISABLE : RTS_CONTROL_HANDSHAKE );
213 dcb.fAbortOnError =
FALSE;
216 switch ( options->
Parity ) {
218 dcb.Parity = NOPARITY;
221 dcb.Parity = EVENPARITY;
224 dcb.Parity = ODDPARITY;
227 dcb.Parity = SPACEPARITY;
230 dcb.Parity = MARKPARITY;
236 dcb.StopBits = ONESTOPBIT;
239 dcb.StopBits = ONE5STOPBITS;
242 dcb.StopBits = TWOSTOPBITS;
246 if( !SetCommState( hDevice, &dcb ) ) {
249 EscapeCommFunction( hDevice, SETDTR );
259 CloseHandle( hDevice );
265 pInfo->
iPort = iPort;
278 if( !ClearCommError( pInfo->
hDevice, &dwErrors, &Status ) )
281 *pLength = (long) Status.cbInQue;
286 void *pvHandle,
const void *data,
size_t length )
295 if( !WriteFile( pInfo->
hDevice,
302 if( length != (
size_t) dwWriteCount )
309 void *pvHandle,
void *data,
size_t *pLength )
326 *pLength = (size_t) dwReadCount;