user.odl
来自「The code for this article was written fo」· ODL 代码 · 共 2,094 行 · 第 1/5 页
ODL
2,094 行
// Events
//define EV_RXCHAR 0x0001 // Any Character received
//define EV_RXFLAG 0x0002 // Received certain character
//define EV_TXEMPTY 0x0004 // Transmitt Queue Empty
//define EV_CTS 0x0008 // CTS changed state
//define EV_DSR 0x0010 // DSR changed state
//define EV_RLSD 0x0020 // RLSD changed state
//define EV_BREAK 0x0040 // BREAK received
//define EV_ERR 0x0080 // Line status error occurred
//define EV_RING 0x0100 // Ring signal detected
//define EV_PERR 0x0200 // Printer error occured
//define EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
//define EV_EVENT1 0x0800 // Provider specific event 1
//define EV_EVENT2 0x1000 // Provider specific event 2
//define EV_CTSS 0x0400
//define EV_DSRS 0x0800
//define EV_RLSDS 0x1000
//define EV_RingTe 0x2000
//define EV_RINGTE EV_RingTe
// Escape Functions
//define SETXOFF 1 // Simulate XOFF received
//define SETXON 2 // Simulate XON received
//define SETRTS 3 // Set RTS high
//define CLRRTS 4 // Set RTS low
//define SETDTR 5 // Set DTR high
//define CLRDTR 6 // Set DTR low
//define RESETDEV 7 // Reset device if possible
//define SETBREAK 8 // Set the device break line.
//define CLRBREAK 9 // Clear the device break line.
//define LPTx 0x80 // Set if ID is for LPT device
// new escape functions
//define GETMAXLPT 8
//define GETMAXCOM 9
//define GETBASEIRQ 10
// Comm Baud Rate indices
//define CBR_110 0xFF10
//define CBR_300 0xFF11
//define CBR_600 0xFF12
//define CBR_1200 0xFF13
//define CBR_2400 0xFF14
//define CBR_4800 0xFF15
//define CBR_9600 0xFF16
//define CBR_14400 0xFF17
//define CBR_19200 0xFF18
//define CBR_38400 0xFF1B
//define CBR_56000 0xFF1F
//define CBR_128000 0xFF23
//define CBR_256000 0xFF27
// notifications passed in low word of lParam on WM_COMMNOTIFY messages
//define CN_RECEIVE 0x0001
//define CN_TRANSMIT 0x0002
//define CN_EVENT 0x0004
//
// PURGE function flags.
//
//define PURGE_TXABORT 0x0001 // Kill the pending/current writes to the comm port.
//define PURGE_RXABORT 0x0002 // Kill the pending/current reads to the comm port.
//define PURGE_TXCLEAR 0x0004 // Kill the transmit queue if there.
//define PURGE_RXCLEAR 0x0008 // Kill the typeahead buffer if there.
//
// Modem Status Flags
//
//define MS_CTS_ON ((DWORD)0x0010)
//define MS_DSR_ON ((DWORD)0x0020)
//define MS_RING_ON ((DWORD)0x0040)
//define MS_RLSD_ON ((DWORD)0x0080)
//
// Serial provider type.
//
//define SP_SERIALCOMM ((DWORD)0x00000001)
//
// Provider SubTypes
//
//define PST_UNSPECIFIED ((DWORD)0x00000000)
//define PST_RS232 ((DWORD)0x00000001)
//define PST_PARALLELPORT ((DWORD)0x00000002)
//define PST_RS422 ((DWORD)0x00000003)
//define PST_RS423 ((DWORD)0x00000004)
//define PST_RS449 ((DWORD)0x00000005)
//define PST_FAX ((DWORD)0x00000021)
//define PST_SCANNER ((DWORD)0x00000022)
//define PST_NETWORK_BRIDGE ((DWORD)0x00000100)
//define PST_LAT ((DWORD)0x00000101)
//define PST_TCPIP_TELNET ((DWORD)0x00000102)
//define PST_X25 ((DWORD)0x00000103)
//
// Provider capabilities flags.
//
//define PCF_DTRDSR ((DWORD)0x0001)
//define PCF_RTSCTS ((DWORD)0x0002)
//define PCF_RLSD ((DWORD)0x0004)
//define PCF_PARITY_CHECK ((DWORD)0x0008)
//define PCF_XONXOFF ((DWORD)0x0010)
//define PCF_SETXCHAR ((DWORD)0x0020)
//define PCF_TOTALTIMEOUTS ((DWORD)0x0040)
//define PCF_INTTIMEOUTS ((DWORD)0x0080)
//define PCF_SPECIALCHARS ((DWORD)0x0100)
//define PCF_16BITMODE ((DWORD)0x0200)
//
// Comm provider settable parameters.
//
//define SP_PARITY ((DWORD)0x0001)
//define SP_BAUD ((DWORD)0x0002)
//define SP_DATABITS ((DWORD)0x0004)
//define SP_STOPBITS ((DWORD)0x0008)
//define SP_HANDSHAKING ((DWORD)0x0010)
//define SP_PARITY_CHECK ((DWORD)0x0020)
//define SP_RLSD ((DWORD)0x0040)
//
// Settable baud rates in the provider.
//
//define BAUD_075 ((DWORD)0x00000001)
//define BAUD_110 ((DWORD)0x00000002)
//define BAUD_134_5 ((DWORD)0x00000004)
//define BAUD_150 ((DWORD)0x00000008)
//define BAUD_300 ((DWORD)0x00000010)
//define BAUD_600 ((DWORD)0x00000020)
//define BAUD_1200 ((DWORD)0x00000040)
//define BAUD_1800 ((DWORD)0x00000080)
//define BAUD_2400 ((DWORD)0x00000100)
//define BAUD_4800 ((DWORD)0x00000200)
//define BAUD_7200 ((DWORD)0x00000400)
//define BAUD_9600 ((DWORD)0x00000800)
//define BAUD_14400 ((DWORD)0x00001000)
//define BAUD_19200 ((DWORD)0x00002000)
//define BAUD_38400 ((DWORD)0x00004000)
//define BAUD_56K ((DWORD)0x00008000)
//define BAUD_128K ((DWORD)0x00010000)
//define BAUD_115200 ((DWORD)0x00020000)
//define BAUD_57600 ((DWORD)0x00040000)
//define BAUD_USER ((DWORD)0x10000000)
//
// Settable Data Bits
//
//define DATABITS_5 ((WORD)0x0001)
//define DATABITS_6 ((WORD)0x0002)
//define DATABITS_7 ((WORD)0x0004)
//define DATABITS_8 ((WORD)0x0008)
//define DATABITS_16 ((WORD)0x0010)
//define DATABITS_16X ((WORD)0x0020)
//
// Settable Stop and Parity bits.
//
//define STOPBITS_10 ((WORD)0x0001)
//define STOPBITS_15 ((WORD)0x0002)
//define STOPBITS_20 ((WORD)0x0004)
//define PARITY_NONE ((WORD)0x0100)
//define PARITY_ODD ((WORD)0x0200)
//define PARITY_EVEN ((WORD)0x0400)
//define PARITY_MARK ((WORD)0x0800)
//define PARITY_SPACE ((WORD)0x1000)
typedef struct _DCB {
DWORD DCBlength; // sizeof(DCB)
DWORD BaudRate; // Baudrate at which running
DWORD fBinary: 1; // Binary Mode (skip EOF check)
DWORD fParity: 1; // Enable parity checking
DWORD fOutxCtsFlow:1; // CTS handshaking on output
DWORD fOutxDsrFlow:1; // DSR handshaking on output
DWORD fDtrControl:2; // DTR Flow control
DWORD fDsrSensitivity:1; // DSR Sensitivity
DWORD fTXContinueOnXoff: 1; // Continue TX when Xoff sent
DWORD fOutX: 1; // Enable output X-ON/X-OFF
DWORD fInX: 1; // Enable input X-ON/X-OFF
DWORD fErrorChar: 1; // Enable Err Replacement
DWORD fNull: 1; // Enable Null stripping
DWORD fRtsControl:2; // Rts Flow control
DWORD fAbortOnError:1; // Abort all reads and writes on Error
DWORD fDummy2:17; // Reserved
WORD wReserved; // Not currently used
WORD XonLim; // Transmit X-ON threshold
WORD XoffLim; // Transmit X-OFF threshold
BYTE ByteSize; // Number of bits/byte, 4-8
BYTE Parity; // 0-4=None,Odd,Even,Mark,Space
BYTE StopBits; // 0,1,2 = 1, 1.5, 2
char XonChar; // Tx and Rx X-ON character
char XoffChar; // Tx and Rx X-OFF character
char ErrorChar; // Error replacement char
char EofChar; // End of Input character
char EvtChar; // Received Event character
WORD wReserved1; // Fill for now.
} DCB, *LPDCB;
typedef struct tagCOMSTAT
{
BYTE status;
UINT cbInQue;
UINT cbOutQue;
} COMSTAT;
typedef struct _COMMTIMEOUTS {
DWORD ReadIntervalTimeout; // Maximum time between read chars.
DWORD ReadTotalTimeoutMultiplier; // Multiplier of characters.
DWORD ReadTotalTimeoutConstant; // Constant in milliseconds.
DWORD WriteTotalTimeoutMultiplier; // Multiplier of characters.
DWORD WriteTotalTimeoutConstant; // Constant in milliseconds.
} COMMTIMEOUTS,*LPCOMMTIMEOUTS;
typedef struct _COMMCONFIG {
DWORD dwSize;
WORD wVersion;
WORD wReserved;
DCB dcb;
DWORD dwProviderSubType;
DWORD dwProviderOffset;
DWORD dwProviderSize;
WCHAR wcProviderData[1];
} COMMCONFIG,*LPCOMMCONFIG;
//define CSTF_CTSHOLD 0x01
//define CSTF_DSRHOLD 0x02
//define CSTF_RLSDHOLD 0x04
//define CSTF_XOFFHOLD 0x08
//define CSTF_XOFFSENT 0x10
//define CSTF_EOF 0x20
//define CSTF_TXIM 0x40
// NOTE: This structure declaration is not ANSI compatible!
typedef struct tagCOMSTAT
{
BYTE fCtsHold :1;
BYTE fDsrHold :1;
BYTE fRlsdHold :1;
BYTE fXoffHold :1;
BYTE fXoffSent :1;
BYTE fEof :1;
BYTE fTxim :1;
UINT cbInQue;
UINT cbOutQue;
} COMSTAT;
typedef struct _COMMPROP {
WORD wPacketLength;
WORD wPacketVersion;
DWORD dwServiceMask;
DWORD dwReserved1;
DWORD dwMaxTxQueue;
DWORD dwMaxRxQueue;
DWORD dwMaxBaud;
DWORD dwProvSubType;
DWORD dwProvCapabilities;
DWORD dwSettableParams;
DWORD dwSettableBaud;
WORD wSettableData;
WORD wSettableStopParity;
DWORD dwCurrentTxQueue;
DWORD dwCurrentRxQueue;
DWORD dwProvSpec1;
DWORD dwProvSpec2;
WCHAR wcProvChar[1];
} COMMPROP,*LPCOMMPROP;
//
// DTR Control Flow Values.
//
//define DTR_CONTROL_DISABLE 0x00
//define DTR_CONTROL_ENABLE 0x01
//define DTR_CONTROL_HANDSHAKE 0x02
//
// RTS Control Flow Values
//
//define RTS_CONTROL_DISABLE 0x00
//define RTS_CONTROL_ENABLE 0x01
//define RTS_CONTROL_HANDSHAKE 0x02
//define RTS_CONTROL_TOGGLE 0x03
*/
/*
BOOL WINAPI ClearCommError(
HANDLE hFile,
LPDWORD lpErrors,
LPCOMSTAT lpStat
);
BOOL WINAPI SetupComm(
HANDLE hFile,
DWORD dwInQueue,
DWORD dwOutQueue
);
BOOL WINAPI GetCommConfig(
HANDLE hCommDev,
LPCOMMCONFIG lpCC,
LPDWORD lpdwSize
);
BOOL WINAPI GetCommMask(
HANDLE hFile,
LPDWORD lpEvtMask
);
BOOL WINAPI GetCommProperties(
HANDLE hFile,
LPCOMMPROP lpCommProp
);
BOOL WINAPI GetCommModemStatus(
HANDLE hFile,
LPDWORD lpModemStat
);
BOOL WINAPI GetCommTimeouts(
HANDLE hFile,
LPCOMMTIMEOUTS lpCommTimeouts
);
BOOL WINAPI PurgeComm(
HANDLE hFile,
DWORD dwFlags
);
BOOL WINAPI SetCommConfig(
HANDLE hCommDev,
LPCOMMCONFIG lpCC,
DWORD dwSize
);
BOOL WINAPI SetCommMask(
HANDLE hFile,
DWORD dwEvtMask
);
BOOL WINAPI SetCommTimeouts(
HANDLE hFile,
LPCOMMTIMEOUTS lpCommTimeouts
);
BOOL WINAPI WaitCommEvent(
HANDLE hFile,
LPDWORD lpEvtMask,
LPOVERLAPPED lpOverlapped
);
BOOL WINAPI BuildCommDCBA(
LPCSTR lpDef,
LPDCB lpDCB
);
BOOL WINAPI BuildCommDCBAndTimeoutsA(
LPCSTR lpDef,
LPDCB lpDCB,
LPCOMMTIMEOUTS lpCommTimeouts
);
BOOL WINAPI CommConfigDialogA(
LPCSTR lpszName,
HWND hWnd,
LPCOMMCONFIG lpCC
);
BOOL WINAPI GetDefaultCommConfigA(
LPCSTR lpszName,
LPCOMMCONFIG lpCC,
LPDWORD lpdwSize
);
BOOL WINAPI SetDefaultCommConfigA(
LPCSTR lpszName,
LPCOMMCONFIG lpCC,
DWORD dwSize
);
int WINAPI OpenComm(LPCSTR, UINT, UINT);
int WINAPI CloseComm(int);
int WINAPI ReadComm(int, void FAR*, int);
int WINAPI WriteComm(int, const void FAR*, int);
int WINAPI UngetCommChar(int, char);
int WINAPI FlushComm(int, int);
int WINAPI TransmitCommChar(int, char);
int WINAPI SetCommState(const DCB FAR*);
int WINAPI GetCommState(int, DCB FAR*);
int WINAPI GetCommError(int, COMSTAT FAR* );
int WINAPI SetCommBreak(int);
int WINAPI ClearCommBreak(int);
UINT FAR* WINAPI SetCommEventMask(int, UINT);
UINT WINAPI GetCommEventMask(int, int);
LONG WINAPI EscapeCommFunction(int, int);
BOOL WINAPI EnableCommNotification(int, [in] HWND hwnd, int, int);
*/
// ****** Omit String formatting support *********
/*
int WINAPI wvsprintf(LPSTR lpszOut, LPCSTR lpszFmt, const void FAR* lpParams);
int FAR CDECL wsprintf(LPSTR lps
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?