static void hottSendTelemetryData(void) { if (!hottIsSending) { hottIsSending = true; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences //serialSetMode(hottPort, MODE_TX); closeSerialPort(hottPort); hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_TX, SERIAL_NOT_INVERTED); hottMsgCrc = 0; return; } if (hottMsgRemainingBytesToSendCount == 0) { hottMsg = NULL; hottIsSending = false; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences //serialSetMode(hottPort, MODE_RX); closeSerialPort(hottPort); hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_RX, SERIAL_NOT_INVERTED); flushHottRxBuffer(); return; } --hottMsgRemainingBytesToSendCount; if(hottMsgRemainingBytesToSendCount == 0) { hottSerialWrite(hottMsgCrc++); return; } hottMsgCrc += *hottMsg; hottSerialWrite(*hottMsg++); }
void ConsoleWindow::closeSerialPort(const QString portName) { if (portName.isEmpty()) return; if (portName.compare(serial->portName()) == 0) { closeSerialPort(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); monitor = new PortMonitor(this); //przyciski connect(ui->pushButtonConnect,SIGNAL(clicked()),monitor,SLOT(openSerialPort())); connect(ui->pushButtonPreferences,SIGNAL(clicked()),monitor->settings,SLOT(show())); connect(ui->pushButtonDisconnect,SIGNAL(clicked()),monitor,SLOT(closeSerialPort())); //sygnały wysyłane, przez monitor portu connect(monitor,SIGNAL(newDataArrived(QByteArray)),this,SLOT(showData(QByteArray))); connect(monitor,SIGNAL(newLeftVerticaTriggerValue(int)),ui->verticalSliderLeftVerticalTrigger,SLOT(setValue(int))); connect(monitor,SIGNAL(newLeftHorizontalTriggerValue(int)),ui->horizontalSliderLeftHorizontalTrigger,SLOT(setValue(int))); connect(monitor,SIGNAL(newRightVerticaTriggerValue(int)),ui->verticalSliderRightVerticalTrigger,SLOT(setValue(int))); connect(monitor,SIGNAL(newRightHorizontalTriggerValue(int)),ui->horizontalSliderRightHorizontalTrigger,SLOT(setValue(int))); connect(monitor,SIGNAL(newLeftTriggerString(QString)),ui->labelLeftTrigger,SLOT(setText(QString))); connect(monitor,SIGNAL(newRightTriggerString(QString)),ui->labelRightTrigger,SLOT(setText(QString))); //dostosowanie kontrolek ui->verticalSliderLeftVerticalTrigger->setMinimum(-100); ui->verticalSliderLeftVerticalTrigger->setMaximum(100); ui->verticalSliderRightVerticalTrigger->setMinimum(-100); ui->verticalSliderRightVerticalTrigger->setMaximum(100); ui->horizontalSliderLeftHorizontalTrigger->setMinimum(-100); ui->horizontalSliderLeftHorizontalTrigger->setMaximum(100); ui->horizontalSliderRightHorizontalTrigger->setMinimum(-100); ui->horizontalSliderRightHorizontalTrigger->setMaximum(100); }
void BTReaderThread::handleError(QSerialPort::SerialPortError error) { if (error == QSerialPort::ResourceError) { closeSerialPort(); emit ShowErrorSignal(serial->errorString()); } }
//Move X - Move X axis motor variable steps //Input: Number of Steps //Output: 0 for failure, 1 for success // 2010/06/30: Added backlash compensation when stepper turns around -ADE int stepperDriver::MoveX(int steps) { int temp; //Added to handle backlash compensation when stepper changes direciton steps = -steps; //Axis is inverted with hardware setup temp = steps; //Check if stepper is changing directions. If so compensate for backlash in motors. if ((iLastMoveX * steps)<0) { if (steps < 0) temp = steps - BACKLASH_COMPENSATION_X; else temp = steps + BACKLASH_COMPENSATION_X; } iLastMoveX = steps; //Build command string char command[25] = "F,C,I1M"; char buf[10]; itoa(temp,buf,10); //convert steps to buffer string strcat(command,buf); //append amount of steps to string strcat(command,",R"); //append run component of command //Output to Port openSerialPort(); PortSendCommands(command); WaitForVXM(); closeSerialPort(); yCo+=steps; return 0; }
//! [8] void MainWindow::handleError(QSerialPort::SerialPortError error) { if (error == QSerialPort::ResourceError) { QMessageBox::critical(this, tr("Critical Error"), serial->errorString()); closeSerialPort(); } }
MainWindow::MainWindow() { //QMainWindow(parent), messages = new char; //free(messages),messages = NULL; //messages[0] = '1'; first = new bool; first = true; serial = new QSerialPort(this); settings = new SettingsDialog; // Création et disposition des widgets de la fenêtre etatServeur = new QLabel; boutonQuitter = new QPushButton(tr("Quitter")); buttonUartConnect = new QPushButton(tr("Open Uart")); buttonUartDisconnect = new QPushButton(tr("Close Uart")); buttonSettings = new QPushButton(tr("Uart Settings")); buttona = new QPushButton(tr("1")); connect(buttona, SIGNAL(clicked()), this, SLOT(open1())); connect(buttonUartConnect, SIGNAL(clicked()), this, SLOT(openSerialPort())); connect(buttonUartDisconnect, SIGNAL(clicked()), this, SLOT(closeSerialPort())); connect(boutonQuitter, SIGNAL(clicked()), qApp, SLOT(quit())); connect(buttonSettings, SIGNAL(clicked()), settings, SLOT(show())); connect(serial, SIGNAL(readyRead()), this, SLOT(readData())); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(etatServeur); layout->addWidget(buttona); layout->addWidget(buttonSettings); layout->addWidget(buttonUartConnect); layout->addWidget(buttonUartDisconnect); layout->addWidget(boutonQuitter); setLayout(layout); setWindowTitle(tr("ZeroChat - Serveur")); // Gestion du serveur serveur = new QTcpServer(this); if (!serveur->listen(QHostAddress::Any, 50885)) // Démarrage du serveur sur toutes les IP disponibles et sur le port 50585 { // Si le serveur n'a pas été démarré correctement etatServeur->setText(tr("Le serveur n'a pas pu être démarré. Raison :<br />") + serveur->errorString()); } else { // Si le serveur a été démarré correctement etatServeur->setText(tr("Le serveur a été démarré sur le port <strong>") + QString::number(serveur->serverPort()) + tr("</strong>.<br />Des clients peuvent maintenant se connecter.")); connect(serveur, SIGNAL(newConnection()), this, SLOT(nouvelleConnexion())); } tailleMessage = 0; }
void MainWindow::initSerialPort(){ Terminal *serial1 = new Terminal; serial1->terminalInitialisation(); QObject::connect(SerialConnectButton, SIGNAL(clicked()), serial1, SLOT(on_bouton_serial_connexion_clicked())); QObject::connect(serial1,SIGNAL(openSerialPortTerminal()),this,SLOT(openSerialPort())); QObject::connect(serial1,SIGNAL(closeSerialPortTerminal()),this,SLOT(closeSerialPort())); }
void ConsoleWindow::closeEvent(QCloseEvent *event) { closeSerialPort(); QSettings settings; settings.setValue("consolewindow/geometry", saveGeometry()); settings.setValue("consolewindow/tate", saveState()); QMainWindow::closeEvent(event); }
void freeSmartPortTelemetryPort(void) { closeSerialPort(smartPortSerialPort); smartPortSerialPort = NULL; smartPortState = SPSTATE_UNINITIALIZED; smartPortTelemetryEnabled = false; }
MainWindow::~MainWindow() { closeSerialPort(); delete connectTimer; delete ui; delete console; delete serial; }
void mspSerialReleaseSharedTelemetryPorts(void) { for (uint8_t portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) { mspPort_t *candidateMspPort = &mspPorts[portIndex]; if (candidateMspPort->sharedWithTelemetry) { closeSerialPort(candidateMspPort->port); memset(candidateMspPort, 0, sizeof(mspPort_t)); } } }
void VnaDevice::handleError(QSerialPort::SerialPortError error) { if (error == QSerialPort::ResourceError) { QMessageBox::critical(mainWindow, tr("Critical Error"), serial->errorString()); closeSerialPort(); } emit signalError(error); }
void MainWindow::initActionsConnections() { connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(openSerialPort())); connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(closeSerialPort())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionConfigure, SIGNAL(triggered()), settings, SLOT(show())); connect(ui->actionClear, SIGNAL(triggered()), console, SLOT(clear())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }
void mspSerialReleasePortIfAllocated(serialPort_t *serialPort) { for (uint8_t portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) { mspPort_t *candidateMspPort = &mspPorts[portIndex]; if (candidateMspPort->port == serialPort) { closeSerialPort(serialPort); memset(candidateMspPort, 0, sizeof(mspPort_t)); } } }
//Move Up - Move Motor 2 +1000 steps //Input: None //Output: 0 for failure, 1 for success int stepperDriver::MoveUp() { int temp = openSerialPort(); //add error code if needed temp = PortSendCommands("F,C,I2M1000,R"); //Move Motor 2 +5 steps temp = WaitForVXM(); //Wait for VMX program to finish temp = closeSerialPort(); yCo+=1000; return temp; }
void mspSerialReleasePortIfAllocated(serialPort_t *serialPort) { for (int i = 0; i < MAX_MSP_PORT_COUNT; i++) { mspPort_t *mspPort = &mspPorts[i]; if (mspPort->port == serialPort) { closeSerialPort(mspPort->port); resetMspPort(mspPort, NULL); } } }
void HexySerial::onSettingsChanged() { { QSignalBlocker(this); closeSerialPort(); openSerialPort(); settings->hide(); //version(); writeData("\n"); } emit settingsChanged(); }
void MainWindow::on_pushButtonConnect_clicked() { if (serialPort->isOpen()) { closeSerialPort(); ui->pushButtonConnect->setText(QStringLiteral("Connect")); } else if(openSerialPort()) { ui->pushButtonConnect->setText(QStringLiteral("Disconnect")); } }
BuzzerModule::BuzzerModule() { setTitle("Buzzer"); setControlWidget(new BuzzerControl); setLiveWidget(new BuzzerLive); BaseControl *control = getControlWidget(); BaseLive *live = getLiveWidget(); serial = new QSerialPort(); teamLocked = false; connect(control, SIGNAL(sendTeamWin(QString)), live, SLOT(teamWin(QString))); connect(control, SIGNAL(openSerialPort(QString&)), this, SLOT(openSerialPort(QString&))); connect(control, SIGNAL(closeSerialPort()), this, SLOT(closeSerialPort())); connect(this, SIGNAL(teamWin(int)), control, SLOT(teamWin(int))); connect(serial, SIGNAL(readyRead()), this, SLOT(readSerialPort())); connect(live, SIGNAL(unlockTeam()), this, SLOT(unlockTeam())); connect(control, SIGNAL(setVideo(QString)), live, SLOT(setVideo(QString))); connect(control, SIGNAL(setVideoPlaying(bool)), live, SLOT(setVideoPlaying(bool))); connect(control, SIGNAL(toggleVideoPlaying()), live, SLOT(toggleVideoPlaying())); connect(live, SIGNAL(videoPlaying(bool)), control, SLOT(videoPlaying(bool))); connect(live, SIGNAL(videoFinished()), control, SLOT(videoFinished())); }
void BuzzerControl::serialGo(bool state) { if (state) { QString serialPort = serialPortList->currentText(); start->setText("Disconnect"); emit openSerialPort(serialPort); serialPortList->setEnabled(false); refresh->setEnabled(false); } else { start->setText("Connect"); emit closeSerialPort(); serialPortList->setEnabled(true); refresh->setEnabled(true); } }
void ConsoleWindow::openSerialPort(const QString portName) { if (portName.isEmpty()) return; settings->selectPortName(portName); if (serial->isOpen()) { if (serial->portName().compare(portName) != 0) { closeSerialPort(); openSerialPort(); } } else { openSerialPort(); } }
int main(int argc, char **argv) { char deviceFilePath[MAXPATHLEN]; int fileDescriptor; int c; int bCont; // flag for continuous operation struct sigaction act; opterr = 0; while ((c=getopt(argc, argv, "cd:h")) != -1) { switch (c) { case 'c': bCont = 1; break; case 'd': strcpy(deviceFilePath, optarg); break; case 'h': printHelp(); return 1; case '?': if (optopt=='d') fprintf(stderr, "Option -%c requires an argument.\n", optopt); else if (isprint (optopt)) fprintf(stderr, "Unknown option '-%c'.\n", optopt); else fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt); return 1; default: abort(); } } act.sa_handler = intHandler; sigaction(SIGINT, &act, NULL); // catch Ctrl-C //printf ("dev: %s\n", deviceFilePath); if (!deviceFilePath[0]) { printf("No serial device found. Did you specify the '-d /dev/device' option?\n"); return EX_UNAVAILABLE; } fileDescriptor = openSerialPort(deviceFilePath); if (fileDescriptor == -1) { return EX_IOERR; } if (!(readSerialData(fileDescriptor, bCont))) { printf("Could not read data.\n"); } closeSerialPort(fileDescriptor); // printf("Modem port closed.\n"); return EX_OK; }
/*********************************************************************************************************************** int main(int argc, char **argv) program entry point, expects the serial port name as a command line argument ***********************************************************************************************************************/ int main(int argc, char **argv) { // store the port parameters char* portName; int serialPort; // parse the command line arguments if(argc != 2) { printf("USAGE: %s <port_name> \n", argv[0]); return 0; } portName = argv[1]; // attempt to open the serial port serialPort = openSerialPort(portName); // check to see if we connected successfully if(serialPort == -1) { printf("unable to open serial port %s \n", portName); return(0); } printf("%s opened successfully!\n", portName); // continuously check for received serial data int numBytes = 0; while(1) { // check for received serial data numBytes = numBytes + pollSerialPort(serialPort); // send a packet sendPacket(serialPort, 0x01, 0x02, 0x03); // stop listening for data once we receive 100 bytes if(numBytes >= 100) { break; } // sleep for 20ms (20*1000 microseconds) usleep(20*1000); } // close the serial port closeSerialPort(serialPort); }
int main(int argc, const char * argv[]) { io_iterator_t serialPortIterator; char bsdPath[MAXPATHLEN]; if(udpServerInit() != 0) { consoleNotef("Simulator link input port open failed.\n"); return -1; } if(initConsoleInput() != 0) { consoleNotef("Console input initialization failed.\n"); return -2; } Boolean looking = false; while(1) { if(!looking) { consoleNotef("Looking for the serial port...\n"); looking = true; } if(findModems(&serialPortIterator) == KERN_SUCCESS) { if(getModemPath(serialPortIterator, bsdPath, sizeof(bsdPath)) == KERN_SUCCESS) { if(openSerialPort(bsdPath) != -1) { serverInit(); consoleNotef("Entering server loop...\n"); serverLoop(); consoleNotef("Server loop exited.\n"); closeSerialPort(serialPort); looking = false; } else consoleNotef("Serial port could not be opened.\n"); } IOObjectRelease(serialPortIterator); } sleep(1); } return EX_OK; }
RESPONSECODE IFDHCloseChannel ( DWORD Lun ) { /* This function should close the reader communication channel for the particular reader. Prior to closing the communication channel the reader should make sure the card is powered down and the terminal is also powered down. returns: IFD_SUCCESS IFD_COMMUNICATION_ERROR */ Log1(PCSC_LOG_DEBUG, "IFDHCloseChannel"); closeSerialPort(); return IFD_SUCCESS; }
//----------------------------------------------------------------------------------------------------------- void Widget::refreshAvSerialPort() { if(ui->pushButton->text()=="Cl&ose") closeSerialPort(); dozvilNaOnovlPortiv=0; QStringList oldList; QStringList oldListInfo; QStringList newList; QStringList newListInfo; for(qint32 i=1; i<ui->comboBox_2->count(); i++) { oldList.append(ui->comboBox_2->itemText(i)); oldListInfo.append(ui->comboBox_2->itemData(i, Qt::ToolTipRole).toString()); } ui->comboBox_2->clear(); ui->comboBox_2->addItem("REFRESH"); foreach (const SerialPortInfo &info, SerialPortInfo::availablePorts()) { newList<<info.portName(); newListInfo<< info.description()+", "+ info.manufacturer() +", "+ info.systemLocation(); }
int main() { int res; pthread_t socket_thread, uart_thread; void *thread_result; serial_port_fd = openSerialPort("/dev/ttySAC3",115200); if (serial_port_fd < 0) { perror("open serialport failed !\n"); exit(EXIT_FAILURE); } // printf("serial_port_fd = %d \n",serial_port_fd ); res=pthread_create( &socket_thread, NULL, thread_socket, 0 ); if(res != 0){ perror("Thread_socket creation failed"); exit(EXIT_FAILURE); } res=pthread_create( &uart_thread, NULL, thread_uart, 0 ); if(res != 0){ perror("Thread_uart creation failed"); exit(EXIT_FAILURE); } res=pthread_join( socket_thread, &thread_result ); if(res != 0){ perror("Thread_socket join failed"); exit(EXIT_FAILURE); } res=pthread_join( uart_thread, &thread_result ); if(res != 0){ perror("Thread_uart join failed"); exit(EXIT_FAILURE); } closeSerialPort(serial_port_fd); printf("main exit\n"); return 0; }
void MainWindow::connButtonPress() { if (!isConnected) { for (int x = 0; x < ports.count(); x++) { if (ports.at(x).portName() == ui->cbSerialPorts->currentText()) { emit sendSerialPort(&ports[x]); lbStatusConnected.setText(tr("Attempting to connect to port ") + ports[x].portName()); return; } } } else { emit closeSerialPort(); isConnected = false; lbStatusConnected.setText(tr("Not Connected")); ui->btnConnect->setText(tr("Connect to GVRET")); } }
void HexySerial::handleError(QSerialPort::SerialPortError error) { /* NoError, DeviceNotFoundError, PermissionError, OpenError, ParityError, FramingError, BreakConditionError, WriteError, ReadError, ResourceError, UnsupportedOperationError, UnknownError, TimeoutError, NotOpenError */ qDebug()<<"HANDLED ERROR: "<<error; if (error == QSerialPort::ResourceError) { qDebug()<<"Critical Error"<<serial->errorString(); closeSerialPort(); } }