我想用CH340做一個簡單的工具,單片機和上位機通信,單片機除了和CH340通信,還可以傳遞出兩個低電平信號,我想用CH340得到這兩個低電平信號,但不知道上位機如何檢測到傳遞過來的信號,應該用到的是CTS#和DSR#,請指導下在上位機程序中如何檢測CTS#和DSR#變?yōu)榈碗娖剑?/p>
到參看一下windows API 函數(shù) 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.