All of the following is on a Raspberry Pi 3 with Qt 5.3.2 (GCC 4.9.2, 32 bit).
MainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtSerialPort/qserialportinfo.h>
#include <QtSerialPort/qserialport.h>
#include <QObject>
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QList>
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
bool zaber_is_available;
~MainWindow();
private slots:
void on_Calibration_25mm_stage_move_button_clicked(int position);
void on_Calibration_25mm_stage_home_button_clicked();
void on_Calibration_25mm_stage_out_button_clicked();
void on_Calibration_300mm_stage_move_button_clicked(int position);
void on_Calibration_300mm_stage_home_button_clicked();
void on_Shot_tab_25mm_stage_move_button_clicked(int position);
void on_Shot_tab_25mm_stage_home_button_clicked();
void on_Shot_tab_25mm_stage_out_button_clicked();
void on_Calibration_25mm_slider_sliderMoved(int position);
void on_Calibration_300mm_slider_sliderMoved(int position);
void on_Shot_tab_25mm_slider_sliderMoved(int position);
void on_Shot_tab_25mm_spinbox_valueChanged(int arg1);
void on_Calibration_300mm_spinbox_valueChanged(int arg1);
void on_Calibration_25mm_spinbox_valueChanged(int arg1);
private:
Ui::MainWindow *ui;
QSerialPortInfo *serialPortInfo;
QSerialPort *zaber;
static const quint16 zaber_vendor_id = 0403;
static const quint16 zaber_product_id = 6001;
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtSerialPort/qserialportinfo.h>
#include <QtSerialPort/qserialport.h>
#include <QObject>
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QList>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
bool zaber_is_available;
~MainWindow();
private slots:
void on_Calibration_25mm_stage_move_button_clicked(int position);
void on_Calibration_25mm_stage_home_button_clicked();
void on_Calibration_25mm_stage_out_button_clicked();
void on_Calibration_300mm_stage_move_button_clicked(int position);
void on_Calibration_300mm_stage_home_button_clicked();
void on_Shot_tab_25mm_stage_move_button_clicked(int position);
void on_Shot_tab_25mm_stage_home_button_clicked();
void on_Shot_tab_25mm_stage_out_button_clicked();
void CommZaber(QString);
void on_Calibration_25mm_slider_sliderMoved(int position);
void on_Calibration_300mm_slider_sliderMoved(int position);
void on_Shot_tab_25mm_slider_sliderMoved(int position);
void on_Shot_tab_25mm_spinbox_valueChanged(int arg1);
void on_Calibration_300mm_spinbox_valueChanged(int arg1);
void on_Calibration_25mm_spinbox_valueChanged(int arg1);
private:
Ui::MainWindow *ui;
QSerialPortInfo *serialPortInfo;
QSerialPort *zaber;
static const quint16 zaber_vendor_id = 0403;
static const quint16 zaber_product_id = 6001;
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QPushButton>
#include <QSpinBox>
#include <QSlider>
int main(int argc, char *argv[])
{
MainWindow w;
w.setWindowTitle("Compact 6 Radiometer Control Unit");
w.show();
return a.exec();
}
#include "mainwindow.h"
#include <QApplication>
#include <QPushButton>
#include <QSpinBox>
#include <QSlider>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowTitle("Compact 6 Radiometer Control Unit");
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
MainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtSerialPort/qserialport.h>
#include <QtSerialPort/qserialportinfo.h>
#include <QObject>
#include <QList>
#include <QDebug>
#include <QString>
#include <QWidget>
#include "qmath.h"
#include <QIODevice>
QT_USE_NAMESPACE
char Reply_Bytes[6] ={0};
qint64 maxSize = 6;
int value[4];
int value2[4];
char position_command[6] = {0};
double new_value;
float conversion;
float distance;
const double global_x = pow(256,3);
const double global_y = pow(256,2);
const double global_z = pow(256,4);
float input_position;
int Cmd_Byte_6 = 0;
int Cmd_Byte_5 = 0;
int Cmd_Byte_4 = 0;
int Cmd_Byte_3 = 0;
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
zaber_is_available = false;
qDebug() <<"Number of ports: "<<QSerialPortInfo::availablePorts();
foreach(const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
{
qDebug()<< "Name: " << serialPortInfo.portName();
qDebug()<< "Description: "<< serialPortInfo.description();
qDebug()<< "Manufacturer: " << serialPortInfo.manufacturer();
if(serialPortInfo.hasVendorIdentifier() && serialPortInfo.hasProductIdentifier())
{
qDebug() << "Has VendorID and ProductID:" << serialPortInfo.hasVendorIdentifier() <<
"and" << serialPortInfo.hasVendorIdentifier();
if(serialPortInfo.vendorIdentifier() == zaber_vendor_id)
{
qDebug() << "Vendor: " << serialPortInfo.vendorIdentifier();
if(serialPortInfo.productIdentifier() == zaber_product_id)
{
qDebug() << "Product: " << serialPortInfo.productIdentifier();
zaber = new QSerialPort;
zaber_is_available = true;
}
}
}
}
//code removed as QDebug does not show in it and it is too long.
void MainWindow
::CommZaber(QString command
) {
if(zaber->isWritable()){
zaber->write(command.toStdString().c_str());
}
else{
qDebug() << "Couldn't Write to Serial";
}
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtSerialPort/qserialport.h>
#include <QtSerialPort/qserialportinfo.h>
#include <QObject>
#include <QList>
#include <QDebug>
#include <QString>
#include <QWidget>
#include "qmath.h"
#include <QIODevice>
QT_USE_NAMESPACE
char Reply_Bytes[6] ={0};
qint64 maxSize = 6;
int value[4];
int value2[4];
char position_command[6] = {0};
double new_value;
float conversion;
float distance;
const double global_x = pow(256,3);
const double global_y = pow(256,2);
const double global_z = pow(256,4);
float input_position;
int Cmd_Byte_6 = 0;
int Cmd_Byte_5 = 0;
int Cmd_Byte_4 = 0;
int Cmd_Byte_3 = 0;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
zaber_is_available = false;
qDebug() <<"Number of ports: "<<QSerialPortInfo::availablePorts();
foreach(const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
{
qDebug()<< "Name: " << serialPortInfo.portName();
qDebug()<< "Description: "<< serialPortInfo.description();
qDebug()<< "Manufacturer: " << serialPortInfo.manufacturer();
if(serialPortInfo.hasVendorIdentifier() && serialPortInfo.hasProductIdentifier())
{
qDebug() << "Has VendorID and ProductID:" << serialPortInfo.hasVendorIdentifier() <<
"and" << serialPortInfo.hasVendorIdentifier();
if(serialPortInfo.vendorIdentifier() == zaber_vendor_id)
{
qDebug() << "Vendor: " << serialPortInfo.vendorIdentifier();
if(serialPortInfo.productIdentifier() == zaber_product_id)
{
qDebug() << "Product: " << serialPortInfo.productIdentifier();
zaber = new QSerialPort;
zaber_is_available = true;
}
}
}
}
//code removed as QDebug does not show in it and it is too long.
void MainWindow::CommZaber(QString command)
{
if(zaber->isWritable()){
zaber->write(command.toStdString().c_str());
}
else{
qDebug() << "Couldn't Write to Serial";
}
}
To copy to clipboard, switch view to plain text mode
The error I get is as stated in the post title. The pointer for the error leads me to the library, as if the error was in the library.
I have tried adding the following to my header file to fix the issue but it did not work.
{
Q_OBJECT
public:
explicit DebugClass
(QObject *parent
= 0);
friend QDebug operator<< (QDebug dbg, const DebugClass &info){
dbg.nospace() << "This is x: " <<info.x;
return dbg.maybeSpace();
}
private:
int x;
};
class DebugClass : public QObject
{
Q_OBJECT
public:
explicit DebugClass(QObject *parent = 0);
friend QDebug operator<< (QDebug dbg, const DebugClass &info){
dbg.nospace() << "This is x: " <<info.x;
return dbg.maybeSpace();
}
private:
int x;
};
To copy to clipboard, switch view to plain text mode
I have gotten this far by the good graces of Google. Any help would be greatly appreciated.
Bookmarks