本文整理汇总了C++中setFlowControl函数的典型用法代码示例。如果您正苦于以下问题:C++ setFlowControl函数的具体用法?C++ setFlowControl怎么用?C++ setFlowControl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFlowControl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tcgetattr
bool QSerialPort::open(int block)
{
if( block== 1) portDesc = ::open(portName.toAscii(),O_RDWR);
else portDesc = ::open(portName.toAscii(),O_RDWR | O_NONBLOCK );
if(portDesc == -1)
{
return false;
}
portOpen = true;
tcgetattr(portDesc, &portConfig);
portConfig.c_cflag|=(CLOCAL | CREAD);
portConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
portConfig.c_iflag&=(~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR| IGNCR|ICRNL|IXON)); // (~(INPCK|IGNPAR|PARMRK|ISTRIP|IXANY));
portConfig.c_iflag&=~(ICRNL);
portConfig.c_oflag&=(~OPOST);
tcsetattr(portDesc, TCSANOW, &portConfig);
setBaudRate(settings.baudRate);
setDataBits(settings.dataBits);
setFlowControl(settings.flowControl);
setParity(settings.parity);
setStopBits(settings.stopBits);
setDtr();
setRts();
connect(&portFile, SIGNAL(readyRead()), this, SLOT(slotNotifierActivated()));
return true;
}
示例2: LOCK_MUTEX
/*!
\fn bool Posix_QextSerialPort::open(int=0)
Opens a serial port. Note that this function does not specify which device to open. If you need
to open a device by name, see Posix_QextSerialPort::open(const char*). This function has no
effect if the port associated with the class is already open. The port is also configured to the
current settings, as stored in the Settings structure.
*/
bool Posix_QextSerialPort::open(int) {
LOCK_MUTEX();
if (!portOpen) {
/*open the port*/
Posix_File->setName(portName);
if (Posix_File->open(IO_Async|IO_Raw|IO_ReadWrite)) {
portOpen=true;
}
/*configure port settings*/
tcgetattr(Posix_File->handle(), &Posix_CommConfig);
/*set up other port settings*/
Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|IXANY));
Posix_CommConfig.c_oflag&=(~OPOST);
Posix_CommConfig.c_cc[VMIN]=0;
Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
setBaudRate(Settings.BaudRate);
setDataBits(Settings.DataBits);
setStopBits(Settings.StopBits);
setParity(Settings.Parity);
setFlowControl(Settings.FlowControl);
setTimeout(Posix_Copy_Timeout.tv_sec, Posix_Copy_Timeout.tv_usec);
tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
}
UNLOCK_MUTEX();
return portOpen;
}
示例3: setEventNotification
/**
* Инициализация COM порта
*/
int FtdiDevices::Initialization() {
int state = 0;
if ( !openDSUSession() ) state = 1;
if ( !reset() ) state = 1;
if ( !setSpeed(115200) ) state = 1;
if ( !setDataCharacteristics() ) state = 1;
if ( !getModemStatus() ) state = 1;
setEventNotification();
setDtrRts();
purge();
if ( !setFlowControl() ) state = 1;
QString msg;
int type;
if ( state == 1 ) {
msg = "Не могу открыть устройство( COM порт A )!" ;
type = appLogger.ERROR_MSG_TYPE;
}
else {
msg = "Устройство открыто успешно( COM порт A )!";
type = appLogger.INFO_MSG_TYPE;
}
/* Запись в лог сообщения */
appLogger.sendDataToViewer( type, msg, appLogger.SYSTEM_LOGGER );
return state;
}
示例4: downloadFile
/* uploadFile() - uploads a file to a FTP server
*
* This function uploads a file to a FTP server
*
* Returns '1' on success and '0' if error
*/
uint8_t WaspGPRS::downloadFile(char* file, char* path, char* user, char* passw, char* ftp_server, uint8_t ftp_port)
{
char command[70];
long previous=0;
uint8_t answer=0;
char aux='"';
uint16_t index=0;
uint16_t i=0;
uint8_t end=0;
char* aux2;
uint8_t j=0;
uint8_t id=0;
if(!setFlowControl()) return 0;
if(!configureGPRS()) return 0;
// Connect to FTP Server
sprintf(command,"AT%s,%c%s%c,%c%s%c,%c%s%c,%u,1%c%c",AT_FTP_PARAM,aux,ftp_server,aux,aux,user,aux,aux,passw,aux,ftp_port,'\r','\n');
printString(command,PORT_USED);
previous=millis();
while( (!serialAvailable(PORT_USED)) && ((millis()-previous)<10000) );
delay(10);
answer=waitForData("+KFTPCFG: ",20,0,0);
if(answer!=1) return 0;
id=serialRead(PORT_USED);
if( !readDataFTP(file, path, id) ) return 0;
return 1;
}
示例5: sizeof
/*!
\fn bool Win_QextSerialPort::open(OpenMode mode)
Opens a serial port. Note that this function does not specify which device to open. If you need
to open a device by name, see Win_QextSerialPort::open(const char*). This function has no effect
if the port associated with the class is already open. The port is also configured to the current
settings, as stored in the Settings structure.
*/
bool Win_QextSerialPort::open(OpenMode mode) {
unsigned long confSize = sizeof(COMMCONFIG);
Win_CommConfig.dwSize = confSize;
DWORD dwFlagsAndAttributes = 0;
if (queryMode() == QextSerialBase::EventDriven)
dwFlagsAndAttributes += FILE_FLAG_OVERLAPPED;
LOCK_MUTEX();
if (mode == QIODevice::NotOpen)
return isOpen();
if (!isOpen()) {
/*open the port*/
Win_Handle=CreateFileA(port.toLatin1(), GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL);
if (Win_Handle!=INVALID_HANDLE_VALUE)
{
/*configure port settings*/
GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
GetCommState(Win_Handle, &(Win_CommConfig.dcb));
/*set up parameters*/
Win_CommConfig.dcb.fBinary=TRUE;
Win_CommConfig.dcb.fInX=FALSE;
Win_CommConfig.dcb.fOutX=FALSE;
Win_CommConfig.dcb.fAbortOnError=FALSE;
Win_CommConfig.dcb.fNull=FALSE;
setBaudRate(Settings.BaudRate);
setDataBits(Settings.DataBits);
setStopBits(Settings.StopBits);
setParity(Settings.Parity);
setFlowControl(Settings.FlowControl);
setTimeout(Settings.Timeout_Millisec);
SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
//init event driven approach
if (queryMode() == QextSerialBase::EventDriven) {
Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD;
Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
if (!SetCommMask( Win_Handle, EV_TXEMPTY | EV_RXCHAR | EV_DSR)) {
qWarning("Failed to set Comm Mask. Error code: %ld", GetLastError());
UNLOCK_MUTEX();
return false;
}
overlapThread->start();
}
QIODevice::open(mode);
}
} else {
UNLOCK_MUTEX();
return false;
}
UNLOCK_MUTEX();
return isOpen();
}
示例6: setBaudRate
/*! \brief SerialDevice::stopDevice Is the serial interface's implementation of setDefaults.
* Sets the serial devices to the default values. (Rate=9600, Parity=None, Flow=None, Data=8, Stop=1)
*/
void SerialDevice::setDefaults()
{
statusReady = false;
setBaudRate(9600);
setParity(0);
setFlowControl(0);
setDataBits(8);
setStopBits(1);
}
示例7: setBaudRate
/*!
\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
Constructs a port with default name and specified settings.
*/
Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) {
Win_Handle=INVALID_HANDLE_VALUE;
setBaudRate(settings.BaudRate);
setDataBits(settings.DataBits);
setStopBits(settings.StopBits);
setParity(settings.Parity);
setFlowControl(settings.FlowControl);
setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
}
示例8: setBaudRate
/*!
Sets the port settigns.
*/
void QextSerialPort::setPortSetting(const PortSettings& settings)
{
setBaudRate(settings.BaudRate);
setDataBits(settings.DataBits);
setParity(settings.Parity);
setStopBits(settings.StopBits);
setFlowControl(settings.FlowControl);
setTimeout(settings.Timeout_Millisec);
}
示例9: sizeof
/*!
Opens a serial port. Note that this function does not specify which device to open. If you need
to open a device by name, see QextSerialPort::open(const char*). This function has no effect
if the port associated with the class is already open. The port is also configured to the current
settings, as stored in the Settings structure.
*/
bool QextSerialPort::open(OpenMode mode) {
unsigned long confSize = sizeof(COMMCONFIG);
Win_CommConfig.dwSize = confSize;
DWORD dwFlagsAndAttributes = 0;
if (queryMode() == QextSerialPort::EventDriven)
dwFlagsAndAttributes += FILE_FLAG_OVERLAPPED;
QMutexLocker lock(mutex);
if (mode == QIODevice::NotOpen)
return isOpen();
if (!isOpen()) {
/*open the port*/
Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE,
0, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL);
if (Win_Handle!=INVALID_HANDLE_VALUE) {
QIODevice::open(mode);
/*configure port settings*/
GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
GetCommState(Win_Handle, &(Win_CommConfig.dcb));
/*set up parameters*/
Win_CommConfig.dcb.fBinary=TRUE;
Win_CommConfig.dcb.fInX=FALSE;
Win_CommConfig.dcb.fOutX=FALSE;
Win_CommConfig.dcb.fAbortOnError=FALSE;
Win_CommConfig.dcb.fNull=FALSE;
setBaudRate(Settings.BaudRate);
setDataBits(Settings.DataBits);
setStopBits(Settings.StopBits);
setParity(Settings.Parity);
setFlowControl(Settings.FlowControl);
setTimeout(Settings.Timeout_Millisec);
SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
//init event driven approach
if (queryMode() == QextSerialPort::EventDriven) {
Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD;
Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
if (!SetCommMask( Win_Handle, EV_TXEMPTY | EV_RXCHAR | EV_DSR)) {
qWarning() << "failed to set Comm Mask. Error code:", GetLastError();
return false;
}
winEventNotifier = new QWinEventNotifier(overlap.hEvent, this);
connect(winEventNotifier, SIGNAL(activated(HANDLE)), this, SLOT(onWinEvent(HANDLE)));
WaitCommEvent(Win_Handle, &eventMask, &overlap);
}
}
} else {
return false;
}
return isOpen();
}
示例10: lock
/*!
Opens the serial port associated to this class.
This function has no effect if the port associated with the class is already open.
The port is also configured to the current settings, as stored in the Settings structure.
*/
bool QextSerialPort::open(OpenMode mode)
{
QMutexLocker lock(mutex);
if (mode == QIODevice::NotOpen)
return isOpen();
if (!isOpen()) {
qDebug() << "trying to open file" << port.toAscii();
//note: linux 2.6.21 seems to ignore O_NDELAY flag
if ((fd = ::open(port.toAscii() ,O_RDWR | O_NOCTTY | O_NDELAY)) != -1) {
qDebug("file opened succesfully");
setOpenMode(mode); // Flag the port as opened
tcgetattr(fd, &old_termios); // Save the old termios
Posix_CommConfig = old_termios; // Make a working copy
/* the equivelent of cfmakeraw() to enable raw access */
#ifdef HAVE_CFMAKERAW
cfmakeraw(&Posix_CommConfig); // Enable raw access
#else
Posix_CommConfig.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON);
Posix_CommConfig.c_oflag &= ~OPOST;
Posix_CommConfig.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
Posix_CommConfig.c_cflag &= ~(CSIZE | PARENB);
Posix_CommConfig.c_cflag |= CS8;
#endif
/*set up other port settings*/
Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
Posix_CommConfig.c_oflag&=(~OPOST);
Posix_CommConfig.c_cc[VMIN]= 0;
#ifdef _POSIX_VDISABLE // Is a disable character available on this system?
// Some systems allow for per-device disable-characters, so get the
// proper value for the configured device
const long vdisable = fpathconf(fd, _PC_VDISABLE);
Posix_CommConfig.c_cc[VINTR] = vdisable;
Posix_CommConfig.c_cc[VQUIT] = vdisable;
Posix_CommConfig.c_cc[VSTART] = vdisable;
Posix_CommConfig.c_cc[VSTOP] = vdisable;
Posix_CommConfig.c_cc[VSUSP] = vdisable;
#endif //_POSIX_VDISABLE
setBaudRate(Settings.BaudRate);
setDataBits(Settings.DataBits);
setParity(Settings.Parity);
setStopBits(Settings.StopBits);
setFlowControl(Settings.FlowControl);
setTimeout(Settings.Timeout_Millisec);
tcsetattr(fd, TCSAFLUSH, &Posix_CommConfig);
if (queryMode() == QextSerialPort::EventDriven) {
readNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(readNotifier, SIGNAL(activated(int)), this, SIGNAL(readyRead()));
}
示例11: construct
/*!
\fn Posix_QextSerialPort::Posix_QextSerialPort(const char* name, const PortSettings& settings)
Constructs a port with specified name and settings.
*/
Posix_QextSerialPort::Posix_QextSerialPort(const char* name, const PortSettings& settings)
:QextSerialBase(name) {
construct();
setBaudRate(settings.BaudRate);
setDataBits(settings.DataBits);
setStopBits(settings.StopBits);
setParity(settings.Parity);
setFlowControl(settings.FlowControl);
setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
}
示例12: LOCK_MUTEX
/*!
\fn bool Posix_QextSerialPort::open(OpenMode mode)
Opens the serial port associated to this class.
This function has no effect if the port associated with the class is already open.
The port is also configured to the current settings, as stored in the Settings structure.
*/
bool Posix_QextSerialPort::open(OpenMode mode)
{
LOCK_MUTEX();
if (mode == QIODevice::NotOpen)
{
UNLOCK_MUTEX();
return isOpen();
}
if (!isOpen())
{
/*open the port*/
Posix_File->setFileName(port);
QueueReceiveSignals = 10;
if (Posix_File->open(QIODevice::ReadWrite | QIODevice::Unbuffered))
{
/*set open mode*/
QIODevice::open(mode);
/*configure port settings*/
tcgetattr(Posix_File->handle(), &Posix_CommConfig);
/*set up other port settings*/
Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|IGNBRK|PARMRK|ISTRIP|ICRNL|IXANY));
Posix_CommConfig.c_oflag&=(~OPOST);
Posix_CommConfig.c_cc[VMIN]=0;
Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
setBaudRate(Settings.BaudRate);
setDataBits(Settings.DataBits);
setParity(Settings.Parity);
setStopBits(Settings.StopBits);
setFlowControl(Settings.FlowControl);
//setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
setTimeout(Settings.Timeout_Millisec);
tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
handle = Posix_File->handle();
readerThread->handle = handle;
readerThread->shutdown = false;
readerThread->start();
}
else
{
qDebug("Could not open File! Error code : %d", Posix_File->error());
}
}
UNLOCK_MUTEX();
return isOpen();
}
示例13: setPortName
/*!
* \brief SerialDev::configPort - Parametri per configurare la porta seriale
* \return true se riesce a configurare correttamente la porta seriale
*/
bool SerialDev::configPort (const QString &name)
{
bool debugVal = m_debug;
m_debug = true;
setPortName(name);
if (!open(QIODevice::ReadWrite)) {
QString testo = QString("Can't open %1, error code %2")
.arg(portName()).arg(error());
debug(testo);
return false;
}
if (!setBaudRate(QSerialPort::Baud115200)) {
QString testo = QString("Can't set rate 115200 baud to port %1, error code %2")
.arg(portName()).arg(error());
debug(testo);
return false;
}
if (!setDataBits(QSerialPort::Data8)) {
QString testo = QString("Can't set 8 data bits to port %1, error code %2")
.arg(portName()).arg(error());
debug(testo);
return false;
}
if (!setParity(QSerialPort::NoParity)) {
QString testo = QString("Can't set no patity to port %1, error code %2")
.arg(portName()).arg(error());
debug(testo);
return false;
}
if (!setStopBits(QSerialPort::OneStop)) {
QString testo = QString("Can't set 1 stop bit to port %1, error code %2")
.arg(portName()).arg(error());
debug(testo);
return false;
}
if (!setFlowControl(QSerialPort::NoFlowControl)) {
QString testo = QString("Can't set no flow control to port %1, error code %2")
.arg(portName()).arg(error());
debug(testo);
return false;
}
connect(this, SIGNAL(error(QSerialPort::SerialPortError)),
this, SLOT(errorSlot(QSerialPort::SerialPortError)));
connect(this, SIGNAL(readyRead()), this, SLOT(fromDeviceSlot()));
m_debug = debugVal;
return true;
}
示例14: setBaudRate
/*!
\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
Constructs a port with default name and specified settings.
*/
Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode) {
Win_Handle=INVALID_HANDLE_VALUE;
setBaudRate(settings.BaudRate);
setDataBits(settings.DataBits);
setStopBits(settings.StopBits);
setParity(settings.Parity);
setFlowControl(settings.FlowControl);
setTimeout(settings.Timeout_Millisec);
setQueryMode(mode);
init();
}
示例15: QextSerialBase
/*!
\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
Constructs a port with default name and specified settings.
*/
Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
: QextSerialBase()
{
setBaudRate(settings.BaudRate);
setDataBits(settings.DataBits);
setParity(settings.Parity);
setStopBits(settings.StopBits);
setFlowControl(settings.FlowControl);
Posix_File=new QFile();
setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
}