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

C++ EscapeCommFunction函数代码示例

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

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



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

示例1: EscapeCommFunction

int RS232Interface::SetSerialRTSDTR(int state)
{
	int result = E2ERR_OPENFAILED;

#ifdef	_WINDOWS
	if ( hCom != INVALID_HANDLE_VALUE )
	{
		if (state)
		{
			EscapeCommFunction(hCom, SETRTS);
			EscapeCommFunction(hCom, SETDTR);
		}
		else
		{
			EscapeCommFunction(hCom, CLRRTS);
			EscapeCommFunction(hCom, CLRDTR);
		}

		result = OK;
	}
#else
#ifdef	_LINUX_
	int flags; 
	ioctl(fd,TIOCMGET, &flags); 
	if (state)
	{
		flags |= (TIOCM_RTS|TIOCM_DTR); 
	}
	else
	{
		flags &= ~(TIOCM_RTS|TIOCM_DTR); 
	}
	result = ioctl(fd,TIOCMSET, &flags); 
#endif
#endif

	return result;
}
开发者ID:bieli,项目名称:avr_jokes,代码行数:38,代码来源:rs232int.cpp


示例2: SetCommMask

void CSerialPort::Close()
{
	if (m_hTTY != INVALID_HANDLE_VALUE)
	{
		// disable event notification and wait for thread to halt
		SetCommMask( m_hTTY, 0 );
		// drop DTR
		EscapeCommFunction( m_hTTY, CLRDTR);	//	 	SETRTS	 
		// purge  reads/writes 
		PurgeComm( m_hTTY, PURGE_TXABORT | PURGE_RXABORT);
		CloseHandle( m_hTTY );
		m_hTTY = INVALID_HANDLE_VALUE;
	}
}
开发者ID:benoitk,项目名称:cristalqt_win,代码行数:14,代码来源:serial.cpp


示例3: setRtsIO

VALUE setRtsIO(VALUE self, VALUE rb_int)
{
    {
        Check_Type(rb_int, T_FIXNUM);
    }

    int boolean = FIX2INT(rb_int);

    PortDescriptor *port = NULL;

    Data_Get_Struct(self, PortDescriptor, port);

    return INT2FIX( EscapeCommFunction(port->fd, boolean == 1 ? SETRTS : CLRRTS) );
}
开发者ID:Ingenico,项目名称:ruby-rs-232,代码行数:14,代码来源:port.c


示例4: Cm17aStart

/*
 * Open the given com port and reset the attached cm17a
 */
int Cm17aStart(int comPortNumber)
{
  char comPortString[80] ;

  sprintf(comPortString, "\\\\.\\COM%d", comPortNumber) ;

  thePort = CreateFile(comPortString, GENERIC_READ | GENERIC_WRITE,
      0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL) ;

  if (thePort != INVALID_HANDLE_VALUE)
  {
    /* Reset the device */
    EscapeCommFunction(thePort, CLRDTR) ;
    EscapeCommFunction(thePort, CLRRTS) ;
    Sleep(DELAY) ;
    EscapeCommFunction(thePort, SETDTR) ;
    EscapeCommFunction(thePort, SETRTS) ;
    Sleep(DELAY) ;

    return 1 ;
  }
  else
    return 0 ;
}
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:27,代码来源:cm17a.c


示例5: EscapeCommFunction

void SerialPort::clearRTS()
{
    if (!isOpen())
        return;
#ifdef __WIN32__
    EscapeCommFunction(handle, CLRRTS);
#endif
#ifdef __gnu_linux__
    int bit = TIOCM_RTS;
    ioctl(handle, TIOCMBIC, &bit);
#endif
#if defined(__APPLE__) && defined(__MACH__)
    ioctl(handle, TIOCM_RTS);
#endif
}
开发者ID:HenriVesala,项目名称:EmptyEpsilon,代码行数:15,代码来源:serialDriver.cpp


示例6: OpenComm

int XTTY::Connect(BOOL fConnect)
{
	if (fConnect) {		// オンラインにする
		if (m_fConnect)		// 既にオンライン?
			return 0;	// 何もせずに終わる

		m_idComDev = OpenComm("COM2", 1024, 128);
		if (m_idComDev < 0) {	// オープンに失敗?
			OpenComm_Error(m_idComDev);
			return -1;
		}

		DCB dcb;
		GetCommState(m_idComDev, &dcb);
		
		dcb.BaudRate = 57600;
		dcb.ByteSize = 8;
		dcb.Parity = NOPARITY;
		dcb.StopBits = ONESTOPBIT;

		SetCommState(&dcb);
		GetCommState(m_idComDev, &dcb);
		EnableCommNotification(m_idComDev, m_hwnd, 80, -1);
		EscapeCommFunction(m_idComDev, SETDTR);
		m_fConnect = TRUE;
	} else {		// オフラインにする
		if (!m_fConnect)	// 既にオフライン?
			return 0;	// 何もせずに終わる

		EscapeCommFunction(m_idComDev, CLRDTR);
		CloseComm(m_idComDev);
		m_fConnect = FALSE;
	}

	return 0;
}
开发者ID:willmomo,项目名称:ry2kojima,代码行数:36,代码来源:tty.cpp


示例7: os_com_close

void os_com_close() { 

    // reset error byte

    if (!EscapeCommFunction((HANDLE) hSerial, CLRDTR)) {

    }
    if (!PurgeComm((HANDLE) hSerial, PURGE_RXABORT | PURGE_RXCLEAR |
                       PURGE_TXABORT | PURGE_TXCLEAR)) {
    }

    // device handle
    CloseHandle((HANDLE) hSerial);
	
}
开发者ID:ShawnOfMisfit,项目名称:ambarella,代码行数:15,代码来源:ar_drv_uart.c


示例8: 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:abbrev,项目名称:tilp-libticables,代码行数:36,代码来源:link_gry2.c


示例9: CloseCOM

//---------------------------------------------------------------------------
// Closes the connection to the port.
//
// 'portnum'  - number 0 to MAX_PORTNUM-1.  This number was provided to
//              OpenCOM to indicate the port number.
//
void CloseCOM(int portnum)
{
   // disable event notification and wait for thread
   // to halt
   SetCommMask(ComID[portnum], 0);

   // drop DTR
   EscapeCommFunction(ComID[portnum], CLRDTR);

   // purge any outstanding reads/writes and close device handle
   PurgeComm(ComID[portnum], PURGE_TXABORT | PURGE_RXABORT |
                    PURGE_TXCLEAR | PURGE_RXCLEAR );
   CloseHandle(ComID[portnum]);
   ComID[portnum] = 0;
} 
开发者ID:svenKautlenbach,项目名称:SmartRF-SimpliciTI-Chronos-PC-suite,代码行数:21,代码来源:BM_Driver.cpp


示例10: SetCommMask

BOOL SerialCommunicationThread::CloseSerialPort(void)
{
	if (COMFile != NULL)
	{
		//禁止串行端口所有事件
		SetCommMask(COMFile, 0);
		//清除数据终端就绪信号
		EscapeCommFunction(COMFile, CLRDTR);
		//丢弃通信资源的输出或输入缓冲区字符并终止在通信资源上挂起的读、写操操作
		PurgeComm(COMFile, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR);
		CloseHandle(COMFile);
	}
	COMFile = NULL;

	return TRUE;
}
开发者ID:bigtruck,项目名称:BookLEDDemo,代码行数:16,代码来源:SerialCommunicationThread.cpp


示例11: COM_Signal

BOOL    COM_Signal( int item, DWORD signal )
{
BOOL    ok=TRUE;

    if( !EscapeCommFunction(COM_Item[item].comH,signal) )
    {
        COM_errorf("COM_Signal(COM%d,%s) EscapeCommFunction() Failed (%s).\n",COM_Item[item].comX,STR_TextCode(COM_SignalText,signal),COM_Error());
        ok = FALSE;
    }
    else
    {
        COM_debugf("COM_Signal(COM%d,%s) OK.\n",COM_Item[item].comX,STR_TextCode(COM_SignalText,signal));
    }

    return(ok);
}
开发者ID:anosnowhong,项目名称:phantom,代码行数:16,代码来源:com.cpp


示例12: sbgSetEscapeComm

/*!
 *	Defines our serial DTR and RTS pins states.
 *	\param[in]	handle				Our serial communication handle.
 *	\param[in]	function			One of the SbgEscapeComm enum function.
 *	\return							SBG_NO_ERROR if the pin state has been defined.
 */
SbgErrorCode sbgSetEscapeComm(SbgDeviceHandle handle, SbgEscapeComm function)
{
	HANDLE pSerialDevice = (HANDLE)handle;
	uint32 escapeCommFunction;

	//
	// Check if we have a valid serial connexion
	//
	if (handle != SBG_INVALID_DEVICE_HANDLE)
	{
		//
		// Translate our sbgCom espace function into our windows one
		//
		switch (function)
		{
		case SBG_SET_DTR:
			escapeCommFunction = SETDTR;
			break;
		case SBG_CLR_DTR:
			escapeCommFunction = CLRDTR;
			break;
		case SBG_SET_RTS:
			escapeCommFunction = SETRTS;
			break;
		case SBG_CLR_RTS:
		default:
			escapeCommFunction = CLRRTS;
			break;
		}

		//
		// Define our espace comm function
		//
		if (EscapeCommFunction(pSerialDevice, escapeCommFunction))
		{
			return SBG_NO_ERROR;
		}
		else
		{
			return SBG_ERROR;
		}
	}
	else
	{
		return SBG_NULL_POINTER;
	}
}
开发者ID:konanrobot,项目名称:SBG_IG_500N_G4A2P1-B,代码行数:53,代码来源:comSerialWin.c


示例13: closeserial

char closeserial(portstream_fd portstream)
{   if (portstream != NULL) {                         
   		// disable event notification
   		SetCommMask( portstream, 0 ) ;
   	    // drop DTR
   		EscapeCommFunction( portstream, CLRDTR ) ;	 
   		// purge any outstanding reads/writes and close device handle
        PurgeComm( portstream, PURGE_TXABORT | PURGE_RXABORT | 
			                   PURGE_TXCLEAR | PURGE_RXCLEAR );
		// close the device   
		err = CloseHandle( portstream ) ;
        portstream = (HANDLE) -1;                
		if (err < 0)
			return -1;
	 }
     return 0;
}
开发者ID:brahayam,项目名称:usc-arm-calibration,代码行数:17,代码来源:w32seria.c


示例14: printf

void Serial_Port::close_serial()
{
	printf("CLOSE SERIAL PORT\n");

	// Enable all events in serial port FALSE 
    SetCommMask(hComm, 0) ;

    EscapeCommFunction( hComm, CLRDTR ) ;
 
    PurgeComm( hComm, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR ) ;
    CloseHandle( hComm );
    hComm = NULL;
	
	status = false;

	printf("\n");
}
开发者ID:DjangoBUAA,项目名称:ReadWrite_from_PIXHAWK,代码行数:17,代码来源:my_serial.cpp


示例15: CloseConnection

static BOOL CloseConnection(LPCOMMINFO hCom)
{

    if (NULL == hCom)
      return (FALSE);

    // drop DTR
    EscapeCommFunction(hCom->hComPort, CLRDTR);

    // purge any outstanding reads/writes and close device handle
    PurgeComm(hCom->hComPort, PURGE_TXABORT | PURGE_RXABORT |
                            PURGE_TXCLEAR | PURGE_RXCLEAR);

    // close handle
    CloseHandle(hCom->hComPort);

    return (TRUE);

} // end of CloseConnection()
开发者ID:tdgincjp,项目名称:FD-T303,代码行数:19,代码来源:RawCom.c


示例16: EscapeCommFunction

int wxSerialPort::ChangeLineState(wxSerialLineState flags)
{
#if ( 1 )
    BOOL ok = false;
    if(flags & wxSERIAL_LINESTATE_DTR) {
	   if(m_rtsdtr_state & wxSERIAL_LINESTATE_DTR) {
		  ok = EscapeCommFunction(fd,CLRDTR);
	   }
	   else {
		  ok = EscapeCommFunction(fd,SETDTR);
	   }
	   m_rtsdtr_state ^= wxSERIAL_LINESTATE_DTR;
    }
    if(flags & wxSERIAL_LINESTATE_RTS) {
	   if(m_rtsdtr_state & wxSERIAL_LINESTATE_RTS) {
		  ok = EscapeCommFunction(fd,CLRRTS);
	   }
	   else {
		  ok = EscapeCommFunction(fd,SETRTS);
	   }
	   m_rtsdtr_state ^= wxSERIAL_LINESTATE_RTS;
    }
    if(!ok) return -1;
    return 0;
#else
    BOOL ok = false;
    if(flags & wxSERIAL_LINESTATE_DTR) 
	   ok = EscapeCommFunction(fd,SETDTR);
    else 
	   ok = EscapeCommFunction(fd,CLRDTR);
    if(flags & wxSERIAL_LINESTATE_RTS) 
	   ok = EscapeCommFunction(fd,SETRTS);
    else 
	   ok = EscapeCommFunction(fd,CLRRTS);
    if(!ok) return -1;
    return 0;
#endif
};
开发者ID:JONA-GA,项目名称:connector_pi,代码行数:38,代码来源:serport.cpp


示例17: xbee_ser_set_rts

int xbee_ser_set_rts( xbee_serial_t *serial, int asserted)
{
	BOOL success;

	XBEE_SER_CHECK( serial);

	// disable flow control so our manual setting will stick
	xbee_ser_flowcontrol( serial, 0);

	success = EscapeCommFunction( serial->hCom, asserted ? SETRTS : CLRRTS);

	#ifdef XBEE_SERIAL_VERBOSE
		if (success == 0)
		{
			printf( "%s: EscapeCommFunction error %lu\n", __FUNCTION__,
					GetLastError());
		}
	#endif

	return success ? 0 : -EIO;
}
开发者ID:Charhong,项目名称:xbee_ansic_library,代码行数:21,代码来源:xbee_serial_win32.c


示例18: rs232_open

// Open the rs232 port
int rs232_open(char *_port, int baud_rate, int byte_size, int parity, int stop_bits)
{
    // Make sure another port is not already opened
    ASSERT(!handle_com);

    // Open the existing COMX file to open the port
  handle_com = CreateFile(
                      _port,
                      GENERIC_READ | GENERIC_WRITE,
                      0,
                      NULL,
                      OPEN_EXISTING,
                      FILE_ATTRIBUTE_SYSTEM,
                      NULL);

    // Make sure it is opened
    if (handle_com == INVALID_HANDLE_VALUE)
       return 0;

    // buffer size for emission and reception
  SetupComm(handle_com, RS232_RX_SIZE, RS232_TX_SIZE);

    // COM port configuration
  g_dcb.BaudRate = baud_rate;
  g_dcb.ByteSize = byte_size;
  g_dcb.Parity = parity;
  g_dcb.StopBits = stop_bits;
  if(!SetCommTimeouts(handle_com, &g_cto) || !SetCommState(handle_com, &g_dcb))
    {
      CloseHandle(handle_com);
      return 0;
    }

    // Flush buffers for emission and reception
    // DTR = 1
  PurgeComm(handle_com, PURGE_TXCLEAR | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_RXABORT);
  EscapeCommFunction(handle_com, SETDTR);

  return 1;
}
开发者ID:Mazetti,项目名称:asf,代码行数:41,代码来源:rs232.c


示例19: commDisconnect

// Disconnects port
void commDisconnect() {	// disconnects with serial port if connected
	HMENU hMenu;
	// Check if we're connected
	if (CONNECTED(TTYInfo)) {
		// Menu
		hMenu = GetMenu(ghWndMain);	// get the menu handle
		EnableMenuItem(hMenu, ID_FILE_CONNECT, MF_ENABLED); // enable the connect menu
		EnableMenuItem(hMenu, ID_FILE_DISCONNECT, MF_GRAYED | MF_DISABLED); // disable the connect menu
		EnableMenuItem(hMenu, ID_EDIT_SETTINGS, MF_ENABLED); // enable the TTY menu

		// lower DTR
		EscapeCommFunction(COMDEV(TTYInfo), CLRDTR);
		
		// Purge reads/writes, and I/O buffer
		PurgeComm(COMDEV(TTYInfo), PURGE_FLAGS);

		CloseHandle(COMDEV(TTYInfo)); // release the handle

		TTYInfo.fThreadDone = TRUE; // we want the thread to end
		CONNECTED(TTYInfo) = FALSE; // we are  now disconnected
	}
}
开发者ID:AshuDassanRepo,项目名称:bcit-courses,代码行数:23,代码来源:serial.c


示例20: SetCommMask

//////////////////////////////////////////////////////////////////////
// CloseConnection
// return:   0  always
//
int CAsyncPort::CloseConnection()
{
	// not connected
	m_isConnected = FALSE;

	// disable event notification and wait for thread to halt
	SetCommMask(m_hCommDev, 0);

	// block until thread has been halted
	while (m_dwThreadID != 0) {
		Sleep(10);
	}

	// drop DTR
	EscapeCommFunction(m_hCommDev, CLRDTR);

	// purge any outstanding reads/writes and close device handle
	PurgeComm (
		m_hCommDev,
		PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR
	);

	// close device
	CloseHandle(m_hCommDev);

	// reset instance variables
	m_hCommDev = INVALID_HANDLE_VALUE;
	memset(m_szCommDevName, 0, sizeof (m_szCommDevName));
	memset(& m_commConfig, 0, sizeof (COMMCONFIG));;
	m_commConfig.dwSize = sizeof (COMMCONFIG);
	memset(& m_commProp, 0, sizeof (COMMPROP));
	memset(& m_commTimeOuts, 0, sizeof (COMMTIMEOUTS));
	memset(m_baInBuf, 0, sizeof (m_baInBuf));
	m_nInBufIndex = 0;
	m_nInBufSize = 0;

	return (0);
}
开发者ID:atsidaev,项目名称:tcpcom32,代码行数:42,代码来源:AsyncPort.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Escher_IteratorNext函数代码示例发布时间:2022-05-30
下一篇:
C++ Escape函数代码示例发布时间: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