📄 tty.h
字号:
// TTY.h: interface for the CTTY class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TTY_H__07B39577_ABAC_11D2_9504_F8BC04C10000__INCLUDED_)
#define AFX_TTY_H__07B39577_ABAC_11D2_9504_F8BC04C10000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// const
// Flow control flags
#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04
// ascii definitions
#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
// terminal size
#define MAXBLOCK 3 //80
// const define
#define DEFAULTCOMPORT 3
#define DEFAULTBAUDRATE 1200
// data structures
typedef struct tagTTYINFO
{
HANDLE idComDev ;
BYTE bCOMPort ; // current COM port int
DWORD dwCOMBaudrate; // current COM baudrate
//BYTE bByteSize,bFlowCtrl, bParity, bStopBits ;
BOOL fConnectedToOther;
BYTE Queue[5000];
WORD HeadPtr, TailPtr;
BOOL fConnected, fXonXoff, fLocalEcho, fNewLine, fAutoWrap,
fUseCNReceive, fDisplayErrors;
BYTE bByteSize, bFlowCtrl, bParity, bStopBits ;
DWORD dwBaudRate ;
HANDLE hWatchThread, hWatchEvent,hLPTWatchThread ;
DWORD dwThreadID ;
OVERLAPPED osWrite, osRead ;
} TTYINFO, NEAR *NPTTYINFO ;
// define COM macro
#define COMDEV( x ) (x -> idComDev)
#define PORT( x ) (x -> bCOMPort)
#define BAUDRATE( x ) (x -> dwCOMBaudrate)
#define CONNECTEDTO( x ) (x -> fConnectedToOther)
#define CONNECTED( x ) (x -> fConnected)
#define XONXOFF( x ) (x -> fXonXoff)
#define LOCALECHO( x ) (x -> fLocalEcho)
#define NEWLINE( x ) (x -> fNewLine)
#define AUTOWRAP( x ) (x -> fAutoWrap)
#define BYTESIZE( x ) (x -> bByteSize)
#define FLOWCTRL( x ) (x -> bFlowCtrl)
#define PARITY( x ) (x -> bParity)
#define STOPBITS( x ) (x -> bStopBits)
#define HTHREAD( x ) (x -> hWatchThread)
#define THREADID( x ) (x -> dwThreadID)
#define WRITE_OS( x ) (x -> osWrite)
#define READ_OS( x ) (x -> osRead)
class CTTY
{
public:
CTTY();
virtual ~CTTY();
LRESULT NEAR CreateTTYInfo( void ) ;
BOOL NEAR OpenConnection( void ) ;
BOOL NEAR SetupConnection( void ) ;
BOOL NEAR DestroyTTYInfo( void ) ;
BOOL NEAR CloseConnection( void ) ;
public:
NPTTYINFO npTTYInfo ;
DWORD ParityTable[5];
DWORD StopBitsTable[3];
DWORD BaudTable[13];
DWORD SelectedBaudRate;
int ComPort;
};
//并口读操作函数
int fnEppRoutine(int port, BYTE * pbResult, int number);
BOOL OpenLPTConnection();
//串口读(ReadCommBlock)写(WriteCommBlock)操作函数
int NEAR ReadCommBlock( NPTTYINFO npTTYInfo, LPSTR lpszBlock, int nMaxLength );
BOOL NEAR WriteCommBlock( NPTTYINFO npTTYInfo, BYTE *lpByte , DWORD dwBytesToWrite, DWORD *dwBytesWritten);
BOOL NEAR WriteLPTBlock( NPTTYINFO npTTYInfo, BYTE *lpByte , DWORD dwBytesToWrite, DWORD *dwBytesWritten );
int NEAR ReadLPTBlock( NPTTYINFO npTTYInfo, LPSTR lpszBlock, int nMaxLength );
//extern CTTY MyTTY;
#endif // !defined(AFX_TTY_H__07B39577_ABAC_11D2_9504_F8BC04C10000__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -