资源简介
Linux平台USB转CAN设备数据解析代码,可用于车机数据解析。欢迎大家下载!
代码片段和文件信息
#include “CanFile.h“
#include
CanFile::CanFile() {
}
CanFile::~CanFile()
{
}
bool CanFile::load(string radar_path string car_path)
{
cout << “loading radar can file!“ << endl;
LoadCanFile(radar_path radar_can_pack_);
cout << “loading vehicle can file!“ << endl;
LoadCanFile(car_path car_can_pack_);
return true;
}
string CanFile::string_to_hex(const string& str) //transfer string to hex-string
{
string result = “0x“;
result += str;
return result;
}
VCI_CAN_OBJ CanFile::string_to_canfrmae(std::vector str) {
VCI_CAN_OBJ frame;
frame.TimeStamp = trans_to_uint_time(stod(str[0]));
frame.ID = UINT(stof(str[3]) + 0.5);
frame.DataLen = UINT(stoi(str[4]));
for (int i = 0; i < frame.DataLen; i++)
{
string aa = string_to_hex(str[5 + i]);
int b = int(stof(aa) + 0.5);
frame.Data[i] = BYTE(b);
}
return frame;
}
int CanFile::LoadCanFile(string path std::vector & can_pack) {
std::ifstream can_file(path);
if (!can_file) {
cout << “Unable to open can file“;
exit(0); // terminate with error
}
std::string feature; //存储读取的每行数据
string feat_onePoint; //存储每行按空格分开的每一个float数据
std::vector lines; //存储每行数据
can_pack.clear();
int cnt = 0;
while (!can_file.eof())
{
getline(can_file feature); //一次读取一行数据
if (feature.length() <= 0) {
break;
}
stringstream stringin(feature); //使用串流实现对string的输入输出操作
lines.clear();
while (stringin >> feat_onePoint) { //按空格一次读取一个数据存入feat_onePoint
lines.push_back(feat_onePoint); //存储每行按空格分开的数据
}
VCI_CAN_OBJ frame = string_to_canfrmae(lines);
can_pack.push_back(frame); //存储所有数据
//cout << cnt++ << endl;
}
can_file.close();
return 1;
}
double CanFile::updata_radar_obs(double timestamp) {
int a = sizeof(UINT);
UINT obs_time = trans_to_uint_time(timestamp);
double rd_time = 0;
while (last_radar_idx_ < radar_can_pack_.size() &&
radar_can_pack_[last_radar_idx_].TimeStamp < obs_time)
{
can_frame frame = { 0 };
frame.can_id = radar_can_pack_[last_radar_idx_].ID;
frame.can_dlc = radar_can_pack_[last_radar_idx_].DataLen;
memcpy(&frame.data &radar_can_pack_[last_radar_idx_].Data sizeof(frame.data));
frame2Value_ContiRadar(&frame);
radar_msg_.update(frame.can_id g_data_ContiRadar);
rd_time = trans_to_float_time(radar_can_pack_[last_radar_idx_].TimeStamp);
last_radar_idx_++;
}
return rd_time;
}
int CanFile::updata_vehicle_obs(double timestamp) {
UINT obs_time = trans_to_uint_time(timestamp);
while (last_car_idx_ < car_can_pack_.size() &&
car_can_pack_[last_car_idx_].TimeStamp < obs_time)
{
can_frame frame = { 0 };
frame.can_id = car_can_pack_[last_car_idx_].ID;
frame.can_dlc = car_can_pack_[last_car_idx_].DataLen;
memcpy(&frame.data &car_can_pack_[last_car_idx_].Data sizeof(frame.data));
frame2Value_Vehicle(&frame);
car_msg_ = g_data_vehicle;
last_car_idx_++;
}
return 1
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-06-10 04:54 canparse\
文件 554 2018-12-04 07:23 canparse\ContiRadarMsg.h
文件 887 2018-12-04 07:23 canparse\ContiRadarMsg.cpp
文件 1628 2018-12-04 07:23 canparse\CanMatrix_ContiRadar.h
文件 3465 2018-12-04 07:23 canparse\CanMatrix_ContiRadar.cpp
文件 1518 2018-12-04 07:23 canparse\CanMatrix_Car.h
文件 3475 2018-12-04 07:23 canparse\CanMatrix_Car.cpp
文件 2382 2018-12-04 07:23 canparse\CanMatrix.h
文件 4305 2018-12-04 07:23 canparse\CanMatrix.cpp
文件 1256 2018-12-04 07:23 canparse\CanFile.h
文件 3462 2018-12-04 07:23 canparse\CanFile.cpp
目录 0 2019-06-10 04:54 canparse\.vscode\
目录 0 2019-06-10 04:54 canparse\.vscode\ipch\
目录 0 2019-06-10 04:54 canparse\.vscode\ipch\bd7e9afe7fb66268\
文件 1167360 2019-06-10 04:50 canparse\.vscode\ipch\bd7e9afe7fb66268\CanMatrix_Car.ipch
文件 8 2019-06-10 04:50 canparse\.vscode\ipch\bd7e9afe7fb66268\mmap_address.bin
目录 0 2019-06-10 04:54 canparse\.vscode\ipch\a2055dfac254ad02\
文件 60125184 2019-06-10 04:49 canparse\.vscode\ipch\a2055dfac254ad02\CanFile.ipch
文件 8 2019-06-10 04:49 canparse\.vscode\ipch\a2055dfac254ad02\mmap_address.bin
相关资源
- 30篇嵌入式系统论文
- 专业Canoco软件
- BDFACSCanto II_使用说明书
- 深入理解LINUX内核 第二版 深入理解
- linux shell脚本攻略第三版
- 华清远见-嵌入式Linux应用程序开发详
- 精通Linux第2版高清非扫描版
- Linux Shell脚本攻略第3版 超高清完整
- linux内核技术手册中英文版
- Exploring BeagleBone Tools and Techniques for
- 海康威视linux下二次开发
- Linux C编程-GTK+ 2.0 中文教程/使用GTK+
- DWA-171_RTL8811AU_Linux_v4.3.0_10674.20140321
- The Linux Programming Interface 原版pdf by K
- synergy-v1.8.8-stable-linux & windows
- Linux+C编程一站式学习+最新版+pdf+网页
- linux 系统下安装IE必备的三个包wine
- Linux网络数据包抓取源码分析和包过滤
- 《Linux C编程一站式学习》
- X-Scan-v3.3 包含npptools.dll
- USBCAN-2I PC端软件
- 基于嵌入式Linux的视频采集系统设计
- 鸟哥的Linux私房菜-基础学习篇(第四
- canopen入门
- linux c 编程一站式学习高清文字带目录
- howlinuxworks.rar
- RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911
- 鸟哥的Linux私房菜_服务器架设篇(第
- LAMP兄弟连李明老师Linux讲义笔记PPT
- usb那些事的全集
评论
共有 条评论