使用Qt库解析DBC文件:
结构体:
struct SignalInfo_S
{
QString SignalName;
QString MsgName;
int msgid{};
double scale{};
double offset{};
int startbit{};
int lenth{};
int codetype{};
};
struct MsgInfo_S
{
int MsgID{};
QString MsgName;
QString SendNodeName;
int msgSendType{};
int msgCycleTime{};
};
//解析文件函数
void CCanManager::LoadSignals(QString filename, QList<SignalInfo_S>& inputsiglist, QList<MsgInfo_S>& inputmsglist, \
QList<SignalInfo_S>& outputsiglist, QList<MsgInfo_S>& outputmsglist)
{
#if 1
//打开文件
QFile dbc_file(filename);
if (!dbc_file.open(QIODevice::ReadOnly))
{
return;
}
//每行读取数据
QString linestr;
i