Esempio n. 1
0
/**
 * @brief MainWindow::on_pushButtonRefresh_clicked
 */
void MainWindow::on_pushButtonRefresh_clicked()
{
    qDebug() debugprefix << "on_pushButtonRefresh_clicked() scanning channels" ;
    int c,i;
    treeWidgetItems.clear();
    ui->treeWidgetInterfaces->clear();
    canStatus stat = canGetNumberOfChannels(&c);
    if( canOK == stat ){
        for (i=0; i < c; i++) {
            char tmp[255];
            stat = canGetChannelData(i, canCHANNELDATA_DEVDESCR_ASCII, &tmp, sizeof(tmp));
            if (stat < 0){
                char buf[128];
                canGetErrorText(stat,buf,128);
                qDebug() debugprefix << "canGetChannelData() " << buf ;
            }else{
                QTreeWidgetItem *port = new QTreeWidgetItem(ui->treeWidgetInterfaces);
                QTreeWidgetItem *name = new QTreeWidgetItem(port);
                port->setText(0, QString().setNum(i,10));
                name->setText(0, QString(tmp));
                qDebug() debugprefix << "canGetChannelData("<< i << ") " << tmp;
                port->setExpanded(true);
            }
        }
    }else{
        char buf[128];
        canGetErrorText(stat,buf,128);
        qDebug() debugprefix << "canGetNumberOfChannels() " << buf ;
    }
}
Esempio n. 2
0
void MainWindow::on_pushButtonBusOn_clicked()
{
    bool fail = false;
    canStatus stat;
    qDebug() debugprefix << "on_pushButtonBusOn_clicked()";

    if(busOn){
        canBusOff(canHandle);
        ui->pushButtonBusOn->setText("Go On Bus");
        busOn = false;
    }else{
        // Timings
        int br = (ui->comboBoxBaud->currentIndex()+1)*-1;
        stat = canSetBusParams(canHandle, br  , 0, 0, 0, 0, 0);
        if (stat < 0){
            char buf[128];
            canGetErrorText(stat,buf,128);
            qDebug() debugprefix << "canSetBusParams("<< br << ") " << buf;
            fail = true;
        }

        // Silent
        bool silent = ui->checkBox_Silent->isChecked();
        if(silent){
            stat = canSetBusOutputControl(canHandle, canDRIVER_SILENT);
        }else{
            stat = canSetBusOutputControl(canHandle, canDRIVER_NORMAL);
        }
        if (stat < 0){
            char buf[128];
            canGetErrorText(stat,buf,128);
            qDebug() debugprefix << "canSetBusOutputControl("<< silent << ") " << buf;
            fail = true;
        }

        if(fail == false){
            stat = canBusOn(canHandle);
            if (stat < 0){
                char buf[128];
                canGetErrorText(stat,buf,128);
                qDebug() debugprefix << "canBusOn("<< br << ") " << buf;
                fail = true;
                QMessageBox msgBox;
                msgBox.setText("Couldn't enter Bus-On state");
                msgBox.exec();
            }else{
                ui->pushButtonBusOn->setText("Go Off Bus");
                busOn = true;
            }
        }else{
            QMessageBox msgBox;
            msgBox.setText("Couldn't enter Bus-On state due to initialization errors");
            msgBox.exec();
        }
    }
}
Esempio n. 3
0
void Check(char* id, canStatus stat)
{
    char buf[50];
    if (stat != canOK) {
        buf[0] = '\0';
        canGetErrorText(stat, buf, sizeof(buf));
        printf("%s: failed, stat=%d (%s)\n", id, (int)stat, buf);
    }
}
Esempio n. 4
0
void check(const char* id, canStatus stat) {
  char buf[50];

  buf[0] = '\0';
  canGetErrorText(stat, buf, sizeof(buf));
  if (stat != canOK) {
    ROS_INFO("%s: failed, stat=%d (%s)\n", id, (int)stat, buf);
  } else {
    //ROS_INFO("%s: OK\n", id);
  }
}