Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SocketCAN #8

Merged
merged 99 commits into from
Dec 21, 2020
Merged

SocketCAN #8

merged 99 commits into from
Dec 21, 2020

Conversation

icecube45
Copy link
Member

@icecube45 icecube45 commented Aug 7, 2020

Adds a framework/support for SocketCAN. This allows dash (and vehicle plugins) to listen to, and query from, the car direct.
Reworks elm327 support to be based on common CANInterface

}
if(this->_write(ss.str())>=0){
QCanBusFrame retFrame = this->receive();
if(retFrame.frameType()!=2){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QCanBusFrame::ErrorFrame is better than 2

std::stringstream ss;

//this is an obd message, so we can send it with the elm327
if(frame.frameId() == 0x7df){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x7df represents an OBD-II request message. That is not obvious from the code/comments. As a matter of style and readability, consider naming your magic numbers with #define or enum

char buf[1];
std::string str;

while (true) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could put the exit condition here, e.g. while buf[0] != '>'

@icecube45
Copy link
Member Author

Urgh the pi is stuck on 5.11 isn't it.. readAllFrames was introduced in 5.12.
I should be able to rework this without using readAllFrames - give me a few days.

@icecube45
Copy link
Member Author

Please try out the new commit, I've removed the readAllFrames call and written my own. It's working on a bunch of CAN logs I have from my car, but I don't have a live car to test on right now.

@jakka351
Copy link

excellent! Will try it out

@jakka351
Copy link

Built sucessfully with one warn
8%] Building CXX object CMakeFiles/dash.dir/src/app/widgets/tuner.cpp.o [ 51%] Building CXX object CMakeFiles/dash.dir/src/app/window.cpp.o [ 53%] Building CXX object CMakeFiles/dash.dir/src/canbus/elm327.cpp.o /can/ui/dash/src/canbus/elm327.cpp: In member function ‘QCanBusFrame elm327::receive()’: /can/ui/dash/src/canbus/elm327.cpp:144:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘unsigned int’} [-Wsign-compare] for(int i=0; i<resp_str.length()/2; i++){ ~^~~~~~~~~~~~~~~~~~~~ [ 55%] Building CXX object CMakeFiles/dash.dir/src/canbus/socketcanbus.cpp.o [ 57%] Building CXX object CMakeFiles/dash.dir/src/dash.cpp.o [ 59%] Building CXX object CMakeFiles/dash.dir/src/obd/command.cpp.o [ 61%] Building CXX object CMakeFiles/dash.dir/dash_autogen/mocs_compilation.cpp.o [ 63%] Building CXX object CMakeFiles/dash.dir/dash_autogen/GBFAFXFCVO/qrc_resources.cpp.o [ 65%] Linking CXX executable bin/dash [ 65%] Built target dash

@icecube45 icecube45 changed the base branch from pages to develop December 21, 2020 02:56

obd_decoder_t decoder;
std::vector<Command> cmds;
std::map<int, double> dataMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataMap was a remnant.

@@ -12,6 +12,10 @@
#include <QRegularExpression>
#include <QTextStream>
#include <QTransform>
#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these extra includes can be removed i think (they're not being usedanymore)

@@ -48,6 +52,8 @@ Theme::Theme() : QObject(qApp), palette()
QFontDatabase::addApplicationFont(":/fonts/Montserrat/Montserrat-LightItalic.ttf");
QFontDatabase::addApplicationFont(":/fonts/Montserrat/Montserrat-Regular.ttf");

qApp->setFont(Theme::font_14);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed (moved before i merged pages into develop, probs came back when you were resolving conflicts hah)

@@ -75,14 +93,15 @@ QString Gauge::null_value()

VehiclePage::VehiclePage(QWidget *parent) : QTabWidget(parent)
{
this->tabBar()->setFont(Theme::font_14);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed too (probs came from conflicts again)

@@ -1,29 +1,41 @@
#include <QPalette>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually in this whole file check to make sure anything font related matches whats in develop (i see a few deviations from it)

@rsjudka rsjudka merged commit 3f7891a into openDsh:develop Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants