本文整理匯總了C++中GetCommModemStatus函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetCommModemStatus函數的具體用法?C++ GetCommModemStatus怎麽用?C++ GetCommModemStatus使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetCommModemStatus函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: mthread
unsigned int WINAPI mthread(void *t)
{
DWORD mask = 0;
register CComm *cm = (CComm *)t;
GetCommModemStatus(cm->h,&cm->mstat);
cm->status=1;
while(1){
if(!WaitCommEvent(cm->h,&mask,&cm->ovr) ) {
DWORD e=GetLastError();
if( e == ERROR_IO_PENDING ) {
DWORD r;
if( !GetOverlappedResult(cm->h,&cm->ovr,&r,TRUE) ) {
throw errors("GetOverlappedResult failed");
break;
}
} else {
throw errors("WaitCommEvent failed");
break;
}
}
if( mask == 0 ) {
break;
}
if( mask & EV_RXCHAR) {
char buf[10];
DWORD read;
do {
read = 0;
if( !ReadFile(cm->h,buf,sizeof(buf),&read,&cm->ovr) ) {
if( GetLastError() == ERROR_IO_PENDING ){
if( !GetOverlappedResult(cm->h,&cm->ovr,&read,TRUE)){
throw errors("GetOverlappedResult failed");
break;
}
} else {
throw errors("ReadFile failed");
break;
}
}
if(read){
cm->receive(buf,read);
}
} while(read);
}
if( mask & EV_TXEMPTY) {
SetEvent(cm->txenable);
}
if ( mask & (EV_RLSD|EV_DSR|EV_CTS)) {
GetCommModemStatus(cm->h,&cm->mstat);
cm->status=1;
}
mask = 0;
}
CloseHandle(cm->ovr.hEvent);
CloseHandle(cm->h);cm->h=NULL;
return 0;
}
示例2: LOCK_MUTEX
/*!
\fn ulong Win_QextSerialPort::lineStatus(void)
returns the line status as stored by the port function. This function will retrieve the states
of the following lines: DCD, CTS, DSR, and RI. On POSIX systems, the following additional lines
can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD. The value returned is an unsigned
long with specific bits indicating which lines are high. The following constants should be used
to examine the states of individual lines:
\verbatim
Mask Line
------ ----
LS_CTS CTS
LS_DSR DSR
LS_DCD DCD
LS_RI RI
\endverbatim
This function will return 0 if the port associated with the class is not currently open.
*/
ulong Win_QextSerialPort::lineStatus(void)
{
unsigned long status = 0;
unsigned long temp = 0;
LOCK_MUTEX();
if (isOpen())
{
GetCommModemStatus(m_WinHandle, &temp);
if (temp&MS_CTS_ON)
{
status|=LS_CTS;
}
if (temp&MS_DSR_ON)
{
status|=LS_DSR;
}
if (temp&MS_RING_ON)
{
status|=LS_RI;
}
if (temp&MS_RLSD_ON)
{
status|=LS_DCD;
}
}
UNLOCK_MUTEX();
return status;
}
示例3: fb_hSerialWaitSignal
static int fb_hSerialWaitSignal( HANDLE hDevice, DWORD dwMask, DWORD dwResult, DWORD dwTimeout )
{
DWORD dwStartTime = GET_MSEC_TIME();
DWORD dwModemStatus = 0;
if( !GetCommModemStatus( hDevice, &dwModemStatus ) )
return FALSE;
while ( ((GET_MSEC_TIME() - dwStartTime) <= dwTimeout)
&& ((dwModemStatus & dwMask)!=dwResult) )
{
if( !GetCommModemStatus( hDevice, &dwModemStatus ) )
return FALSE;
}
return ((dwModemStatus & dwMask)==dwResult);
}
示例4: ndiSerialCheckDSR
int ndiSerialCheckDSR(HANDLE serial_port)
{
DWORD bits;
/* get the bits to see if DSR is set (i.e. if device is connected) */
GetCommModemStatus(serial_port, &bits);
return ((bits & MS_DSR_ON) != 0);
}
示例5: GetCommModemStatus
void Tserial_event::OnEvent (unsigned long events)
{
unsigned long ModemStat;
GetCommModemStatus(serial_handle, &ModemStat);
if ((events & EV_RING)!=0)
{
if ((ModemStat & MS_RING_ON)!= 0)
{
if (manager!=0)
manager((uint32) this, SERIAL_RING);
}
}
if ((events & EV_RLSD)!=0)
{
if ((ModemStat & MS_RLSD_ON)!= 0)
{
if (manager!=0)
manager((uint32) this, SERIAL_CD_ON);
}
else
{
if (manager!=0)
manager((uint32) this, SERIAL_CD_OFF);
}
}
}
示例6: while
DWORD SerialPort::ThreadProc (LPVOID lpdwThreadParam ) {
SerialPort *port = (SerialPort *)lpdwThreadParam;
HANDLE hCOM = port->get_com();
DWORD read;
const int buffSize = 1024;
char buff[buffSize];
while (true) {
read = 0;
bool res = ReadFile(hCOM, buff, buffSize, &read,0);
if(!port->mTreadFlag)
break;
if(res) {
if(read > 0) {
port->mReadError = false;
buff[read]='\0';
SerialPortRecieved(port, buff, read);
port->mBytesRecivedSinceLastSend += read;
} else {
if(GetCommModemStatus(hCOM, &read)==0) {
if(port->mReadError == false)
SerialPortError(port, ERROR_READ_STRING);
port->mReadError = true;
} else {
port->mReadError = false;
}
port->sleep(100);
}
} else {
port->mReadError = true;
SerialPortError(port, ERROR_READ_STRING);
port->sleep(100);
}
}
return 0;
}
示例7: __declspec
extern "C" __declspec (dllexport) bool SerialGate::GetLine(IN_LINES_NAME ln)
{
if(!state)
return 0;
unsigned long ul = 0;
GetCommModemStatus(m_hFile, &ul);
if(ul == 0x10 && ln == CTS)
{
return true;
}
if(ul == 0x20 && ln == DSR)
{
return true;
}
if(ul == 0x40 && ln == RING)
{
return true;
}
if(ul == 0x80 && ln == RLSD)
{
return true;
}
return false;
}
示例8: getModemSignals
COMPort::MSPack COMPort::getModemSignals() const {
MSPack aPack;
if ( !GetCommModemStatus ( (HANDLE)portHandle, (LPDWORD)&aPack ) ) {
}
return aPack;
}
示例9: gry_probe
static int gry_probe(CableHandle *h)
{
DWORD status; //MS_CTS_ON or MS_DTR_ON
EscapeCommFunction(hCom, SETDTR);
EscapeCommFunction(hCom, SETRTS);
GetCommModemStatus(hCom, &status); // Get MCR values
if (status != 0x20)
{
return ERR_PROBE_FAILED;
}
EscapeCommFunction(hCom, SETDTR);
EscapeCommFunction(hCom, CLRRTS);
GetCommModemStatus(hCom, &status);
if (status != 0x20)
{
return ERR_PROBE_FAILED;
}
EscapeCommFunction(hCom, CLRDTR);
EscapeCommFunction(hCom, CLRRTS);
GetCommModemStatus(hCom, &status);
if (status != 0x00)
{
return ERR_PROBE_FAILED;
}
EscapeCommFunction(hCom, CLRDTR);
EscapeCommFunction(hCom, SETRTS);
GetCommModemStatus(hCom, &status);
if (status != 0x00)
{
return ERR_PROBE_FAILED;
}
EscapeCommFunction(hCom, SETDTR);
EscapeCommFunction(hCom, SETRTS);
GetCommModemStatus(hCom, &status);
if (status != 0x20)
{
return ERR_PROBE_FAILED;
}
return 0;
}
示例10: RS232_IsDSREnabled
int RS232_IsDSREnabled(int comport_number)
{
int status;
GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
if(status&MS_DSR_ON) return(1);
else return(0);
}
示例11: IsCTSEnabled
int IsCTSEnabled()
{
int status;
GetCommModemStatus(Cport, (LPDWORD)((void *)&status));
if(status&MS_CTS_ON) return(1);
else return(0);
}
示例12: comGetModemStatus
int comGetModemStatus(COM_HANDLE handle)
{
DWORD status=0;
if(GetCommModemStatus(handle, &status))
return status;
else
return COM_ERROR;
}
示例13: NumChann
/*------------------------------------------------------------------------------
FUNCTION NAME: Uart_CTSReady
DESCRIPTION: Checks CTS ready
PARAMETERS:
- INPUT:
- NumChann (int): Port to check
- OUTPUT:
RETURN: TRUE - CTS 1
FALSE - CTS 0
NOTES:
------------------------------------------------------------------------------*/
t_boolean Uart_CTSReady (int NumChann)
{
HANDLE hPort = GetPortHandle ( NumChann );
DWORD ModemStat;
GetCommModemStatus (hPort, &ModemStat);
return (t_boolean) (MS_CTS_ON & ModemStat);
} /* Uart_CTSReady */
示例14: ASSERT
void CSerialPort::GetModemStatus(DWORD& dwModemStatus)
{
ASSERT(IsOpen());
if (!GetCommModemStatus(m_hComm, &dwModemStatus))
{
TRACE(_T("Failed in call to GetCommModemStatus\n"));
AfxThrowSerialException();
}
}
示例15: XDEBUG
void CSerialServer::CheckModemStatus(BOOL bUpdateNow)
{
if (!GetCommModemStatus(m_hComPort, &m_dwModemStatus))
XDEBUG("GetCommModemStatus Error\r\n");
// Report status if bUpdateNow is true or status has changed
if (bUpdateNow || (m_dwModemStatus != m_dwOldModemStatus))
OnUpdateModemStatus(m_dwModemStatus);
m_dwOldModemStatus = m_dwModemStatus;
}