我想用CH340做一個(gè)簡(jiǎn)單的工具,單片機(jī)和上位機(jī)通信,單片機(jī)除了和CH340通信,還可以傳遞出兩個(gè)低電平信號(hào),我想用CH340得到這兩個(gè)低電平信號(hào),但不知道上位機(jī)如何檢測(cè)到傳遞過(guò)來(lái)的信號(hào),應(yīng)該用到的是CTS#和DSR#,請(qǐng)指導(dǎo)下在上位機(jī)程序中如何檢測(cè)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.