• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetCommModemStatus函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetCommModemStatus函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCommModemStatus函数的具体用法?C++ GetCommModemStatus怎么用?C++ GetCommModemStatus使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetCommModemStatus函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: GetDSR

BOOL CSerialPort::GetDSR()
{
  DWORD result =0;
  if (!GetCommModemStatus(m_hComm, &result))
  {
    TRACE(_T("Failed in call to EscapeCommFunction\n"));
    AfxThrowSerialException();
  }

  return result&MS_DSR_ON?1:0;
}
开发者ID:freegroup,项目名称:DigitalSimulator,代码行数:11,代码来源:SerialPort.cpp


示例17: SerialPort_getLineStatus

static int SerialPort_getLineStatus(GORILLA_METHOD_PARAMETERS) {
    HANDLE win32Handle;
    int status;
    
    win32Handle = SerialPort_property__win32Handle_entity(GORILLA_METHOD_PARAM_PASSTHRU);
    if (GetCommModemStatus(win32Handle, (LPDWORD)&status) == FALSE) {
        zend_throw_exception(NULL, "failed to get line status", 641 TSRMLS_CC);
        return 0;
    }
    
    return status;
}
开发者ID:AcamTech,项目名称:phpmake_serialport,代码行数:12,代码来源:GorillaWin32.c


示例18: put

serial_raw::serial_raw(const char *devname)
{
#ifdef WIN32
  char portstr[MAX_PATH];
#ifdef WIN32_RECEIVE_RAW
  DWORD threadID;
#endif
#endif

  put ("SERR");
  settype (SERRLOG);
#ifdef WIN32
  memset(&dcb, 0, sizeof(DCB));
  dcb.DCBlength = sizeof(DCB);
  dcb.fBinary = 1;
  dcb.fDtrControl = DTR_CONTROL_ENABLE;
  dcb.fRtsControl = RTS_CONTROL_ENABLE;
  dcb.Parity = NOPARITY;
  dcb.ByteSize = 8;
  dcb.StopBits = ONESTOPBIT;
  dcb.BaudRate = CBR_115200;
  DCBchanged = FALSE;
  if (lstrlen(devname) > 0) {
    wsprintf(portstr, "\\\\.\\%s", devname);
    hCOM = CreateFile(portstr, GENERIC_READ|GENERIC_WRITE, 0, NULL,
                      OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
    if (hCOM != INVALID_HANDLE_VALUE) {
      present = 1;
      GetCommModemStatus(hCOM, &MSR_value);
      SetupComm(hCOM, 8192, 2048);
      PurgeComm(hCOM, PURGE_TXABORT | PURGE_RXABORT |
                PURGE_TXCLEAR | PURGE_RXCLEAR);
#ifdef WIN32_RECEIVE_RAW
      SetCommMask(hCOM, EV_BREAK | EV_CTS | EV_DSR | EV_ERR | EV_RING | EV_RLSD | EV_RXCHAR);
      memset(&rx_ovl, 0, sizeof(OVERLAPPED));
      rx_ovl.hEvent = CreateEvent(NULL,TRUE,FALSE,"receive");
      hRawSerialThread = CreateThread(NULL, 0, RawSerialThread, this, 0, &threadID);
#endif
    } else {
      present = 0;
      BX_ERROR(("Raw device '%s' not present", devname));
    }
  } else {
    present = 0;
  }
#else
  present = 0;
#endif
  set_modem_control(0x00);
  set_break(0);
  rxdata_count = 0;
}
开发者ID:hack477,项目名称:bochs4wii,代码行数:52,代码来源:serial_raw.cpp


示例19: EIO_Get

void EIO_Get(uv_work_t* req) {
  GetBaton* data = static_cast<GetBaton*>(req->data);

  DWORD bits = 0;
  if (!GetCommModemStatus((HANDLE)data->fd, &bits)) {
    ErrorCodeToString("Getting control settings on COM port (GetCommModemStatus)", GetLastError(), data->errorString);
    return;
  }

  data->cts = bits & MS_CTS_ON;
  data->dsr = bits & MS_DSR_ON;
  data->dcd = bits & MS_RLSD_ON;
}
开发者ID:Zensey,项目名称:node-serialport,代码行数:13,代码来源:serialport_win.cpp


示例20: return

AREXPORT bool ArSerialConnection::getRing(void)
{
  DWORD modemStat;
  if (GetCommModemStatus(myPort, &modemStat))
  {
    return (bool) (modemStat & MS_RING_ON);
  }
  else
  {
    fprintf(stderr, "problem with GetCommModemStatus\n");
    return false;
  }
}
开发者ID:3660628,项目名称:mrpt,代码行数:13,代码来源:ArSerialConnection_WIN.cpp



注:本文中的GetCommModemStatus函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetCommState函数代码示例发布时间:2022-05-30
下一篇:
C++ GetCommLineStatus函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap