Files
giesCANne/connections/socketcand.h
Andy Huska 1b41decd20 Custom sender is no longer crashing
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
2022-11-01 15:01:07 -05:00

83 lines
1.7 KiB
C++

#ifndef SOCKETCAND_H
#define SOCKETCAND_H
//#include <QSerialPort>
//#include <QCanBusDevice>
#include <QTimer>
#include <QTcpSocket>
#include <QHostAddress>
//#include <QUdpSocket>
/*************/
#include <QDateTime>
/*************/
#include "canframemodel.h"
#include "canconnection.h"
#include "canconmanager.h"
namespace KAYAKSTATE {
enum MODE
{
IDLE, //NO_BUS in socketcand doc
BCM,
SWITCHING2RAW,
RAWMODE,
ISOTP
};
}
using namespace KAYAKSTATE;
class SocketCANd : public CANConnection
{
Q_OBJECT
public:
SocketCANd(QString portName);
virtual ~SocketCANd();
protected:
virtual void piStarted();
virtual void piStop();
virtual void piSetBusSettings(int pBusIdx, CANBus pBus);
virtual bool piGetBusSettings(int pBusIdx, CANBus& pBus);
virtual void piSuspend(bool pSuspend);
virtual bool piSendFrame(const CANFrame&);
void disconnectDevice();
private slots:
void connectDevice();
void checkConnection();
void readTCPData(int busNum);
void invokeReadTCPData();
void deviceConnected(int busNum);
void switchToRawMode(int busNum);
QString decodeFrames(QString, int busNum);
private:
void procRXData(QString, int busNum);
void sendBytesToTCP(const QByteArray &bytes, int busNum);
void sendStringToTCP(const char* data, int busNum);
void sendDebug(const QString debugText);
protected:
QTimer mTimer;
bool reconnecting;
QVarLengthArray<QTcpSocket*> tcpClient;
QHostAddress hostIP;
int hostPort;
QList<QString> hostCanIDs;
int framesRapid;
QVarLengthArray<MODE> rx_state;
CANFrame buildFrame;
QVarLengthArray<QString> unprocessedData;
};
#endif // SOCKETCAND_H