int main(int argc, char *argv[]) { int i,j,k,portFD; unsigned char data[1024]; gettimeofday(&tStart,NULL); output(1,"HP iPAQ 214 BT chip GPIO twiddling util v1.1\n----------------------------------\n"); #ifndef NOIO gpioInit(1); #else output(1,"TESTING MODE - NOT USING IO\n"); #endif if(argc > 1 && strcmp(argv[1],"on")==0){ portFD=openPort(); if(portFD == -1){ return 0; } output(1,"Shutting down chip first...\n"); #ifndef NOIO shutdownChip(); tcflush(portFD, TCIOFLUSH); //flush buffers again #endif output(1,"Waiting 2 secs.\n"); sleep(2); output(1,"Bringing up chip...\n"); bringUpChip(); output(1,"Resetting chip...\n"); #ifndef NOIO sendReset(portFD); #endif output(1,"Turning LED on.\n"); #ifndef NOIO gpioSet(3,1); #endif output(1,"closing port..."); fflush(stdout); close(portFD); output(1,"done\n"); }else if(argc > 1 && strcmp(argv[1],"off")==0){ output(1,"Shutting down chip...\n"); #ifndef NOIO shutdownChip(); gpioSet(3,0); //turn LED off #endif }else printf("usage %s on/off\n",argv[0]); #ifndef NOIO gpioCleanup(); #endif return 0; }
void RiscComm::onConsoleInput(QString input) { m_sp->readAll(); // flush any residual crap out (from FPGA reset for example) if (input.compare("s") == 0) { sendStep(); doScan(); } else if (input.compare("sc") == 0) doScan(); else if (input.compare("q") == 0) QCoreApplication::exit(); else if (input.compare("r") == 0) sendRun(); else if (input.compare("rs") == 0) sendReset(); else if (input.compare("st") == 0) { sendStop(); doScan(); } else if (input.startsWith("wp")) { QStringList args = input.split(" "); if (args.length() == 2) { // upload a file sendProgram(args.at(1)); } } else if (input.compare("clrmem") == 0) { QByteArray zeros; zeros.fill(0, 256); writeMem(zeros, 0, true); } else if (input.compare("dm") == 0) { dumpMem(); } else qDebug() << "Unknown command:" << input; }
void rfid::receiveID(QString _ID) { //If a card is detected, request the ID of it if(_ID.toInt() == 253) { sendRequestID(); } //If we are in the process of receiving an ID, add it to receivedData else if(_ID.toInt() != 251) { if(_ID.toInt() < 10) receivedData += (QString::number(0) + QString::number(0) + _ID); else if (_ID.toInt() < 100) receivedData += (QString::number(0) + _ID); else receivedData += _ID; } // If we get the endofline command (251), and receivedData is not empty, emit newID. else if(_ID.toInt() == 251 && !receivedData.isEmpty()) { emit newID(receivedData); //qDebug() << receivedData; receivedData.clear(); } //Always send reset to prevent getting stuck if card is removed too quickly.. :) sendReset(); }
rfid::rfid(QObject *parent, QString port, int baudrate) : QObject(parent) { serial = new QAsyncSerial(port, baudrate); connect(serial, SIGNAL(lineReceived(QString)), this, SLOT(receiveID(QString))); sendReset(); }
AddVaccineWid::AddVaccineWid(QString rootdir,QWidget *parent) : QWidget(parent) { path = rootdir; lay = new QVBoxLayout(this); det_w = new VaccineDetailsWid(); bottom = new VaccineBottomWid(); lay->addWidget(det_w); lay->addWidget(bottom); connect(bottom,SIGNAL(sendSave()),this,SLOT(performSave())); connect(bottom,SIGNAL(sendReset()),this,SLOT(performReset())); }
void BasicModem::initialize(void) { // Reset and flush pending input. sendReset(); Time::Delay::wait(2.0); m_handle->flushInput(); // Perform initialization. setReadMode(READ_MODE_LINE); start(); sendInitialization(); }
bool PBBP::enumerate(void (*callback)(uint8_t*)) { uint8_t b; if (!sendReset() || !sendByte(BC_CMD_ENUMERATE)) { if (this->last_error == NO_ACK_OR_NACK) { // Nobody on the bus return true; } // Other error return false; } uint8_t num_slaves = 0; while (num_slaves < this->max_slaves) { // Allocate room to store one more address uint8_t id[UNIQUE_ID_LENGTH]; uint8_t crc = 0; for (uint8_t i = 0; i < UNIQUE_ID_LENGTH; ++i) { if (!receiveByte(&id[i])) { if (i == 0 && this->last_error == NO_ACK_OR_NACK) { // Nobody responded, meaning all device are enumerated return true; } // Other error return false; } crc = pinoccio_crc_update(UNIQUE_ID_CRC_POLY, crc, id[i]); } if (crc != 0) { this->last_error = CRC_ERROR; return false; } callback(id); num_slaves++; } // See if there is one more if (receiveByte(&b)) { // Succesfully received a byte, there are more slaves! this->last_error = TOO_MANY_SLAVES; return false; } else { return (this->last_error == NO_ACK_OR_NACK); } }
DownloadView::DownloadView(QWidget *parent) : QWidget(parent) { QBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); bar = new THBlackBar(this); QAction *action = new QAction(tr("Downloads"), this); bar->addAction(action); layout->addWidget(bar); listView = new DownloadListView(this); #ifdef APP_MAC listView->setAlternatingRowColors(true); #endif /* QPalette p = listView->palette(); p.setColor(QPalette::Base, palette().color(QPalette::Window)); listView->setPalette(p); */ PrettyItemDelegate *delegate = new PrettyItemDelegate(this, true); listView->setItemDelegate(delegate); listView->setSelectionMode(QAbstractItemView::NoSelection); // cosmetics listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); listView->setFrameShape(QFrame::NoFrame); listView->setAttribute(Qt::WA_MacShowFocusRect, false); listView->setMinimumSize(320,240); listView->setUniformItemSizes(true); listModel = DownloadManager::instance()->getModel(); listView->setModel(listModel); connect(listView, SIGNAL(downloadButtonPushed(QModelIndex)), SLOT(buttonPushed(QModelIndex))); connect(listView, SIGNAL(entered(const QModelIndex &)), SLOT(itemEntered(const QModelIndex &))); layout->addWidget(listView); updateTimer = new QTimer(this); updateTimer->setInterval(1000); connect(updateTimer, SIGNAL(timeout()), listModel, SLOT(sendReset())); downloadSettings = new DownloadSettings(this); layout->addWidget(downloadSettings); }
dacDialog::dacDialog(QWidget *parent, QSerialPort *serial) : QDialog(parent), ui(new Ui::dacDialog) { ui->setupUi(this); if(serial != NULL) serialPort = serial; activeMsg = new GUI_message(); connect(ui->resetButton, SIGNAL(clicked()), this, SLOT(sendReset())); connect(ui->writePushButton, SIGNAL(clicked()), this, SLOT(sendDACMessage())); connect(ui->readPushButton, SIGNAL(clicked()), this, SLOT(sendDACMessage())); connect(this, SIGNAL(updateData(unsigned char)), this, SLOT(updateDataLineEdit(unsigned char))); ui->pageLineEdit->setInputMask("0xHH"); ui->pageLineEdit->setText("0x00"); ui->addressLineEdit->setInputMask("0xHH"); ui->addressLineEdit->setText("0x00"); ui->dataLineEdit->setInputMask("0xHH"); ui->dataLineEdit->setText("0x00"); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { thread = new QThread(); reader = new Reader(); reader->moveToThread(thread); connect(reader, SIGNAL(sendPoint(int,int,double)), this, SLOT(setPointProb(int,int,double))); connect(reader, SIGNAL(workRequested()), thread, SLOT(start())); connect(thread, SIGNAL(started()), reader, SLOT(doWork())); connect(reader, SIGNAL(finished()), thread, SLOT(quit()) , Qt::DirectConnection); connect(reader, SIGNAL(finished()), this, SLOT(fileFinished())); connect(reader, SIGNAL(sendReset()), this, SLOT(resetPositions())); setFixedSize(800,600); p_scene = new QGraphicsScene(this); p_view = new QGraphicsView(p_scene, this); QPixmap background(QCoreApplication::applicationDirPath() + "/img/sol.png"); if (background.isNull()) { std::cout << "Ouverture de sol.png échouée, ouverture de sol.jpg" << std::endl; background = QPixmap(QCoreApplication::applicationDirPath() + "/img/sol.jpg"); } p_scene->setBackgroundBrush(QBrush(background)); p_view->setGeometry(10,10,505,505); p_addPosition = new QPushButton("Ajouter position", this); p_addPosition->setGeometry(590,90, 120, 30); p_deletePos = new QPushButton("Réinitialiser positions", this); p_deletePos->setGeometry(590,130, 120, 30); p_openFile = new QPushButton("Ouvrir fichier", this); p_openFile->setGeometry(590, 170, 120, 30); p_changeTableSize = new QPushButton("Changer taille table", this); p_changeTableSize->setGeometry(50, 560, 120, 30); pauseButton = new QPushButton("", this); QIcon pauseIcon(QCoreApplication::applicationDirPath() + "/img/pause.png"); if (pauseIcon.isNull()) { std::cout << "Ouverture de pause.png échouée, ouverture de pause.jpg" << std::endl; pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/pause.jpg")); } pauseButton->setIcon(pauseIcon); pauseButton->setGeometry(590, 250, 30, 30); pauseButton->setDisabled(true); stopButton = new QPushButton("", this); QIcon stopIcon(QCoreApplication::applicationDirPath() + "/img/stop.png"); if (stopIcon.isNull()) { std::cout << "Ouverture de stop.png échouée, ouverture de stop.jpg" << std::endl; pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/stop.jpg")); } stopButton->setIcon(stopIcon); stopButton->setGeometry(630, 250, 30, 30); stopButton->setDisabled(true); stepButton = new QPushButton("", this); QIcon stepIcon(QCoreApplication::applicationDirPath() + "/img/step.png"); if (stepIcon.isNull()) { std::cout << "Ouverture de step.png échouée, ouverture de step.jpg" << std::endl; stepIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/step.jpg")); } stepButton->setIcon(stepIcon); stepButton->setGeometry(670, 250, 30, 30); stepButton->setDisabled(true); p_quit = new QPushButton("Quitter", this); p_quit->setGeometry(600, 560, 100, 30); p_addPosX = new QLineEdit(this); p_addPosY = new QLineEdit(this); p_addPosP = new QLineEdit(this); p_addPosX->setGeometry(580, 50, 40, 30); p_addPosY->setGeometry(630, 50, 40, 30); p_addPosP->setGeometry(680, 50, 40, 30); p_addPosX->setPlaceholderText("Abscisse"); p_addPosY->setPlaceholderText("Ordonnée"); p_addPosP->setPlaceholderText("Proba"); currentDate = new QLabel("Pas de fichier en cours", this); currentDate->setGeometry(580, 300, 140, 30); QObject::connect(p_addPosition, SIGNAL(clicked()), this, SLOT(sendPointProbValues())); QObject::connect(this, SIGNAL(pointProbValues(int,int,double)), this, SLOT(setPointProb(int,int,double))); QObject::connect(p_deletePos, SIGNAL(clicked()), this, SLOT(resetPositions())); QObject::connect(p_quit, SIGNAL(clicked()), qApp, SLOT(quit())); QObject::connect(p_openFile, SIGNAL(clicked()), this, SLOT(readMatrixFromFile())); QObject::connect(p_changeTableSize, SIGNAL(clicked()), this, SLOT(changeTableSize())); QObject::connect(pauseButton, SIGNAL(clicked()), this, SLOT(pauseRead())); QObject::connect(stopButton, SIGNAL(clicked()), this, SLOT(stopRead())); QObject::connect(reader, SIGNAL(sendDate(QString)), this, SLOT(setDate(QString))); QObject::connect(stepButton, SIGNAL(clicked()), this, SLOT(clickNextDate())); }
//-------------------------------------------------------------- void testApp::update(){ for(int i = 0; i < K; i++) kinects[i].markAsOld(); processOSC(); //------------------------- if(bLoadMLP){ bLoadMLP = false; matrixData.openMLP(); for(int i = 0; i < K; i++) kinects[i].setMatrix(matrixData.getMatrix(i)); } //------------------------- if(bTracking){ if(!bCalibrated) { bCalibrated = match.startTracking(kinects, trackers); } else{ for(int i = 0; i < N; i++) trackers[i].resetCandidates(); match.matchCandidates(kinects, trackers); for(int i = 0; i < N; i++) trackers[i].match(); } } else{ bCalibrated = false; } //---- sendDistances(); sendPositions(); sendAzimuts(); if(bReset){ sendReset(); bReset = false; } if(bSaving){ if(!pbSaving){ frame = 0; pbSaving = true; } sendSaving(frame); frame += 1; } else{ pbSaving = false; } if(ofGetFrameNum() % 30 == 0) sendPing(); //----- SCREEN INFO char msg[2048]; matrixData.getStatus(msg); strcat(msg, oscStatus); char kinectMsg[500]; for(int i = 0; i < K; i++){ kinects[i].getStatus(kinectMsg, i); strcat(msg, kinectMsg); } char other[500]; sprintf(other, "\n[CENTER] %4.f, %4.f\n[REF POINT] %4.f, %4.f\n[REF VECTOR] %4.f, %4.f ", center.x, center.z, refPoint.x, refPoint.z, refVector.x, refVector.z); strcat(msg, other); sprintf(other, "\n[GHOST 1] %4.f, %4.f\n[GHOST 2] %4.f, %4.f ", ghost0.x, ghost0.z, ghost1.x, ghost1.z); strcat(msg, other); float delta[3]; int n = 0; if(bTracking && bCalibrated){ for(int i = 0; i < N; i++){ sprintf(other, "\n[TRACKER %d] %4.f %4.f %4.f", i, trackers[i].pos.x, trackers[i].pos.y, trackers[i].pos.z); strcat(msg, other); } } sprintf(other, "\n[STATE] %1.d", state); strcat(msg, other); strcat(msg, "\n\nPRESS AND DRAG:\n[1] cam zoom [2] cam x/y [2] cam rot\n"); strcat(msg, "PRESS:\n[ ] to start tracking\n"); status->setName(msg); status->setSize(300, 400); calibratedButton ->setValue(bCalibrated); //----- // ... //writeLog(); }
void RbFirmataController::ProcessIO() { try { m_bIOThreadProcessing = true; std::cout << "Sending firmware version request\r\n"; //First lets flush the buffer. _port.flush(); //First reset firmata sendReset(); boost::this_thread::sleep(boost::posix_time::microseconds(10)); sendFirmwareVersionRequest(); //Loop through to do the innitial setup int iSendFirmwareCount=0; while(!(m_bStopIO || m_bSetupComplete)) { if(!_firmwareReceived) { update(); //if(iSendFirmwareCount <= 0 && !_firmwareReceived) //{ // //Then need to do this to init the pins, get the firmware version, and call setupArduino. // //Will stay in update loop looking for signal. When it arrives Setup will be called // //and we can start processing. // iSendFirmwareCount = 1000; //} //iSendFirmwareCount--; boost::this_thread::sleep(boost::posix_time::microseconds(300)); } } //Start the timer to measure motor send timing. m_lMotorSendStart = GetSimulator()->GetTimerTick(); //Now that setup has compled lets do our main loop while(!m_bStopIO) { if(m_bPauseIO || m_lpSim->Paused()) { m_bIOPaused = true; boost::this_thread::sleep(boost::posix_time::microseconds(1000)); } else { m_bIOPaused = false; //Update the firmata IO. update(); //Do not try and step IO until it has been setup correctly. StepIO(); if(_dynamixelMoveAdds > 0) { //Get the motor send time m_fltMotorSendTime = GetSimulator()->TimerDiff_m(m_lMotorSendStart, GetSimulator()->GetTimerTick()); //Execute any synch moves that were setup for this IO loop in StepIO //If none were setup it will ignore this call. sendDynamixelSynchMoveExecute(); //Star the timer again. m_lMotorSendStart = GetSimulator()->GetTimerTick(); } } } } catch(CStdErrorInfo oError) { m_bIOThreadProcessing = false; } catch(...) { m_bIOThreadProcessing = false; } m_bIOThreadProcessing = false; }
bool PBBP::sendCommand(uint8_t slave_addr, uint8_t command) { return sendReset() && sendByte(slave_addr) && sendByte(command); }
void CEMIDriver::started() { after_reset = true; reset_timer.start(0.5,0); sendReset(); }
void AppointmentBottomBar::onResetPressed() { emit sendReset(); }