本文整理汇总了C++中EscapeCommFunction函数的典型用法代码示例。如果您正苦于以下问题:C++ EscapeCommFunction函数的具体用法?C++ EscapeCommFunction怎么用?C++ EscapeCommFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EscapeCommFunction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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) );
}
示例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 ;
}
示例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
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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");
}
示例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()