Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ These commands ensure your system has all the required Qt6 libraries, CAN-relate
```bash
git clone https://github.com/OpenAutoDiagLabs/cangaroo

cd CANgaroo/src && PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig qmake6 && cd .. && PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig make -j$(nproc)
cd cangaroo/src && PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig qmake6 && cd .. && PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig make -j$(nproc)
```

The binary will be located in `../bin/cangaroo`.
Expand Down
6 changes: 4 additions & 2 deletions src/driver/SocketCanDriver/SocketCanDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool SocketCanDriver::update() {
deleteAllInterfaces();

struct nl_sock *sock = nl_socket_alloc();
struct nl_cache *cache;
struct nl_cache *cache = NULL;

nl_connect(sock, NETLINK_ROUTE);
int result = rtnl_link_alloc_cache(sock, AF_UNSPEC, &cache);
Expand All @@ -71,7 +71,9 @@ bool SocketCanDriver::update() {
}
}

nl_cache_free(cache);
if (cache) {
nl_cache_free(cache);
}
nl_close(sock);
nl_socket_free(sock);

Expand Down
12 changes: 8 additions & 4 deletions src/driver/SocketCanDriver/SocketCanInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ bool SocketCanInterface::updateStatus()
bool retval = false;

struct nl_sock *sock = nl_socket_alloc();
struct nl_cache *cache;
struct nl_cache *cache = NULL;
struct rtnl_link *link;
uint32_t state;

Expand Down Expand Up @@ -215,7 +215,9 @@ bool SocketCanInterface::updateStatus()
}
}

nl_cache_free(cache);
if (cache) {
nl_cache_free(cache);
}
nl_close(sock);
nl_socket_free(sock);

Expand All @@ -227,7 +229,7 @@ bool SocketCanInterface::readConfig()
bool retval = false;

struct nl_sock *sock = nl_socket_alloc();
struct nl_cache *cache;
struct nl_cache *cache = NULL;
struct rtnl_link *link;

nl_connect(sock, NETLINK_ROUTE);
Expand All @@ -239,7 +241,9 @@ bool SocketCanInterface::readConfig()
}
}

nl_cache_free(cache);
if (cache) {
nl_cache_free(cache);
}
nl_close(sock);
nl_socket_free(sock);

Expand Down
5 changes: 5 additions & 0 deletions src/window/SetupDialog/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ void SetupDialog::treeViewSelectionChanged(const QItemSelection &selected, const
QModelIndex idx = selected.first().topLeft();
SetupDialogTreeItem *item = static_cast<SetupDialogTreeItem *>(idx.internalPointer());

if (!item) {
ui->stackedWidget->setCurrentWidget(ui->emptyPage);
updateButtons();
return;
}

_currentNetwork = item->network;

Expand Down
40 changes: 3 additions & 37 deletions src/window/TraceWindow/TraceWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ TraceWindow::TraceWindow(QWidget *parent, Backend &backend) :
ConfigurableWidget(parent),
ui(new Ui::TraceWindow),
_backend(&backend),
_mode(mode_linear),
_doAutoScroll(false),
_mode(mode_aggregated),
_timestampMode(timestamp_mode_absolute)
{
ui->setupUi(this);
Expand All @@ -56,7 +55,6 @@ TraceWindow::TraceWindow(QWidget *parent, Backend &backend) :
_linFilteredModel->setSourceModel(_linearProxyModel);

setMode(mode_aggregated);
setAutoScroll(false);

QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
Expand Down Expand Up @@ -88,11 +86,6 @@ TraceWindow::TraceWindow(QWidget *parent, Backend &backend) :

connect(ui->TraceClearpushButton, SIGNAL(released()), this, SLOT(on_cbTraceClearpushButton()));

connect(ui->cbAggregated,SIGNAL(stateChanged(int)),this,SLOT(on_cbAggregated_stateChanged(int)));
connect(ui->cbAutoScroll,SIGNAL(stateChanged(int)),this,SLOT(on_cbAutoScroll_stateChanged(int)));

ui->cbAggregated->setCheckState(Qt::Unchecked);
ui->cbAutoScroll->setCheckState(Qt::Checked);
}

TraceWindow::~TraceWindow()
Expand All @@ -111,35 +104,23 @@ void TraceWindow::setMode(TraceWindow::mode_t mode)
{
ui->tree->setSortingEnabled(false);
ui->tree->setModel(_linFilteredModel); //_linearTraceViewModel);
ui->cbAutoScroll->setEnabled(true);
ui->tree->sortByColumn(BaseTraceViewModel::column_index, Qt::AscendingOrder);
}
else
{
ui->tree->setSortingEnabled(true);
ui->tree->setModel(_aggFilteredModel); //_aggregatedProxyModel);
ui->cbAutoScroll->setEnabled(false);
ui->tree->sortByColumn(BaseTraceViewModel::column_canid, Qt::AscendingOrder);
}

ui->tree->scrollToBottom();

if (isChanged)
{
ui->cbAggregated->setChecked(_mode==mode_aggregated);
emit(settingsChanged(this));
}
}

void TraceWindow::setAutoScroll(bool doAutoScroll)
{
if (doAutoScroll != _doAutoScroll)
{
_doAutoScroll = doAutoScroll;
ui->cbAutoScroll->setChecked(_doAutoScroll);
emit(settingsChanged(this));
}
}

void TraceWindow::setTimestampMode(int mode)
{
Expand Down Expand Up @@ -178,11 +159,10 @@ bool TraceWindow::saveXML(Backend &backend, QDomDocument &xml, QDomElement &root
}

root.setAttribute("type", "TraceWindow");
root.setAttribute("mode", (_mode==mode_linear) ? "linear" : "aggregated");
root.setAttribute("mode", "aggregated");
root.setAttribute("TimestampMode", _timestampMode);

QDomElement elLinear = xml.createElement("LinearTraceView");
elLinear.setAttribute("AutoScroll", (ui->cbAutoScroll->checkState() == Qt::Checked) ? 1 : 0);
root.appendChild(elLinear);

QDomElement elAggregated = xml.createElement("AggregatedTraceView");
Expand All @@ -199,11 +179,10 @@ bool TraceWindow::loadXML(Backend &backend, QDomElement &el)
return false;
}

setMode((el.attribute("mode", "linear") == "linear") ? mode_linear : mode_aggregated);
setMode(mode_aggregated);
setTimestampMode(el.attribute("TimestampMode", "0").toInt());

QDomElement elLinear = el.firstChildElement("LinearTraceView");
setAutoScroll(elLinear.attribute("AutoScroll", "0").toInt() != 0);

QDomElement elAggregated = el.firstChildElement("AggregatedTraceView");
int sortColumn = elAggregated.attribute("SortColumn", "-1").toInt();
Expand All @@ -223,22 +202,9 @@ void TraceWindow::rowsInserted(const QModelIndex &parent, int first, int last)
{
_backend->clearTrace();
}

if ((_mode==mode_linear) && (ui->cbAutoScroll->checkState() == Qt::Checked))
{
ui->tree->scrollToBottom();
}
}

void TraceWindow::on_cbAggregated_stateChanged(int i)
{
setMode( (i==Qt::Checked) ? mode_aggregated : mode_linear );
}

void TraceWindow::on_cbAutoScroll_stateChanged(int i)
{
setAutoScroll(i==Qt::Checked);
}

void TraceWindow::on_cbTimestampMode_currentIndexChanged(int index)
{
Expand Down
4 changes: 0 additions & 4 deletions src/window/TraceWindow/TraceWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class TraceWindow : public ConfigurableWidget
~TraceWindow();

void setMode(mode_t mode);
void setAutoScroll(bool doAutoScroll);
void setTimestampMode(int mode);

virtual bool saveXML(Backend &backend, QDomDocument &xml, QDomElement &root);
Expand All @@ -60,8 +59,6 @@ public slots:
void rowsInserted(const QModelIndex & parent, int first, int last);

private slots:
void on_cbAggregated_stateChanged(int i);
void on_cbAutoScroll_stateChanged(int i);

void on_cbTimestampMode_currentIndexChanged(int index);
void on_cbFilterChanged(void);
Expand All @@ -72,7 +69,6 @@ private slots:
Ui::TraceWindow *ui;
Backend *_backend;
mode_t _mode;
bool _doAutoScroll;
timestamp_mode_t _timestampMode;

TraceFilterModel * _aggFilteredModel;
Expand Down
23 changes: 0 additions & 23 deletions src/window/TraceWindow/TraceWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbAutoScroll">
<property name="toolTip">
<string>Autoscroll</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../cangaroo.qrc">
<normaloff>:/assets/auto-scroll.svg</normaloff>:/assets/auto-scroll.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down