Added ability for connections to update the connection view details
based on hardware status.
This commit is contained in:
+7
-1
@@ -55,7 +55,13 @@ signals:
|
||||
void frameUpdate(int);
|
||||
void connectionSuccess();
|
||||
void connectionFailure();
|
||||
void deviceInfo(int, int); //First param = driver version (or version of whatever you want), second param a status byte (listen only, single wire, etc)
|
||||
void deviceInfo(int, int); //First param = driver version (or version of whatever you want), second param a status byte
|
||||
|
||||
//bus number, bus speed, status (bit 0 = enabled, 1 = single wire, 2 = listen only)
|
||||
//3 = Use value stored for enabled, 4 = use value passed for single wire, 5 = use value passed for listen only
|
||||
//6 = use value passed for speed. This allows bus status to be updated but set that some things aren't really
|
||||
//being passed. Just set for things that really are being updated.
|
||||
void busStatus(int, int, int);
|
||||
|
||||
public slots:
|
||||
virtual void run();
|
||||
|
||||
@@ -7,6 +7,12 @@ CANConnectionModel::CANConnectionModel(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CANConnectionModel::refreshView()
|
||||
{
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QVariant CANConnectionModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
void addBus(CAN_Bus &bus);
|
||||
CAN_Bus* getBus(int bus);
|
||||
CANConnection* getConnection(int conn);
|
||||
void refreshView();
|
||||
|
||||
private:
|
||||
QList<CANConnectionContainer *> connections;
|
||||
|
||||
+16
-29
@@ -89,6 +89,7 @@ void ConnectionWindow::handleOKButton()
|
||||
if (ui->rbGVRET->isChecked())
|
||||
{
|
||||
SerialWorker *serial = new SerialWorker(canModel, connModel->rowCount());
|
||||
connect(serial, SIGNAL(busStatus(int,int,int)), this, SLOT(receiveBusStatus(int,int,int)));
|
||||
connModel->addConnection(serial);
|
||||
|
||||
qDebug() << "Setup initial connection object";
|
||||
@@ -136,40 +137,26 @@ void ConnectionWindow::handleOKButton()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (ui->rbGVRET->isChecked())
|
||||
{
|
||||
conn = "GVRET";
|
||||
connType = 0;
|
||||
currentConnType = ConnectionType::GVRET_SERIAL;
|
||||
}
|
||||
|
||||
if (ui->rbKvaser->isChecked())
|
||||
void ConnectionWindow::receiveBusStatus(int bus, int speed, int status)
|
||||
{
|
||||
conn = "KVASER";
|
||||
connType = 1;
|
||||
currentConnType = ConnectionType::KVASER;
|
||||
}
|
||||
|
||||
if (ui->rbSocketCAN->isChecked())
|
||||
qDebug() << "bus " << bus << " speed " << speed << " status " << status;
|
||||
CAN_Bus *busRef = connModel->getBus(bus);
|
||||
if (status & 40) busRef->setSpeed(speed);
|
||||
if (status & 8) //update enabled status
|
||||
{
|
||||
conn = "SOCKETCAN";
|
||||
connType = 2;
|
||||
currentConnType = ConnectionType::SOCKETCAN;
|
||||
busRef->setEnabled((status & 1)?true:false);
|
||||
}
|
||||
|
||||
currentPortName = getPortName();
|
||||
currentSpeed1 = getSpeed();
|
||||
|
||||
settings->setValue("Main/DefaultConnectionPort", currentPortName);
|
||||
settings->setValue("Main/DefaultConnectionType", connType);
|
||||
settings->setValue("Main/SingleWireMode", ui->ckSingleWire->isChecked());
|
||||
|
||||
emit updateConnectionSettings(conn, getPortName(), getSpeed());
|
||||
|
||||
this->close();
|
||||
*/
|
||||
if (status & 0x10) //update single wire status
|
||||
{
|
||||
busRef->setSingleWire((status & 2)?true:false);
|
||||
}
|
||||
if (status & 0x20) //update listen only status
|
||||
{
|
||||
busRef->setListenOnly((status & 4)?true:false);
|
||||
}
|
||||
connModel->refreshView();
|
||||
}
|
||||
|
||||
void ConnectionWindow::handleConnSelectionChanged()
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ private slots:
|
||||
void handleConnSelectionChanged();
|
||||
void handleRemoveConn();
|
||||
void handleRevert();
|
||||
|
||||
void receiveBusStatus(int bus, int speed, int status);
|
||||
|
||||
private:
|
||||
Ui::ConnectionWindow *ui;
|
||||
|
||||
+2
-1
@@ -81,7 +81,6 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port)
|
||||
serial = new QSerialPort(*port);
|
||||
|
||||
qDebug() << "Serial port name is " << port->portName();
|
||||
//serial->setBaudRate(10000000); //more speed! probably does nothing for USB serial
|
||||
serial->setDataBits(serial->Data8);
|
||||
serial->setFlowControl(serial->HardwareControl); //this is important though
|
||||
if (!serial->open(QIODevice::ReadWrite))
|
||||
@@ -414,6 +413,8 @@ void SerialWorker::procRXChar(unsigned char c)
|
||||
if (!can0Enabled) can0Baud = 0;
|
||||
isConnected = true;
|
||||
emit connectionSuccess();
|
||||
emit busStatus(busBase, can0Baud, can0Enabled?0x49:0x48); //say that we're updating baud rate and set enabled status
|
||||
emit busStatus(busBase + 1, can1Baud, can1Enabled?0x49:0x48);
|
||||
break;
|
||||
}
|
||||
rx_step++;
|
||||
|
||||
Reference in New Issue
Block a user