當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetCommModemStatus函數代碼示例

本文整理匯總了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;
}
開發者ID:inspirer,項目名稱:history,代碼行數:60,代碼來源:comm.cpp

示例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;
}
開發者ID:dulton,項目名稱:53_hero,代碼行數:51,代碼來源:win_qextserialport.cpp

示例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);
}
開發者ID:KurtWoloch,項目名稱:fbc,代碼行數:16,代碼來源:io_serial.c

示例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);
}
開發者ID:Beastmaster,項目名稱:AIGS,代碼行數:7,代碼來源:ndicapi_serial.c

示例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);
		}
	}
}
開發者ID:yingzhang536,項目名稱:mrayy-Game-Engine,代碼行數:29,代碼來源:Tserial_event.cpp

示例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;
}
開發者ID:LeftRadio,項目名稱:esp8266-firmware,代碼行數:35,代碼來源:serialport_win.cpp

示例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;
}
開發者ID:yuriiq,項目名稱:GetStarMoskit,代碼行數:31,代碼來源:SerialGate.cpp

示例8: getModemSignals

COMPort::MSPack COMPort::getModemSignals() const {
	MSPack aPack;

	if ( !GetCommModemStatus ( (HANDLE)portHandle, (LPDWORD)&aPack ) ) {
	}
	return aPack;
}
開發者ID:dreamsxin,項目名稱:ultimatepp,代碼行數:7,代碼來源:Comport.cpp

示例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;
}
開發者ID:TC01,項目名稱:tilibs,代碼行數:46,代碼來源:link_gry2.c

示例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);
}
開發者ID:kelayamatoz,項目名稱:DC8094A,代碼行數:9,代碼來源:rs232.c

示例11: IsCTSEnabled

int IsCTSEnabled()
{
  int status;

  GetCommModemStatus(Cport, (LPDWORD)((void *)&status));

  if(status&MS_CTS_ON) return(1);
  else return(0);
}
開發者ID:lexx-polarnet-pl,項目名稱:AquaPi,代碼行數:9,代碼來源:rs232.c

示例12: comGetModemStatus

int comGetModemStatus(COM_HANDLE handle)
{
	DWORD status=0;
	
	if(GetCommModemStatus(handle, &status))
		return status;
	else
		return COM_ERROR;
}
開發者ID:donfanning,項目名稱:syncterm,代碼行數:9,代碼來源:comio_win32.c

示例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 */
開發者ID:bochaqos,項目名稱:tol,代碼行數:27,代碼來源:NT_Uart.c

示例14: ASSERT

void CSerialPort::GetModemStatus(DWORD& dwModemStatus)
{
  ASSERT(IsOpen());

  if (!GetCommModemStatus(m_hComm, &dwModemStatus))
  {
    TRACE(_T("Failed in call to GetCommModemStatus\n"));
    AfxThrowSerialException();
  }
}
開發者ID:freegroup,項目名稱:DigitalSimulator,代碼行數:10,代碼來源:SerialPort.cpp

示例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;
}
開發者ID:bearxiong99,項目名稱:new_swamm,代碼行數:11,代碼來源:_WinSerialServer.cpp


注:本文中的GetCommModemStatus函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。