Merge branch 'WIP2' of github.com:collin80/SavvyCAN into WIP2

Conflicts:
	connectionwindow.cpp
This commit is contained in:
Collin Kidder
2016-05-06 14:49:54 -04:00
5 changed files with 70 additions and 24 deletions
+2 -2
View File
@@ -53,8 +53,8 @@ signals:
void error(const QString &);
void frameUpdateRapid(int);
void frameUpdate(int);
void connectionSuccess();
void connectionFailure();
void connectionSuccess(CANConnection *);
void connectionFailure(CANConnection *);
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)
+45 -2
View File
@@ -83,6 +83,16 @@ void ConnectionWindow::handleNewConn()
handleConnSelectionChanged();
}
void ConnectionWindow::handleEnableAll()
{
}
void ConnectionWindow::handleDisableAll()
{
}
void ConnectionWindow::handleConnTypeChanged()
{
if (ui->rbGVRET->isChecked()) getSerialPorts();
@@ -90,6 +100,38 @@ void ConnectionWindow::handleConnTypeChanged()
if (ui->rbSocketCAN->isChecked()) getSocketcanPorts();
}
void ConnectionWindow::connectionSuccess(CANConnection *conn)
{
CAN_Bus bus;
bus.active = true;
bus.busNum = conn->getBusBase();
bus.connection = conn;
bus.listenOnly = ui->ckListenOnly->isChecked();
bus.singleWire = ui->ckSingleWire->isChecked();
if (ui->cbSpeed->currentIndex() < 1) bus.speed = 0; //default speed
else if (ui->cbSpeed->currentIndex() == 1)
{
bus.speed = 0;
bus.active = false;
}
else bus.speed = ui->cbSpeed->currentText().toInt();
connModel->addBus(bus);
int numBuses = conn->getNumBuses();
for (int i = 1; i < numBuses; i++)
{
bus.active = false;
bus.listenOnly = false;
bus.singleWire = false;
bus.speed = 250000;
bus.busNum = conn->getBusBase() + i;
bus.connection = conn;
connModel->addBus(bus);
qDebug() << "Added bus " << bus.busNum;
}
}
void ConnectionWindow::handleOKButton()
{
QString conn;
@@ -113,11 +155,12 @@ void ConnectionWindow::handleOKButton()
else if (ui->cbSpeed->currentIndex() > 1)
{
bus->setSpeed(ui->cbSpeed->currentText().toInt());
}
}
//call through signal/slot interface without using connect
QMetaObject::invokeMethod(bus->connection, "updateBusSettings",
Qt::QueuedConnection,
Q_ARG(CAN_Bus *, bus));
connModel->refreshView();
}
else //new connection
{
@@ -125,6 +168,7 @@ void ConnectionWindow::handleOKButton()
{
SerialWorker *serial = new SerialWorker(canModel, connModel->rowCount());
connect(serial, SIGNAL(busStatus(int,int,int)), this, SLOT(receiveBusStatus(int,int,int)));
connect(serial, SIGNAL(connectionSuccess(CANConnection*)), this, SLOT(connectionSuccess(CANConnection*)));
connModel->addConnection(serial);
qDebug() << "Setup initial connection object";
@@ -226,7 +270,6 @@ void ConnectionWindow::handleConnSelectionChanged()
ui->ckEnabled->setChecked(bus->isActive());
int speed = bus->getSpeed();
setSpeed(speed);
//connModel->refreshView();
}
}
+3
View File
@@ -58,7 +58,10 @@ private slots:
void handleDisableAll();
void handleRevert();
void handleNewConn();
void handleEnableAll();
void handleDisableAll();
void receiveBusStatus(int bus, int speed, int status);
void connectionSuccess(CANConnection *conn);
private:
Ui::ConnectionWindow *ui;
+19 -19
View File
@@ -134,7 +134,7 @@ void SerialWorker::connectionTimeout()
qDebug() << "Failed to connect to GVRET at that com port";
//ticker->stop();
closeSerialPort(); //make sure it's properly closed anyway
emit connectionFailure();
emit connectionFailure(this);
}
}
@@ -205,7 +205,7 @@ void SerialWorker::sendFrameBatch(const QList<CANFrame> *frames)
sendBulkMutex.unlock();
}
void SerialWorker::updateBaudRates(int Speed1, int Speed2)
void SerialWorker::updateBaudRates(unsigned int Speed1, unsigned int Speed2)
{
QByteArray buffer;
qDebug() << "Got signal to update bauds. 1: " << Speed1 <<" 2: " << Speed2;
@@ -413,17 +413,17 @@ void SerialWorker::procRXChar(unsigned char c)
qDebug() << "Baud 0 = " << can0Baud;
qDebug() << "Baud 1 = " << can1Baud;
can0Baud &= 0x80000000;
if (can0Enabled) can0Baud &= 0x40000000;
if (can0ListenOnly) can0Baud &= 0x20000000;
can0Baud |= 0x80000000;
if (can0Enabled) can0Baud |= 0x40000000;
if (can0ListenOnly) can0Baud |= 0x20000000;
can1Baud &= 0x80000000;
if (can1Enabled) can1Baud &= 0x40000000;
if (can1ListenOnly) can1Baud &= 0x20000000;
if (deviceSingleWireMode > 0) can1Baud &= 0x10000000;
can1Baud |= 0x80000000;
if (can1Enabled) can1Baud |= 0x40000000;
if (can1ListenOnly) can1Baud |= 0x20000000;
if (deviceSingleWireMode > 0) can1Baud |= 0x10000000;
isConnected = true;
emit connectionSuccess();
emit connectionSuccess(this);
int can0Status = 0x78; //updating everything we can update
int can1Status = 0x78;
if (can0Enabled) can0Status +=1;
@@ -431,8 +431,8 @@ void SerialWorker::procRXChar(unsigned char c)
if (can1Enabled) can1Status += 1;
if (deviceSingleWireMode > 0) can1Status += 2;
if (can1ListenOnly) can1Status += 4;
emit busStatus(busBase, can0Baud, can0Status);
emit busStatus(busBase + 1, can1Baud, can1Status);
emit busStatus(busBase, can0Baud & 0xFFFFF, can0Status);
emit busStatus(busBase + 1, can1Baud & 0xFFFFF, can1Status);
break;
}
rx_step++;
@@ -585,17 +585,17 @@ void SerialWorker::updateBusSettings(CAN_Bus *bus)
if (busNum == 0)
{
can0Baud = bus->getSpeed();
can0Baud &= 0x80000000;
can0Baud |= 0x80000000;
if (bus->isActive())
{
can0Baud &= 0x40000000;
can0Baud |= 0x40000000;
can0Enabled = true;
}
else can0Enabled = false;
if (bus->isListenOnly())
{
can0Baud &= 0x20000000;
can0Baud |= 0x20000000;
can0ListenOnly = true;
}
else can0ListenOnly = false;
@@ -603,24 +603,24 @@ void SerialWorker::updateBusSettings(CAN_Bus *bus)
if (busNum == 1)
{
can1Baud = bus->getSpeed();
can1Baud &= 0x80000000;
can1Baud |= 0x80000000;
if (bus->isActive())
{
can1Baud &= 0x40000000;
can1Baud |= 0x40000000;
can1Enabled = true;
}
else can1Enabled = false;
if (bus->isListenOnly())
{
can1Baud &= 0x20000000;
can1Baud |= 0x20000000;
can1ListenOnly = true;
}
else can1ListenOnly = false;
if (bus->isSingleWire())
{
can1Baud &= 0x10000000;
can1Baud |= 0x10000000;
deviceSingleWireMode = 1;
}
else deviceSingleWireMode = 0;
+1 -1
View File
@@ -53,7 +53,7 @@ public slots:
void closeSerialPort();
void sendFrame(const CANFrame *) override;
void sendFrameBatch(const QList<CANFrame> *) override;
void updateBaudRates(int, int);
void updateBaudRates(unsigned int, unsigned int);
//void stopFrameCapture(int) override;
//void startFrameCapture(int) override;
void updatePortName(QString) override; //string version of the port to connect to. This base doesnt know a thing about this value