More work on supporting swcan - it's there now! Untested as of yet.
This commit is contained in:
@@ -71,7 +71,7 @@ int CANConnectionModel::rowCount(const QModelIndex &parent) const
|
|||||||
foreach(const CANConnection* conn_p, conns)
|
foreach(const CANConnection* conn_p, conns)
|
||||||
rows += conn_p->getNumBuses();
|
rows += conn_p->getNumBuses();
|
||||||
|
|
||||||
qDebug() << "Num Rows: " << rows;
|
//qDebug() << "Num Rows: " << rows;
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
qDebug() << "Row: " << index.row();
|
//qDebug() << "Row: " << index.row();
|
||||||
|
|
||||||
int busId;
|
int busId;
|
||||||
CANConnection *conn_p = getAtIdx(index.row(), busId);
|
CANConnection *conn_p = getAtIdx(index.row(), busId);
|
||||||
@@ -154,7 +154,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
ret = conn_p->getBusSettings(busId, bus);
|
ret = conn_p->getBusSettings(busId, bus);
|
||||||
bool isSocketCAN = (conn_p->getType() == CANCon::SOCKETCAN) ? true: false;
|
bool isSocketCAN = (conn_p->getType() == CANCon::SOCKETCAN) ? true: false;
|
||||||
|
|
||||||
qDebug() << "ConnP: " << conn_p << " ret " << ret;
|
//qDebug() << "ConnP: " << conn_p << " ret " << ret;
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if(!conn_p)
|
if(!conn_p)
|
||||||
|
|||||||
@@ -125,7 +125,27 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
}
|
}
|
||||||
else deviceSingleWireMode = 0;
|
else deviceSingleWireMode = 0;
|
||||||
}
|
}
|
||||||
|
else if (pBusIdx == 2)
|
||||||
|
{
|
||||||
|
swcanBaud = bus.getSpeed();
|
||||||
|
swcanBaud |= 0x80000000;
|
||||||
|
if (bus.isActive())
|
||||||
|
{
|
||||||
|
swcanBaud |= 0x40000000;
|
||||||
|
swcanEnabled = true;
|
||||||
|
}
|
||||||
|
else swcanEnabled = false;
|
||||||
|
|
||||||
|
if (bus.isListenOnly())
|
||||||
|
{
|
||||||
|
swcanBaud |= 0x20000000;
|
||||||
|
swcanListenOnly = true;
|
||||||
|
}
|
||||||
|
else swcanListenOnly = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBusIdx < 2) {
|
||||||
/* update baud rates */
|
/* update baud rates */
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
qDebug() << "Got signal to update bauds. 1: " << can0Baud <<" 2: " << can1Baud;
|
qDebug() << "Got signal to update bauds. 1: " << can0Baud <<" 2: " << can1Baud;
|
||||||
@@ -144,6 +164,32 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
if (serial == NULL) return;
|
if (serial == NULL) return;
|
||||||
if (!serial->isOpen()) return;
|
if (!serial->isOpen()) return;
|
||||||
serial->write(buffer);
|
serial->write(buffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* update baud rates */
|
||||||
|
QByteArray buffer;
|
||||||
|
qDebug() << "Got signal to update extended bus speeds SWCAN: " << swcanBaud <<" LIN1: " << lin1Baud << " LIN2: " << lin2Baud;
|
||||||
|
debugOutput("Got signal to update extended bus speeds SWCAN: " + QString::number(swcanBaud) + " LIN1: " + QString::number(lin1Baud) + " LIN2: " + QString::number(lin2Baud));
|
||||||
|
buffer[0] = (char)0xF1; //start of a command over serial
|
||||||
|
buffer[1] = 14; //setup extended buses
|
||||||
|
buffer[2] = (unsigned char)(swcanBaud & 0xFF); //four bytes of ID LSB first
|
||||||
|
buffer[3] = (unsigned char)(swcanBaud >> 8);
|
||||||
|
buffer[4] = (unsigned char)(swcanBaud >> 16);
|
||||||
|
buffer[5] = (unsigned char)(swcanBaud >> 24);
|
||||||
|
buffer[6] = (unsigned char)(lin1Baud & 0xFF); //four bytes of ID LSB first
|
||||||
|
buffer[7] = (unsigned char)(lin1Baud >> 8);
|
||||||
|
buffer[8] = (unsigned char)(lin1Baud >> 16);
|
||||||
|
buffer[9] = (unsigned char)(lin1Baud >> 24);
|
||||||
|
buffer[10] = (unsigned char)(lin2Baud & 0xFF); //four bytes of ID LSB first
|
||||||
|
buffer[11] = (unsigned char)(lin2Baud >> 8);
|
||||||
|
buffer[12] = (unsigned char)(lin2Baud >> 16);
|
||||||
|
buffer[13] = (unsigned char)(lin2Baud >> 24);
|
||||||
|
buffer[14] = 0;
|
||||||
|
if (serial == NULL) return;
|
||||||
|
if (!serial->isOpen()) return;
|
||||||
|
serial->write(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ void SocketCan::piStarted()
|
|||||||
mTimer.setInterval(1000);
|
mTimer.setInterval(1000);
|
||||||
mTimer.setSingleShot(false); //keep ticking
|
mTimer.setSingleShot(false); //keep ticking
|
||||||
mTimer.start();
|
mTimer.start();
|
||||||
|
mBusData[0].mBus.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ bool SocketCan::piGetBusSettings(int pBusIdx, CANBus& pBus)
|
|||||||
|
|
||||||
void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||||
{
|
{
|
||||||
|
CANConStatus stats;
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if(0 != pBusIdx)
|
if(0 != pBusIdx)
|
||||||
return;
|
return;
|
||||||
@@ -109,7 +111,6 @@ bool SocketCan::piSendFrame(const CANFrame& pFrame)
|
|||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if(0 != pFrame.bus || pFrame.len>8)
|
if(0 != pFrame.bus || pFrame.len>8)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!mDev_p) return false;
|
if (!mDev_p) return false;
|
||||||
|
|
||||||
/* fill frame */
|
/* fill frame */
|
||||||
@@ -232,8 +233,11 @@ void SocketCan::testConnection() {
|
|||||||
/* try to reconnect */
|
/* try to reconnect */
|
||||||
CANBus bus;
|
CANBus bus;
|
||||||
if(getBusConfig(0, bus))
|
if(getBusConfig(0, bus))
|
||||||
|
{
|
||||||
|
bus.setEnabled(true);
|
||||||
setBusSettings(0, bus);
|
setBusSettings(0, bus);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* disconnect test instance */
|
/* disconnect test instance */
|
||||||
dev_p->disconnectDevice();
|
dev_p->disconnectDevice();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user