Additional work on UDS - now UDS scan window can get results from UDS
handler instead of trying to do it all itself.
This commit is contained in:
@@ -7,20 +7,7 @@
|
||||
#include "can_structs.h"
|
||||
#include "mainwindow.h"
|
||||
#include "canframemodel.h"
|
||||
|
||||
//the same as the CANFrame struct but with arbitrary data size.
|
||||
struct ISOTP_MESSAGE
|
||||
{
|
||||
public:
|
||||
uint32_t ID;
|
||||
int bus;
|
||||
bool extended;
|
||||
bool isReceived;
|
||||
int len; //# of bytes this message should have (as reported)
|
||||
int actualSize; //# we actually got
|
||||
QVector<unsigned char> data;
|
||||
uint64_t timestamp;
|
||||
};
|
||||
#include "isotp_message.h"
|
||||
|
||||
class ISOTP_HANDLER : public QObject
|
||||
{
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef ISOTP_MESSAGE_H
|
||||
#define ISOTP_MESSAGE_H
|
||||
|
||||
//the same as the CANFrame struct but with arbitrary data size.
|
||||
class ISOTP_MESSAGE
|
||||
{
|
||||
public:
|
||||
uint32_t ID;
|
||||
int bus;
|
||||
bool extended;
|
||||
bool isReceived;
|
||||
int len; //# of bytes this message should have (as reported)
|
||||
int actualSize; //# we actually got
|
||||
QVector<unsigned char> data;
|
||||
uint64_t timestamp;
|
||||
};
|
||||
|
||||
#endif // ISOTP_MESSAGE_H
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "uds_handler.h"
|
||||
#include "connections/canconmanager.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QDebug>
|
||||
|
||||
QVector<CODE_STRUCT> UDS_SERVICE_DESC = {
|
||||
@@ -143,6 +144,18 @@ UDS_HANDLER::UDS_HANDLER()
|
||||
void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE &msg)
|
||||
{
|
||||
qDebug() << "UDS handler got ISOTP frame";
|
||||
UDS_MESSAGE udsMsg;
|
||||
udsMsg.bus = msg.bus;
|
||||
udsMsg.extended = msg.extended;
|
||||
udsMsg.ID = msg.ID;
|
||||
udsMsg.isReceived = msg.isReceived;
|
||||
udsMsg.timestamp = msg.timestamp;
|
||||
udsMsg.actualSize = msg.actualSize;
|
||||
udsMsg.len = msg.len;
|
||||
udsMsg.service = msg.data.at(0);
|
||||
udsMsg.subFunc = msg.data.at(1);
|
||||
udsMsg.data = msg.data.mid(1, -1); //don't copy data[0] which was service number
|
||||
emit newUDSMessage(udsMsg);
|
||||
}
|
||||
|
||||
void UDS_HANDLER::setReception(bool mode)
|
||||
@@ -177,6 +190,18 @@ void UDS_HANDLER::sendUDSFrame(int bus, int ID, int service, QVector<unsigned ch
|
||||
qDebug() << "Sent UDS service: " << getServiceShortDesc(service) << " on bus " << bus;
|
||||
}
|
||||
|
||||
void UDS_HANDLER::sendUDSFrame(const UDS_MESSAGE &msg)
|
||||
{
|
||||
QVector<unsigned char> data;
|
||||
if (msg.bus < 0) return;
|
||||
if (msg.bus >= CANConManager::getInstance()->getNumBuses()) return;
|
||||
if (msg.service < 0 || msg.service > 0xFF) return;
|
||||
data.append(msg.service);
|
||||
data.append(msg.data);
|
||||
ISOTP_HANDLER::getInstance()->sendISOTPFrame(msg.bus, msg.ID, data);
|
||||
qDebug() << "Sent UDS service: " << getServiceShortDesc(msg.service) << " on bus " << msg.bus;
|
||||
}
|
||||
|
||||
QString UDS_HANDLER::getServiceShortDesc(int service)
|
||||
{
|
||||
foreach (CODE_STRUCT code, UDS_SERVICE_DESC)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include "can_structs.h"
|
||||
#include "isotp_handler.h"
|
||||
#include "isotp_message.h"
|
||||
|
||||
namespace UDS_SERVICES
|
||||
{
|
||||
@@ -68,6 +68,13 @@ struct CODE_STRUCT
|
||||
QString longDesc;
|
||||
};
|
||||
|
||||
class UDS_MESSAGE: public ISOTP_MESSAGE
|
||||
{
|
||||
public:
|
||||
int service;
|
||||
int subFunc;
|
||||
};
|
||||
|
||||
class UDS_HANDLER : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -78,6 +85,7 @@ public:
|
||||
static UDS_HANDLER* getInstance();
|
||||
void setReception(bool mode); //set whether to accept and forward frames or not
|
||||
void sendUDSFrame(int bus, int ID, int service, QVector<unsigned char> payload);
|
||||
void sendUDSFrame(const UDS_MESSAGE &msg);
|
||||
QString getServiceShortDesc(int service);
|
||||
QString getServiceLongDesc(int service);
|
||||
QString getNegativeResponseShort(int respCode);
|
||||
@@ -87,7 +95,7 @@ public slots:
|
||||
void gotISOTPFrame(ISOTP_MESSAGE &msg);
|
||||
|
||||
signals:
|
||||
void newUDSMessage(ISOTP_MESSAGE &msg);
|
||||
void newUDSMessage(UDS_MESSAGE &msg);
|
||||
|
||||
private:
|
||||
QList<ISOTP_MESSAGE> messageBuffer;
|
||||
|
||||
Reference in New Issue
Block a user