There are a TON of explorations I did here, many may be unnecessary, but this is a stake in the ground. The main issue was the strange queue logic in canconmanager::sendFrame which puts the tx data in the rx queue so it will show up in the displayed data. It caused SIGABRT and SIGSEG to show up everywhere. It is NOT fixed yet, but TX works over the wire you just can't see it in the tableview. I thought at first it was only when overwrite data was active, so I put in a a pile of changes to keep frames and filtered frames as two seperate copies of data where frames was always complete and filtered was only what was seen in the mainwindow. It made it so the graphing window would work with overwrite data active which is an improvement. I wouldn't roll these changes back. Because of these changes I had to update the frame sorting code adjust the refresh function in canframemode.cpp I also thought it was related to UI updates, but its not, that's been confirmed. I put a mutex around the custom sender tick timer so that the 1ms timer wouldn't re-enter its callback. This didn't fix the crash, but it sure seems to make a lot of sense, and the way I did it no elasped time is lost for tracking purposes, and in reality theres no way 1ms was consistent anyway. I put a mutex around the shrinking of frames and filteredframes to make sure we weren't deleting at the same time as accessing, but honestly we acccess those lists in many places without semaphores so that probably did nothing. Fixed a bug in FrameSenderWindow:DoModifiers that was improperly parsing and sometimes crashing when looking for the ~ operator before a symbol. Also added some minor work to keep row expansion functioning when changing filters or sorting. Need to make some tweaks so it stops trying so hard when overwrite is not active Theres also code in main.c taht makes debugging output super verbose. Committing now to start cleanup
109 lines
3.7 KiB
C++
109 lines
3.7 KiB
C++
#ifndef CANFRAMEMODEL_H
|
|
#define CANFRAMEMODEL_H
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QList>
|
|
#include <QVector>
|
|
#include <QDebug>
|
|
#include <QMutex>
|
|
#include "can_structs.h"
|
|
#include "dbc/dbchandler.h"
|
|
#include "connections/canconnection.h"
|
|
|
|
enum class Column {
|
|
TimeStamp = 0, ///< The timestamp when the frame was transmitted or received
|
|
FrameId = 1, ///< The frames CAN identifier (Standard: 11 or Extended: 29 bit)
|
|
Extended = 2, ///< True if the frames CAN identifier is 29 bit
|
|
Remote = 3, ///< True if the frames is a remote frame
|
|
Direction = 4, ///< Whether the frame was transmitted or received
|
|
Bus = 5, ///< The bus where the frame was transmitted or received
|
|
Length = 6, ///< The frames payload data length
|
|
ASCII = 7, ///< The payload interpreted as ASCII characters
|
|
Data = 8, ///< The frames payload data
|
|
NUM_COLUMN
|
|
};
|
|
|
|
class CANFrameModel: public QAbstractTableModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CANFrameModel(QObject *parent = 0);
|
|
virtual ~CANFrameModel();
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
int role = Qt::DisplayRole) const;
|
|
int columnCount(const QModelIndex &) const;
|
|
int totalFrameCount();
|
|
|
|
void sendRefresh();
|
|
void sendRefresh(int);
|
|
int sendBulkRefresh();
|
|
void clearFrames();
|
|
void setInterpretMode(bool);
|
|
bool getInterpretMode();
|
|
void setOverwriteMode(bool);
|
|
void setHexMode(bool);
|
|
void setClearMode(bool mode);
|
|
void setSysTimeMode(bool);
|
|
void setMillisMode(bool mode);
|
|
void setIgnoreDBCColors(bool mode);
|
|
void setFilterState(unsigned int ID, bool state);
|
|
void setBusFilterState(unsigned int BusID, bool state);
|
|
void setAllFilters(bool state);
|
|
void setSecondsMode(bool);
|
|
void setTimeFormat(QString);
|
|
void loadFilterFile(QString filename);
|
|
void saveFilterFile(QString filename);
|
|
void normalizeTiming();
|
|
void recalcOverwrite();
|
|
bool needsFilterRefresh();
|
|
void insertFrames(const QVector<CANFrame> &newFrames);
|
|
void sortByColumn(int column);
|
|
int getIndexFromTimeID(unsigned int ID, double timestamp);
|
|
const QVector<CANFrame> *getListReference() const; //thou shalt not modify these frames externally!
|
|
const QVector<CANFrame> *getFilteredListReference() const; //Thus saith the Lord, NO.
|
|
const QMap<int, bool> *getFiltersReference() const; //this neither
|
|
const QMap<int, bool> *getBusFiltersReference() const; //this neither
|
|
|
|
public slots:
|
|
void addFrame(const CANFrame&, bool);
|
|
void addFrames(const CANConnection*, const QVector<CANFrame>&);
|
|
|
|
signals:
|
|
void updatedFiltersList();
|
|
|
|
private:
|
|
void qSortCANFrameAsc(QVector<CANFrame>* frames, Column column, int lowerBound, int upperBound);
|
|
void qSortCANFrameDesc(QVector<CANFrame>* frames, Column column, int lowerBound, int upperBound);
|
|
uint64_t getCANFrameVal(QVector<CANFrame> *frames, int row, Column col);
|
|
bool any_filters_are_configured(void);
|
|
bool any_busfilters_are_configured(void);
|
|
|
|
QVector<CANFrame> frames;
|
|
QVector<CANFrame> filteredFrames;
|
|
QMap<int, bool> filters;
|
|
QMap<int, bool> busFilters;
|
|
DBCHandler *dbcHandler;
|
|
QMutex mutex;
|
|
bool interpretFrames; //should we use the dbcHandler?
|
|
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
|
bool filtersPersistDuringClear;
|
|
QString timeFormat;
|
|
bool useHexMode;
|
|
bool timeSeconds;
|
|
bool useSystemTime;
|
|
bool needFilterRefresh;
|
|
bool ignoreDBCColors;
|
|
int64_t timeOffset;
|
|
int lastUpdateNumFrames;
|
|
uint32_t preallocSize;
|
|
bool sortDirAsc;
|
|
};
|
|
|
|
|
|
#endif // CANFRAMEMODEL_H
|
|
|