我想用CH340做一个简单的工具,单片机和上位机通信,单片机除了和CH340通信,还可以传递出两个低电平信号,我想用CH340得到这两个低电平信号,但不知道上位机如何检测到传递过来的信号,应该用到的是CTS#和DSR#,请指导下在上位机程序中如何检测CTS#和DSR#变为低电平!
到参看一下windows API 函数 GetCommModemStatus 的使用。
Syntax
BOOL WINAPI GetCommModemStatus( __in HANDLE hFile, __out LPDWORD lpModemStat);
Parameters
hFile
A handle to the communications device. The CreateFile function returns this handle.
lpModemStat
A pointer to a variable that receives the current state of the modem control-register values. This parameter can be one or more of the following values.
ValueMeaningMS_CTS_ON
0x0010The CTS (clear-to-send) signal is on.
MS_DSR_ON
0x0020The DSR (data-set-ready) signal is on.
MS_RING_ON
0x0040The ring indicator signal is on.
MS_RLSD_ON
0x0080The RLSD (receive-line-signal-detect) signal is on.