8
87150
Unregistered / Unconfirmed
GUEST, unregistred user!
请教
以下是用COMM API 截获的
--------------------------------------------------------------
IRP_MJ_CREATE Options: Open
IOCTL_SERIAL_SET_DTR
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_WAIT_MASK Mask: RXCHAR RLSD ERR
IOCTL_SERIAL_GET_MODEMSTATUS
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_GET_MODEMSTATUS
IOCTL_SERIAL_GET_MODEMSTATUS
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_QUEUE_SIZE InSize: 4096 OutSize: 4096
IOCTL_SERIAL_PURGE Purge: TXABORT RXABORT TXCLEAR RXCLEAR
IOCTL_SERIAL_SET_TIMEOUTS RI:-1 RM:0 RC:1000 WM:0 WC:0
IOCTL_SERIAL_GET_BAUD_RATE
IOCTL_SERIAL_GET_LINE_CONTROL
IOCTL_SERIAL_GET_CHARS
IOCTL_SERIAL_GET_HANDFLOW
IOCTL_SERIAL_GET_BAUD_RATE
IOCTL_SERIAL_GET_LINE_CONTROL
IOCTL_SERIAL_GET_CHARS
IOCTL_SERIAL_GET_HANDFLOW
======================================================
IOCTL_SERIAL_SET_BAUD_RATE Rate: 16457
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_DTR
======================================================
IOCTL_SERIAL_SET_LINE_CONTROL StopBits: ERROR Parity: ODD WordLength: 8
IOCTL_SERIAL_SET_CHAR EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
IOCTL_SERIAL_SET_HANDFLOW Shake:1 Replace:0 XonLimit:2048 XoffLimit:512
-----------------------------------------------------------------------------
以上的设置用MSCOMM,SPCOMM,COMPORT都服务实现,我用以下代码
hCommFile := CreateFile
( PChar(s),GENERIC_READ+GENERIC_WRITE,
0,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if(hCommFile = INVALID_HANDLE_VALUE)or
(GetFileType( hCommFile )<>FILE_TYPE_CHAR)then exit;
EscapeCommFunction(hCommFile,SETDTR);
EscapeCommFunction(hCommFile,CLRRTS);
fdwEvtMask:=EV_RXCHAR+EV_ERR+EV_RLSD;
setcommmask(hcommfile,fdwEvtMask);
GetCommModemStatus(hcommfile,ModemStat);
EscapeCommFunction(hCommFile,SETRTS);
GetCommModemStatus(hcommfile,ModemStat);
EscapeCommFunction(hCommFile,CLRRTS);
SetupComm(hCommFile,4096,4096);
PurgeComm(hCommFile,PURGE_TXABORT+PURGE_RXABORT+PURGE_TXCLEAR+PURGE_RXCLEAR);
commtimeouts.ReadIntervalTimeout :=4294967295; //setup commtimeout
commtimeouts.ReadTotalTimeoutMultiplier :=0;
commtimeouts.ReadTotalTimeoutConstant :=1000;
commtimeouts.WriteTotalTimeoutMultiplier :=0;
commtimeouts.WriteTotalTimeoutConstant :=0;
SetCommTimeouts(hCommFile,commtimeouts);
fillchar( dcb, sizeof(dcb), 0 ); //setup dcb struct
GetCommState(hCommFile,dcb);
// dcbstr:='16457, O, 8, 2';
// BuildCommDCBW(dcbstr,dcb);
// SetCommState(hCommFile,dcb);
dcb.DCBLength :=sizeof(dcb);
dcb.BaudRate:=16457;
dcb.Flags:=$9C140003;
dcb.XonLim:=2048;
dcb.XoffLim:=512;
dcb.bytesize:=8;
dcb.Parity:=ODDPARITY;//2;
dcb.StopBits:=TWOSTOPBITS;//0;
dcb.XonChar:=#11;
dcb.XoffChar:=#13;
SetCommState(hCommFile,dcb);
出来的结果中
======================================================
IOCTL_SERIAL_SET_BAUD_RATE Rate: 16457
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_CLR_DTR
======================================================
请教如何实现上述COMM API设置结果?
以下是用COMM API 截获的
--------------------------------------------------------------
IRP_MJ_CREATE Options: Open
IOCTL_SERIAL_SET_DTR
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_WAIT_MASK Mask: RXCHAR RLSD ERR
IOCTL_SERIAL_GET_MODEMSTATUS
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_GET_MODEMSTATUS
IOCTL_SERIAL_GET_MODEMSTATUS
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_QUEUE_SIZE InSize: 4096 OutSize: 4096
IOCTL_SERIAL_PURGE Purge: TXABORT RXABORT TXCLEAR RXCLEAR
IOCTL_SERIAL_SET_TIMEOUTS RI:-1 RM:0 RC:1000 WM:0 WC:0
IOCTL_SERIAL_GET_BAUD_RATE
IOCTL_SERIAL_GET_LINE_CONTROL
IOCTL_SERIAL_GET_CHARS
IOCTL_SERIAL_GET_HANDFLOW
IOCTL_SERIAL_GET_BAUD_RATE
IOCTL_SERIAL_GET_LINE_CONTROL
IOCTL_SERIAL_GET_CHARS
IOCTL_SERIAL_GET_HANDFLOW
======================================================
IOCTL_SERIAL_SET_BAUD_RATE Rate: 16457
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_DTR
======================================================
IOCTL_SERIAL_SET_LINE_CONTROL StopBits: ERROR Parity: ODD WordLength: 8
IOCTL_SERIAL_SET_CHAR EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
IOCTL_SERIAL_SET_HANDFLOW Shake:1 Replace:0 XonLimit:2048 XoffLimit:512
-----------------------------------------------------------------------------
以上的设置用MSCOMM,SPCOMM,COMPORT都服务实现,我用以下代码
hCommFile := CreateFile
( PChar(s),GENERIC_READ+GENERIC_WRITE,
0,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if(hCommFile = INVALID_HANDLE_VALUE)or
(GetFileType( hCommFile )<>FILE_TYPE_CHAR)then exit;
EscapeCommFunction(hCommFile,SETDTR);
EscapeCommFunction(hCommFile,CLRRTS);
fdwEvtMask:=EV_RXCHAR+EV_ERR+EV_RLSD;
setcommmask(hcommfile,fdwEvtMask);
GetCommModemStatus(hcommfile,ModemStat);
EscapeCommFunction(hCommFile,SETRTS);
GetCommModemStatus(hcommfile,ModemStat);
EscapeCommFunction(hCommFile,CLRRTS);
SetupComm(hCommFile,4096,4096);
PurgeComm(hCommFile,PURGE_TXABORT+PURGE_RXABORT+PURGE_TXCLEAR+PURGE_RXCLEAR);
commtimeouts.ReadIntervalTimeout :=4294967295; //setup commtimeout
commtimeouts.ReadTotalTimeoutMultiplier :=0;
commtimeouts.ReadTotalTimeoutConstant :=1000;
commtimeouts.WriteTotalTimeoutMultiplier :=0;
commtimeouts.WriteTotalTimeoutConstant :=0;
SetCommTimeouts(hCommFile,commtimeouts);
fillchar( dcb, sizeof(dcb), 0 ); //setup dcb struct
GetCommState(hCommFile,dcb);
// dcbstr:='16457, O, 8, 2';
// BuildCommDCBW(dcbstr,dcb);
// SetCommState(hCommFile,dcb);
dcb.DCBLength :=sizeof(dcb);
dcb.BaudRate:=16457;
dcb.Flags:=$9C140003;
dcb.XonLim:=2048;
dcb.XoffLim:=512;
dcb.bytesize:=8;
dcb.Parity:=ODDPARITY;//2;
dcb.StopBits:=TWOSTOPBITS;//0;
dcb.XonChar:=#11;
dcb.XoffChar:=#13;
SetCommState(hCommFile,dcb);
出来的结果中
======================================================
IOCTL_SERIAL_SET_BAUD_RATE Rate: 16457
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_CLR_DTR
======================================================
请教如何实现上述COMM API设置结果?