├── pharse ├── 2018_5_3_10_23_23 .csv ├── bin └── Debug │ ├── 2018_5_14_15_54_54.csv │ ├── train.csv │ ├── dbc_load_0 │ ├── __pycache__ │ └── test01.cpython-35.pyc │ ├── cantest.sh │ ├── motohawk.dbc │ ├── test01.py │ ├── Huanghonglei.dbc │ └── Tx2TryDBC.dbc ├── BO_Index.c ├── canbus.h ├── package.c ├── pharse.c ├── dbc_timer.c ├── obj └── Debug │ ├── MySql.o │ ├── main.o │ ├── menu.o │ ├── BO_Index.o │ ├── GetTime.o │ ├── canbus.o │ ├── package.o │ ├── pharse.o │ └── dbc_timer.o ├── menu.h ├── main.h ├── GetTime.h ├── pharse.h ├── menu.c ├── PyCall.h ├── BO_Index.h ├── ssh_key.pub ├── GetTime.c ├── package.h ├── .gitignore ├── MySql.h ├── motohawk.dbc ├── dbc_timer.h ├── BO.h ├── ssh_key ├── dbc_load_0.2.layout ├── can_dbc_0.2.cbp ├── dbc_load_0.2.cbp ├── dbc_load_0.1.layout ├── can_dbc_0.2.layout ├── dbc_load_0.1.depend ├── PyCall.c ├── dbc_load_0.2.depend ├── Tx2TryDBC_define.h ├── can_dbc_0.2.depend ├── main.c ├── README.md ├── Huanghonglei.dbc ├── MySql.c └── canbus.c /pharse: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2018_5_3_10_23_23 .csv: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/Debug/2018_5_14_15_54_54.csv: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BO_Index.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/BO_Index.c -------------------------------------------------------------------------------- /canbus.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/canbus.h -------------------------------------------------------------------------------- /package.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/package.c -------------------------------------------------------------------------------- /pharse.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/pharse.c -------------------------------------------------------------------------------- /bin/Debug/train.csv: -------------------------------------------------------------------------------- 1 | P,I,D 2 | 14.146756860967635,5.109532918173506,2.326863284912136 3 | -------------------------------------------------------------------------------- /dbc_timer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/dbc_timer.c -------------------------------------------------------------------------------- /obj/Debug/MySql.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/MySql.o -------------------------------------------------------------------------------- /obj/Debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/main.o -------------------------------------------------------------------------------- /obj/Debug/menu.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/menu.o -------------------------------------------------------------------------------- /bin/Debug/dbc_load_0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/bin/Debug/dbc_load_0 -------------------------------------------------------------------------------- /obj/Debug/BO_Index.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/BO_Index.o -------------------------------------------------------------------------------- /obj/Debug/GetTime.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/GetTime.o -------------------------------------------------------------------------------- /obj/Debug/canbus.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/canbus.o -------------------------------------------------------------------------------- /obj/Debug/package.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/package.o -------------------------------------------------------------------------------- /obj/Debug/pharse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/pharse.o -------------------------------------------------------------------------------- /obj/Debug/dbc_timer.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/obj/Debug/dbc_timer.o -------------------------------------------------------------------------------- /menu.h: -------------------------------------------------------------------------------- 1 | #ifndef __MENU_H__ 2 | #define __MENU_H__ 3 | int menu(); 4 | void print_usage(); 5 | 6 | #endif // __MENU_H__ 7 | -------------------------------------------------------------------------------- /bin/Debug/__pycache__/test01.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HongleiHuang-amd/LinuxCanbusTool/HEAD/bin/Debug/__pycache__/test01.cpython-35.pyc -------------------------------------------------------------------------------- /bin/Debug/cantest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo ***canbus test script 3 | ip -details -statistics link show can0 4 | ip -details -statistics link show can1 5 | 6 | -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAIN_H__ 2 | #define __MAIN_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include //sockaddr_can 9 | #include 10 | #endif // MAIN_H_INCLUDED 11 | -------------------------------------------------------------------------------- /GetTime.h: -------------------------------------------------------------------------------- 1 | #ifndef __GETTIME_H__ 2 | #define __GETTIME_H__ 3 | 4 | #include 5 | #include 6 | 7 | time_t timeSaved; 8 | struct tm *timeDate; 9 | 10 | void GetTime(time_t *t, struct tm *date, char *strDate); 11 | 12 | 13 | #endif // __GETTIME_H__ 14 | -------------------------------------------------------------------------------- /pharse.h: -------------------------------------------------------------------------------- 1 | #ifndef __PHARSE_H__ 2 | #define __PHARSE_H__ 3 | #include "main.h" 4 | #include "BO.h" 5 | void pharse(struct can_frame *frame,BO_Unit_t **BO_List); 6 | void pharse2(struct can_frame *frame,BO_Unit_t **BO_List); 7 | void parse3(struct can_frame *frame,BO_Unit_t **BO_List); 8 | //#define SHOW 9 | #endif // __PHARSE_H__ 10 | -------------------------------------------------------------------------------- /menu.c: -------------------------------------------------------------------------------- 1 | #include "menu.h" 2 | #include 3 | #include 4 | 5 | 6 | int menu(void) 7 | { 8 | printf("1234"); 9 | return 0; 10 | 11 | } 12 | 13 | void print_usage() 14 | { 15 | fprintf(stderr, "Usage: ./can_dbc \n"); 16 | 17 | } 18 | 19 | void print_state() 20 | { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /PyCall.h: -------------------------------------------------------------------------------- 1 | #ifndef __PYCALL_H__ 2 | #define __PYCALL_H__ 3 | 4 | typedef struct pyCallTask{ 5 | char *fileName; 6 | char *module; 7 | char *fun; 8 | }pyCallTask_t; 9 | 10 | 11 | int PyInit(); 12 | int PyReadcsv(char *m); 13 | int PyCallfun(char* module, char* fun, char* arg); 14 | void * PyProcessThread(void* arg); 15 | #endif // __PYCALL_H__ 16 | -------------------------------------------------------------------------------- /BO_Index.h: -------------------------------------------------------------------------------- 1 | #ifndef __BO_INDEX_H__ 2 | #define __BO_INDEX_H__ 3 | char * Detect_BO(FILE * fptr,char * rdbuf); 4 | 5 | int Get_BO_Index(const char * bo,BO_Unit_t *boptr); 6 | 7 | int Get_SG_Index(FILE * fptr,char * rdbuf,BO_Unit_t *boptr); 8 | 9 | int Free_BO_(int BO_Number); 10 | 11 | int Dbc_load(FILE * dbc_cfg_fd,char *dbc_cfg_rdbuf,BO_Unit_t **BO_List); 12 | #endif // BO_INDEX_H_INCLUDED 13 | -------------------------------------------------------------------------------- /ssh_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiOwEVr9HXgMRRblj976yi5ejdsCKm21ZsA2d2tqz/HvHfFdeaiZkzotncw7uh81FYN6Pihya9JtmAz5Q7z79D4xEcEHE1/k1ZbzSvqcAcmvIzZPf0sgMzW7bnqOr96Ureiik9h+42TirLesI+t6DUcOTx1/+XCgAMsfX9A4wsl/YAnd78eIPkQAxbYUN5bG7O5vcSb2MzWkEyVrahRyeg0uPb8EbTjCEVuFxnv/OpQFY3hTWPnqdvjlzGeCiaQs07S0C005HCU8CqED0WQ4SjVjnDxeIsKHWCzBz0oHnKF032lJWPzc7j+FG+sxr4BD3CYrjr73Gb4/ilrjc4SVYp 1248832396@qq.com 2 | -------------------------------------------------------------------------------- /GetTime.c: -------------------------------------------------------------------------------- 1 | #include "GetTime.h" 2 | 3 | 4 | void GetTime(time_t *t, struct tm *date, char *strDate) 5 | { 6 | time(t); 7 | date = localtime(t); 8 | //printf("%d_%d_%d_%d:%d:%d\n",date->tm_year+1900,date->tm_mon+1,date->tm_mday,date->tm_hour,date->tm_min,date->tm_min); 9 | sprintf(strDate,"%d_%d_%d_%d_%d_%d",date->tm_year+1900,date->tm_mon+1,date->tm_mday,date->tm_hour,date->tm_min,date->tm_min); 10 | //printf(">>>%s",strDate); 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /package.h: -------------------------------------------------------------------------------- 1 | #ifndef __PACKAGE_H__ 2 | #define __PACKAGE_H__ 3 | #include "main.h" 4 | #include "BO.h" 5 | int package(struct can_frame *frame_send,BO_Unit_t **BO_List,unsigned int BO_ID,unsigned char SG_START,double value_send); 6 | 7 | int package_bo(struct can_frame *frame_send,BO_Unit_t **BO_List,unsigned int BO_ID); 8 | 9 | int package_bo2(struct can_frame *frame_send,BO_Unit_t **BO_List,unsigned int BO_ID); 10 | 11 | int package_bo3(struct can_frame *frame_send,BO_Unit_t **BO_List,unsigned int BO_ID); 12 | 13 | #endif // __PACKAGE_H__ 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /MySql.h: -------------------------------------------------------------------------------- 1 | #ifndef __MYSQL_H__ 2 | #define __MYSQL_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "BO.h" 9 | 10 | #define MAX_BUF_SIZE 4096 11 | 12 | 13 | 14 | MYSQL *g_conn; 15 | MYSQL_RES *g_res; 16 | MYSQL_ROW g_row; 17 | 18 | typedef struct mySqlTask 19 | { 20 | char* sqlbuf; 21 | char* tableName; 22 | BO_Unit_t** boList; 23 | }mySqlTask_t; 24 | 25 | typedef struct csvTask 26 | { 27 | FILE ** fptr; 28 | }csvTask_t; 29 | 30 | typedef struct csvFileList 31 | { 32 | char fileNameList[10][50]; 33 | unsigned short counter; 34 | }csvFileList_t; 35 | 36 | void print_mysql_error(const char *msg); 37 | 38 | int executesql(const char *sql); 39 | 40 | int init_mysql(); 41 | 42 | void CanbusMySqlTest(); 43 | 44 | void RecordDataCsv(); 45 | 46 | FILE * recordFile; 47 | #endif // MYSQL_H_INCLUDED 48 | -------------------------------------------------------------------------------- /motohawk.dbc: -------------------------------------------------------------------------------- 1 | VERSION "1.0" 2 | 3 | NS_ : 4 | NS_DESC_ 5 | CM_ 6 | BA_DEF_ 7 | BA_ 8 | VAL_ 9 | CAT_DEF_ 10 | CAT_ 11 | FILTER 12 | BA_DEF_DEF_ 13 | EV_DATA_ 14 | ENVVAR_DATA_ 15 | SGTYPE_ 16 | SGTYPE_VAL_ 17 | BA_DEF_SGTYPE_ 18 | BA_SGTYPE_ 19 | SIG_TYPE_REF_ 20 | VAL_TABLE_ 21 | SIG_GROUP_ 22 | SIG_VALTYPE_ 23 | SIGTYPE_VALTYPE_ 24 | BO_TX_BU_ 25 | BA_DEF_REL_ 26 | BA_REL_ 27 | BA_DEF_DEF_REL_ 28 | BU_SG_REL_ 29 | BU_EV_REL_ 30 | BU_BO_REL_ 31 | SG_MUL_VAL_ 32 | 33 | BS_: 34 | 35 | BU_: PCM1 FOO 36 | 37 | BO_ 496 ExampleMessage: 8 PCM1 38 | SG_ Temperature : 0|12@0- (0.01,250) [229.53|270.47] "degK" Vector__XXX, FOO 39 | SG_ AverageRadius : 6|6@0+ (0.1,0) [0.0|5.0] "m" Vector__XXX 40 | SG_ Enable : 7|1@0+ (1.0,0) [0.0|0.0] "-" Vector__XXX 41 | 42 | CM_ BO_ 496 "Example message used as template in MotoHawk models."; 43 | CM_ SG_ 496 AverageRadius ""; 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | VAL_ 496 Enable 0 "Disabled" 1 "Enabled" ; 52 | -------------------------------------------------------------------------------- /bin/Debug/motohawk.dbc: -------------------------------------------------------------------------------- 1 | VERSION "1.0" 2 | 3 | NS_ : 4 | NS_DESC_ 5 | CM_ 6 | BA_DEF_ 7 | BA_ 8 | VAL_ 9 | CAT_DEF_ 10 | CAT_ 11 | FILTER 12 | BA_DEF_DEF_ 13 | EV_DATA_ 14 | ENVVAR_DATA_ 15 | SGTYPE_ 16 | SGTYPE_VAL_ 17 | BA_DEF_SGTYPE_ 18 | BA_SGTYPE_ 19 | SIG_TYPE_REF_ 20 | VAL_TABLE_ 21 | SIG_GROUP_ 22 | SIG_VALTYPE_ 23 | SIGTYPE_VALTYPE_ 24 | BO_TX_BU_ 25 | BA_DEF_REL_ 26 | BA_REL_ 27 | BA_DEF_DEF_REL_ 28 | BU_SG_REL_ 29 | BU_EV_REL_ 30 | BU_BO_REL_ 31 | SG_MUL_VAL_ 32 | 33 | BS_: 34 | 35 | BU_: PCM1 FOO 36 | 37 | BO_ 496 ExampleMessage: 8 PCM1 38 | SG_ Temperature : 0|12@0- (0.01,250) [229.53|270.47] "degK" Vector__XXX, FOO 39 | SG_ AverageRadius : 6|6@0+ (0.1,0) [0.0|5.0] "m" Vector__XXX 40 | SG_ Enable : 7|1@0+ (1.0,0) [0.0|0.0] "-" Vector__XXX 41 | 42 | CM_ BO_ 496 "Example message used as template in MotoHawk models."; 43 | CM_ SG_ 496 AverageRadius ""; 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | VAL_ 496 Enable 0 "Disabled" 1 "Enabled" ; 52 | -------------------------------------------------------------------------------- /dbc_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __DBC_TIMER_H__ 2 | #define __DBC_TIMER_H__ 3 | 4 | #define _10msTask 1 5 | #define _20msTask 2 6 | #define _50msTask 3 7 | #define _100msTask 4 8 | #include "canbus.h" 9 | 10 | typedef struct{ 11 | 12 | pthread_cond_t _10msThreadReady; 13 | pthread_cond_t _20msThreadReady; 14 | pthread_cond_t _50msThreadReady; 15 | pthread_cond_t _100msThreadReady; 16 | int threadStop; 17 | pthread_mutex_t timerThreadLock; 18 | pthread_t *timerRoutineThread; 19 | 20 | } TimerThread_t; 21 | 22 | typedef struct taskArg{ 23 | canBus_t * can; 24 | unsigned int boId; 25 | }taskArg_t; 26 | 27 | typedef struct TaskAdd{ 28 | void(*task)(taskArg_t *); 29 | int canID; 30 | taskArg_t arg; 31 | }TaskAdd_t; 32 | 33 | TimerThread_t* TimerRoutineInit(void); 34 | 35 | TimerThread_t* timerThread; 36 | 37 | 38 | /* 39 | Task->task is the thread to be run 40 | Task->canID is the parameter of the task 41 | */ 42 | pthread_t AddTimerTask(TaskAdd_t * Task, int Type); 43 | 44 | void TimerCtl(int on_off); 45 | 46 | //void _100MsTask(void (*fun)(void)); 47 | 48 | #endif // __DBC_TIMER_H__ 49 | -------------------------------------------------------------------------------- /BO.h: -------------------------------------------------------------------------------- 1 | #ifndef __BO_H__ 2 | #define __BO_H__ 3 | 4 | #define BOFLAG "BO_ " 5 | #define SGFLAG " SG_ " 6 | //#define DEBUG //show BO something.... 7 | //#define DEBUGLINE 8 | //#define DEBUGPARSE //start size offset /..debug inf 9 | 10 | typedef enum bit_order_t{motorola,intel} bit_order; 11 | typedef enum val_type_t{unsigned_value,signed_value}VALUE_TYPE; 12 | 13 | typedef struct SG_{ 14 | char signal_name[50]; 15 | char multiplexer_indicator; 16 | int start_bit; 17 | unsigned int signal_size; 18 | bit_order Bit_order; //0 :motorola 1:intel 19 | VALUE_TYPE val_type; //+:unsigned(0) -:signed(1) 20 | double facator; 21 | double offset; 22 | double minimum; 23 | double maximum; 24 | char unit[20]; 25 | char receiver[20]; 26 | struct SG_ *next; //NOT USED 27 | double value; 28 | double value_send; 29 | }SG_t; 30 | 31 | //struct of every msg 32 | typedef struct BO_Unit{ 33 | unsigned int message_id; //msg id 0x123.... 34 | unsigned int message_size; //DLC MAX 8byte 35 | char transmitter[50]; 36 | char message_name[100]; 37 | SG_t *First_SG; 38 | struct SG_ *SG_List[50]; 39 | }BO_Unit_t; 40 | BO_Unit_t * BO_List[50]; //dbc list 41 | #endif 42 | -------------------------------------------------------------------------------- /bin/Debug/test01.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.5 2 | import time 3 | import csv 4 | import random 5 | 6 | 7 | train_file_name = 'train.csv' 8 | 9 | class Hello: 10 | def __init__(self, x): 11 | self.a = x 12 | def print(self, x=None): 13 | print(x) 14 | 15 | 16 | def xprint(): 17 | print("read file!") 18 | fptr = open('testfile.csv', 'r') 19 | print(fptr.readlines()) 20 | return 666 21 | 22 | 23 | 24 | def readcsv(filename): 25 | data_inedx = [] 26 | data_name = [] 27 | print("filenameis:") 28 | print(filename) 29 | 30 | fptr = open(filename, 'r') 31 | lines_list = fptr.readline() 32 | #print(lines_list) 33 | 34 | print("processing!") 35 | 36 | data_name.append('P') 37 | data_name.append('I') 38 | data_name.append('D') 39 | data_inedx.append(random.uniform(0, 100)) 40 | data_inedx.append(random.uniform(5, 10)) 41 | data_inedx.append(random.uniform(1, 5)) 42 | 43 | 44 | 45 | datas = [data_name,data_inedx] 46 | with open('train.csv','w+') as f: 47 | writer = csv.writer(f) 48 | for row in datas: 49 | writer.writerow(row) 50 | 51 | return 0 52 | 53 | 54 | 55 | 56 | 57 | if __name__ == "__main__": 58 | #xprint() 59 | ##h = Hello(5) 60 | ##print() 61 | readcsv('testfile.csv') 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /ssh_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpQIBAAKCAQEAojsBFa/R14DEUW5Y/e+souXo3bAipttWbANndras/x7x3xXX 3 | momZM6LZ3MO7ofNRWDej4ocmvSbZgM+UO8+/Q+MRHBBxNf5NWW80r6nAHJryM2T3 4 | 9LIDM1u256jq/elK3oopPYfuNk4qy3rCPreg1HDk8df/lwoADLH1/QOMLJf2AJ3e 5 | /HiD5EAMW2FDeWxuzub3Em9jM1pBMla2oUcnoNLj2/BG04whFbhcZ7/zqUBWN4U1 6 | j56nb45cxngomkLNO0tAtNORwlPAqhA9FkOEo1Y5w8XiLCh1gswc9KB5yhdN9pSV 7 | j83O4/hRvrMa+AQ9wmK46+9xm+P4pa43OElWKQIDAQABAoIBAHrMvx1zYRwHVJNv 8 | O928Nql37rUgRpqXHOvWB9NMo9bZzaxYFEPeNCFp/A+n+be1PrXQKDWoqCI17h4b 9 | AtHjh5wTnTfpGkkMnfA8xVzS2aDNiNhubWLD/Lg7jE//BSH+HbYmTuFMq3xf3vT3 10 | j2F6DjvA2QxXvBjQcQkrDFDhBpIZoITnm214PMkUbCtT/TjYd0k603J2xwwyEb4W 11 | 8/17DKnIv8CXlgc/Mg2er0asDGjUUTJhRYP1OL0Ap8pRavVNhn6TtzhmycvhHNMc 12 | HDJXSccr4Qp8vZ58BmhdjXp/q+dVcfnaFvznALfxtaSNlBIrJefcqS1jx/zjRFva 13 | nkTFuAECgYEAzxXZcDt1MgNBBLTgFeL68D30/cDFi/SshxyGOt5A2qHyj6lgM2JC 14 | XvNuw3aprOYNHoN0Kwtdur6Z0b6MBIS0o8m35Yg1EnI9mwybg9JdwBcF0daQn2sa 15 | I/3X+TBoLe1yu+GEBzmLiojG+wSsw1rJeLAXTxPPxa7gTVD4Acn7fEkCgYEAyIzY 16 | qPAOs9aWJG0pKJFA5yEDqRPZrkaukC51B4aB+b4oJ5AdcDaDtsGOWcqX7rh2aryZ 17 | e+/oQ6oYT7Dj5fV5tPYVszYKxeTmK/Nx64PzqLsZvsu9CsxRYQ+FwiFe3Q/JTmwH 18 | Q0nXxHcBYS4uLYGS09XiIn7XxNuTaZyiF7W0SuECgYEAtpCrpk80zceinXScjY8S 19 | 7ZOhlchKIE2vgFn8WI+yG01k25RWFFbO7oisILRPd/dEn58CXiRiGI2KbCgRprYb 20 | zr26WygOqdl/SF8AB2IBdqSVY95Gl9TDMfHLYotzfPH2EX8Kd5ga1iIpUglYCc3T 21 | CowrsHJl3QCEDIWSb3lTNckCgYEAmGV3KoEpGv3AoDOXaC1gvYH37x6XdvhdJFE5 22 | Oxu6XxZiGxZHWIMEefcBfjgWViA0VA23MFfxDqIN0VjhBVkRQDMT8Ffrvc+gHNvk 23 | wIxHtvtep/7YS4FRgcky4n9LP/8EASTULAzL+o5YLQnTq17gPTs1mPL8capNjZ6q 24 | CgxY0eECgYEAlHOUB7rfXO1pHAyj1jIZY2dAGIbetfLcEwhh5H1xDS9Y/8c9zcDy 25 | bub5XoDIcXd6t4sLd+Eo/aN3m8igwiSJa4g0Bd9dNoFCnbKB0rdcVLZJV70P8ByV 26 | GWF3aW43KGni87jmA1MHHi+xm8z9Llj+9e0cZAjUGfM0KVorePbTLsI= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /dbc_load_0.2.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /can_dbc_0.2.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 88 | 89 | -------------------------------------------------------------------------------- /dbc_load_0.2.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 90 | 91 | -------------------------------------------------------------------------------- /dbc_load_0.1.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /can_dbc_0.2.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /dbc_load_0.1.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1523523453 source:/home/hhl2/dbc/dbc_load_0.1/main.c 3 | 4 | 5 | 6 | 7 | "BO.h" 8 | "BO_Index.h" 9 | "menu.h" 10 | "canbus.h" 11 | "main.h" 12 | "pharse.h" 13 | "package.h" 14 | 15 | 1523178827 source:/home/hhl2/dbc/dbc_load_0.1/BO_Index.c 16 | 17 | 18 | 19 | "BO.h" 20 | "BO_Index.h" 21 | 22 | 1523495757 /home/hhl2/dbc/dbc_load_0.1/BO.h 23 | 24 | 1523178735 /home/hhl2/dbc/dbc_load_0.1/BO_Index.h 25 | 26 | 1523410226 /home/hhl2/dbc/dbc_load_0.1/menu.h 27 | 28 | 1523502917 source:/home/hhl2/dbc/dbc_load_0.1/menu.c 29 | "menu.h" 30 | 31 | 32 | 33 | 1523176153 source:/home/hhl2/dbc/dbc_load_0.1/canbus.c 34 | "main.h" 35 | "canbus.h" 36 | 37 | 1523519284 /home/hhl2/dbc/dbc_load_0.1/main.h 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 1523176168 /home/hhl2/dbc/dbc_load_0.1/canbus.h 46 | 47 | 48 | 49 | 50 | 51 | 1523523295 source:/home/hhl2/dbc/dbc_load_0.1/pharse.c 52 | "pharse.h" 53 | 54 | 1523523448 /home/hhl2/dbc/dbc_load_0.1/pharse.h 55 | "main.h" 56 | "BO.h" 57 | 58 | 1523522048 source:/home/hhl2/dbc/dbc_load_0.1/package.c 59 | "package.h" 60 | 61 | 1523521675 /home/hhl2/dbc/dbc_load_0.1/package.h 62 | "main.h" 63 | "BO.h" 64 | 65 | 1523178827 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/BO_Index.c 66 | 67 | 68 | 69 | "BO.h" 70 | "BO_Index.h" 71 | 72 | 1523856769 /home/nvidia/hhl2/dbc/dbc_load_0.1/BO.h 73 | 74 | 1523178735 /home/nvidia/hhl2/dbc/dbc_load_0.1/BO_Index.h 75 | 76 | 1523944523 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/canbus.c 77 | "main.h" 78 | "canbus.h" 79 | 80 | 1523519284 /home/nvidia/hhl2/dbc/dbc_load_0.1/main.h 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 1523951462 /home/nvidia/hhl2/dbc/dbc_load_0.1/canbus.h 89 | 90 | 91 | 92 | 93 | 94 | 1524017495 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/main.c 95 | 96 | 97 | 98 | 99 | 100 | "BO.h" 101 | "BO_Index.h" 102 | "menu.h" 103 | "canbus.h" 104 | "main.h" 105 | "pharse.h" 106 | "package.h" 107 | "Tx2TryDBC_define.h" 108 | "dbc_timer.h" 109 | 110 | 1523410226 /home/nvidia/hhl2/dbc/dbc_load_0.1/menu.h 111 | 112 | 1523864945 /home/nvidia/hhl2/dbc/dbc_load_0.1/pharse.h 113 | "main.h" 114 | "BO.h" 115 | 116 | 1523867185 /home/nvidia/hhl2/dbc/dbc_load_0.1/package.h 117 | "main.h" 118 | "BO.h" 119 | 120 | 1523502917 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/menu.c 121 | "menu.h" 122 | 123 | 124 | 125 | 1523866970 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/package.c 126 | "package.h" 127 | 128 | 1523864941 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/pharse.c 129 | "pharse.h" 130 | 131 | 1523936528 /home/nvidia/hhl2/dbc/dbc_load_0.1/Tx2TryDBC_define.h 132 | 133 | 1524017457 source:/home/nvidia/hhl2/dbc/dbc_load_0.1/dbc_timer.c 134 | 135 | 136 | 137 | 138 | 139 | "dbc_timer.h" 140 | "canbus.h" 141 | 142 | 1524017280 /home/nvidia/hhl2/dbc/dbc_load_0.1/dbc_timer.h 143 | 144 | -------------------------------------------------------------------------------- /PyCall.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "PyCall.h" 3 | #include "stdio.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define CSV_MAX_LINE_SIZE 4096 11 | 12 | #define PYSHOW 1 13 | 14 | 15 | int FileSize(char *filename) 16 | { 17 | struct stat statbuf; 18 | int ret; 19 | ret = stat(filename, &statbuf); 20 | if(ret != 0) 21 | return -1; 22 | return statbuf.st_size; 23 | } 24 | 25 | /*init python*/ 26 | int PyInit() 27 | { 28 | Py_Initialize(); 29 | PyRun_SimpleString("import sys"); 30 | PyRun_SimpleString("sys.path.append('./')"); 31 | //pyThreadRun = 1; //enable pyThread 32 | return 0; 33 | } 34 | 35 | /*let pythin read .csv fiel*/ 36 | int PyReadcsv(char *m) 37 | { 38 | PyObject *pModule = NULL, *pArg = NULL, *result = NULL, *pFunc =NULL; 39 | pModule = PyImport_ImportModule(m);//import *.py 40 | 41 | pFunc = PyObject_GetAttrString(pModule, "testprint"); 42 | pArg = Py_BuildValue("(s)","just for show!"); 43 | PyObject_CallObject(pFunc,pArg); 44 | // pFunc = PyObject_GetAttrString(pModule, "xprint");//get .py function 45 | // pArg = Py_BuildValue("(filename)","testfile.csv");//build arg 46 | // result = PyObject_CallFunction(pFunc,NULL);//execute py function 47 | int ret; 48 | PyArg_Parse(result, "i", &ret); 49 | printf(">>>%d\n",ret); 50 | return 0; 51 | } 52 | 53 | /* 54 | the function to call py function 55 | module: *.py name 56 | fun: the function of .py 57 | arg:the arguement of fun Attention:must be str/char* 58 | */ 59 | int PyCallfun(char* module, char* fun, char* arg) 60 | { 61 | PyObject *pModule = NULL, *pArg = NULL, *result = NULL, *pFunc =NULL; 62 | int ret; 63 | pModule = PyImport_ImportModule(module);//import *.py 64 | pFunc = PyObject_GetAttrString(pModule, fun); 65 | pArg = Py_BuildValue("(s)",arg); 66 | result = PyObject_CallObject(pFunc,pArg); 67 | PyArg_Parse(result, "i", &ret); 68 | return ret; 69 | } 70 | 71 | double readCsv(char* csvName, char* indexName) 72 | { 73 | int counter = 0; 74 | char line[CSV_MAX_LINE_SIZE]; 75 | FILE * f; 76 | if(NULL == (f = fopen(csvName,"r+"))) 77 | { 78 | printf("csv open error!\n"); 79 | return -1; 80 | } 81 | fgets(line, CSV_MAX_LINE_SIZE, f); 82 | char *p = strtok(line, ","); 83 | if(p) 84 | { 85 | //printf(">>>%s\n",p); 86 | counter++; 87 | if(!strcmp(p,indexName)) 88 | goto process; 89 | } 90 | else 91 | { 92 | printf("open csv err\n"); 93 | return -1; 94 | } 95 | while(1) 96 | { 97 | p = strtok(NULL,","); 98 | if(p) 99 | { 100 | counter++; 101 | //printf(">>>%d",counter); 102 | //printf("%s\n",p); 103 | if(!strcmp(p,indexName)) 104 | break; 105 | } 106 | else 107 | { 108 | break; 109 | } 110 | } 111 | process: 112 | memset(line,0,CSV_MAX_LINE_SIZE); 113 | fgets(line, CSV_MAX_LINE_SIZE, f); 114 | p = strtok(line, ","); 115 | if(p) 116 | counter--; 117 | int i ; 118 | for(i = 0;i>%s\n",p); 122 | } 123 | double ret = 0; 124 | ret = atof(p); 125 | fclose(f); 126 | return ret; 127 | } 128 | 129 | 130 | 131 | int readTrain() 132 | { 133 | printf(">>>P:%lf\n",readCsv("train.csv","P")); 134 | printf(">>>I:%lf\n",readCsv("train.csv","I")); 135 | printf(">>>D:%lf\n",readCsv("train.csv","D")); 136 | 137 | return 0; 138 | } 139 | 140 | 141 | void * PyProcessThread(void* arg) 142 | { 143 | 144 | pyCallTask_t *pytask = (pyCallTask_t*)arg; 145 | int ret = PyCallfun(pytask->module, pytask->fun, pytask->fileName); 146 | 147 | #ifdef PYSHOW 148 | printf("ret is %d\n",ret); 149 | printf("PY done!\n"); 150 | 151 | #endif // PYSHOW 152 | readTrain(); 153 | return NULL; 154 | } 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /dbc_load_0.2.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1523178827 source:/home/nvidia/hhl2/dbc_load_0.2/BO_Index.c 3 | 4 | 5 | 6 | "BO.h" 7 | "BO_Index.h" 8 | 9 | 1523856769 /home/nvidia/hhl2/dbc_load_0.2/BO.h 10 | 11 | 1523178735 /home/nvidia/hhl2/dbc_load_0.2/BO_Index.h 12 | 13 | 1523944523 source:/home/nvidia/hhl2/dbc_load_0.2/canbus.c 14 | "main.h" 15 | "canbus.h" 16 | 17 | 1523519284 /home/nvidia/hhl2/dbc_load_0.2/main.h 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 1523951462 /home/nvidia/hhl2/dbc_load_0.2/canbus.h 26 | 27 | 28 | 29 | 30 | 31 | 1524099064 source:/home/nvidia/hhl2/dbc_load_0.2/dbc_timer.c 32 | 33 | 34 | 35 | 36 | 37 | "dbc_timer.h" 38 | "canbus.h" 39 | 40 | 1524020649 /home/nvidia/hhl2/dbc_load_0.2/dbc_timer.h 41 | 42 | 1524039885 source:/home/nvidia/hhl2/dbc_load_0.2/main.c 43 | 44 | 45 | 46 | 47 | 48 | 49 | "BO.h" 50 | "BO_Index.h" 51 | "menu.h" 52 | "canbus.h" 53 | "main.h" 54 | "pharse.h" 55 | "package.h" 56 | "Tx2TryDBC_define.h" 57 | "dbc_timer.h" 58 | 59 | 1523410226 /home/nvidia/hhl2/dbc_load_0.2/menu.h 60 | 61 | 1523864945 /home/nvidia/hhl2/dbc_load_0.2/pharse.h 62 | "main.h" 63 | "BO.h" 64 | 65 | 1523867185 /home/nvidia/hhl2/dbc_load_0.2/package.h 66 | "main.h" 67 | "BO.h" 68 | 69 | 1523936528 /home/nvidia/hhl2/dbc_load_0.2/Tx2TryDBC_define.h 70 | 71 | 1523502917 source:/home/nvidia/hhl2/dbc_load_0.2/menu.c 72 | "menu.h" 73 | 74 | 75 | 76 | 1523866970 source:/home/nvidia/hhl2/dbc_load_0.2/package.c 77 | "package.h" 78 | 79 | 1523864941 source:/home/nvidia/hhl2/dbc_load_0.2/pharse.c 80 | "pharse.h" 81 | 82 | 1524448107 source:/home/nvidia/dbc_load_0.2/BO_Index.c 83 | 84 | 85 | 86 | "BO.h" 87 | "BO_Index.h" 88 | 89 | 1524102134 /home/nvidia/dbc_load_0.2/BO.h 90 | 91 | 1523178735 /home/nvidia/dbc_load_0.2/BO_Index.h 92 | 93 | 1525314743 source:/home/nvidia/dbc_load_0.2/canbus.c 94 | "main.h" 95 | "canbus.h" 96 | "BO.h" 97 | "pharse.h" 98 | 99 | "dbc_timer.h" 100 | "package.h" 101 | 102 | 1523519284 /home/nvidia/dbc_load_0.2/main.h 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 1525318044 /home/nvidia/dbc_load_0.2/canbus.h 111 | 112 | 113 | 114 | 115 | 116 | 1523864945 /home/nvidia/dbc_load_0.2/pharse.h 117 | "main.h" 118 | "BO.h" 119 | 120 | 1524106662 /home/nvidia/dbc_load_0.2/dbc_timer.h 121 | "canbus.h" 122 | 123 | 1523867185 /home/nvidia/dbc_load_0.2/package.h 124 | "main.h" 125 | "BO.h" 126 | 127 | 1525310317 source:/home/nvidia/dbc_load_0.2/dbc_timer.c 128 | 129 | 130 | 131 | 132 | 133 | "dbc_timer.h" 134 | "canbus.h" 135 | 136 | 1524809340 source:/home/nvidia/dbc_load_0.2/GetTime.c 137 | "GetTime.h" 138 | 139 | 1524792071 /home/nvidia/dbc_load_0.2/GetTime.h 140 | 141 | 142 | 143 | 1523502917 source:/home/nvidia/dbc_load_0.2/menu.c 144 | "menu.h" 145 | 146 | 147 | 148 | 1523410226 /home/nvidia/dbc_load_0.2/menu.h 149 | 150 | 1525760237 source:/home/nvidia/dbc_load_0.2/MySql.c 151 | "MySql.h" 152 | "GetTime.h" 153 | "canbus.h" 154 | "pharse.h" 155 | "sys/time.h" 156 | 157 | 158 | 159 | 160 | 161 | 1525316186 /home/nvidia/dbc_load_0.2/MySql.h 162 | 163 | 164 | 165 | 166 | "BO.h" 167 | 168 | 1524449581 source:/home/nvidia/dbc_load_0.2/package.c 169 | "package.h" 170 | 171 | 1525310432 source:/home/nvidia/dbc_load_0.2/pharse.c 172 | "pharse.h" 173 | 174 | 1525314925 source:/home/nvidia/dbc_load_0.2/main.c 175 | 176 | 177 | 178 | 179 | 180 | 181 | "BO.h" 182 | "BO_Index.h" 183 | "menu.h" 184 | "canbus.h" 185 | "main.h" 186 | "pharse.h" 187 | "package.h" 188 | "Tx2TryDBC_define.h" 189 | "dbc_timer.h" 190 | "MySql.h" 191 | 192 | 1523936528 /home/nvidia/dbc_load_0.2/Tx2TryDBC_define.h 193 | 194 | -------------------------------------------------------------------------------- /Tx2TryDBC_define.h: -------------------------------------------------------------------------------- 1 | #define MASTER_ESA_CheckSum BO_List[0]->SG_List[0]->value 2 | #define MASTER_REQ_CheckSum BO_List[0]->SG_List[1]->value 3 | #define New_Signal_263 BO_List[0]->SG_List[2]->value 4 | #define New_Signal_262 BO_List[0]->SG_List[3]->value 5 | #define VehV_a BO_List[0]->SG_List[4]->value 6 | 7 | #define MASTER_ESA_TorqueLimitation BO_List[1]->SG_List[0]->value 8 | #define MASTER_ESA_Speedgradient BO_List[1]->SG_List[1]->value 9 | #define MASTER_ESA_EndSpeed BO_List[1]->SG_List[2]->value 10 | #define MASTER_ESA_DurationMax BO_List[1]->SG_List[3]->value 11 | #define MASTER_DIS_ExMaxCurrent BO_List[1]->SG_List[4]->value 12 | #define MASTER_ESA_RollingCounter BO_List[1]->SG_List[5]->value 13 | #define MASTER_Generator_RegVoltage BO_List[1]->SG_List[6]->value 14 | #define MASTER_Generator_TrqLimitation BO_List[1]->SG_List[7]->value 15 | 16 | #define SCU_Negative_Trq_Prediction_10s BO_List[2]->SG_List[0]->value 17 | #define SCU_PREDICTION_CheckSum BO_List[2]->SG_List[1]->value 18 | #define SCU_PREDICTION_RollingCounter BO_List[2]->SG_List[2]->value 19 | #define SCU_Positive_Trq_Prediction_10s BO_List[2]->SG_List[3]->value 20 | 21 | #define SCU_12V_VOLTAGE_LOW BO_List[3]->SG_List[0]->value 22 | #define SCU_REVERSE_SPEED_FAULT BO_List[3]->SG_List[1]->value 23 | #define SCU_12V_VOLTAGE_HIGH BO_List[3]->SG_List[2]->value 24 | #define SCU_BUSOFF_FAULT BO_List[3]->SG_List[3]->value 25 | #define SCU_UNLOCK_PTL_FAULT BO_List[3]->SG_List[4]->value 26 | #define SCU_DIAG_RollingCounter BO_List[3]->SG_List[5]->value 27 | #define SCU_DIAG_CheckSum BO_List[3]->SG_List[6]->value 28 | #define SCU_BRUSH_WEAR_FAULT BO_List[3]->SG_List[7]->value 29 | #define SCU_EXC_OPENCIRCUIT_FAULT BO_List[3]->SG_List[8]->value 30 | #define SCU_EXC_LATENT_FAULT BO_List[3]->SG_List[9]->value 31 | #define SCU_EXC_HSM_FAULT BO_List[3]->SG_List[10]->value 32 | #define SCU_CAN_COM_ERROR BO_List[3]->SG_List[11]->value 33 | #define SCU_DC_VOLTAGEMEAS_SENSOR_FAULT BO_List[3]->SG_List[12]->value 34 | #define SCU_PHX_CURRENT_SENSOR_FAULT BO_List[3]->SG_List[13]->value 35 | #define SCU_MACHINE_TEMP_SENSOR_FAULT BO_List[3]->SG_List[14]->value 36 | #define SCU_INVERTER_TEMP_SENSOR_FAULT BO_List[3]->SG_List[15]->value 37 | #define SCU_POSITION_SENSORS_FAULT BO_List[3]->SG_List[16]->value 38 | #define SCU_STATOR_FAULT BO_List[3]->SG_List[17]->value 39 | #define SCU_INVERTER_FAULT BO_List[3]->SG_List[18]->value 40 | #define SCU_TORQUE_CTRL_TIMEOUT BO_List[3]->SG_List[19]->value 41 | #define SCU_TORQUE_SIGN_FAULT BO_List[3]->SG_List[20]->value 42 | #define SCU_TORQUE_LEVEL_FAULT BO_List[3]->SG_List[21]->value 43 | #define SCU_ROTOR_OVERCURRENT BO_List[3]->SG_List[22]->value 44 | #define SCU_STATOR_OVERCURRENT BO_List[3]->SG_List[23]->value 45 | #define SCU_LOADDUMP BO_List[3]->SG_List[24]->value 46 | #define SCU_OVERVOLTAGE BO_List[3]->SG_List[25]->value 47 | #define SCU_MOSFET_JUNCTION_PROTECTION BO_List[3]->SG_List[26]->value 48 | #define SCU_OVERHEATING BO_List[3]->SG_List[27]->value 49 | #define SCU_STARTER_WARNING BO_List[3]->SG_List[28]->value 50 | #define SCU_THERMAL_DERATING BO_List[3]->SG_List[29]->value 51 | #define SCU_STALLED_ROTOR_PROTECTION BO_List[3]->SG_List[30]->value 52 | #define SCU_TORQUE_SUSPENSION BO_List[3]->SG_List[31]->value 53 | 54 | #define SCU_FUNCTIONAL_RollingCounter BO_List[4]->SG_List[0]->value 55 | #define SCU_FUNCTIONAL_CheckSum BO_List[4]->SG_List[1]->value 56 | #define SCU_Positive_Trq_Prediction_1s BO_List[4]->SG_List[2]->value 57 | #define SCU_Negative_Trq_Prediction_1s BO_List[4]->SG_List[3]->value 58 | #define SCU_IDC_Current BO_List[4]->SG_List[4]->value 59 | #define SCU_Estimated_Torque BO_List[4]->SG_List[5]->value 60 | 61 | #define MASTER_REQ_RollingCounter BO_List[5]->SG_List[0]->value 62 | #define MASTER_TRQCTRL_POS_TRQ_LIM BO_List[5]->SG_List[1]->value 63 | #define MASTER_TRQCTRL_NEG_TRQ_LIM BO_List[5]->SG_List[2]->value 64 | #define MASTER_NEGATIVE_TORQUE_GRADIENT BO_List[5]->SG_List[3]->value 65 | #define MASTER_POSITIVE_TORQUE_GRADIENT BO_List[5]->SG_List[4]->value 66 | #define MASTER_TorqueCtrl_RegTorque BO_List[5]->SG_List[5]->value 67 | #define MASTER_MM_REQUEST BO_List[5]->SG_List[6]->value 68 | 69 | #define SCU_STATUS_RollingCounter BO_List[6]->SG_List[0]->value 70 | #define SCU_STATUS_CheckSum BO_List[6]->SG_List[1]->value 71 | #define CRANK_POSSIBLE_IF_STOPPED BO_List[6]->SG_List[2]->value 72 | #define SCU_ENA_STATUS BO_List[6]->SG_List[3]->value 73 | #define iBSG_Temperature_Rate BO_List[6]->SG_List[4]->value 74 | #define SCU_Rotor_Speed BO_List[6]->SG_List[5]->value 75 | #define SCU_BUS_VOLTAGE BO_List[6]->SG_List[6]->value 76 | #define SCU_MM_STATUS BO_List[6]->SG_List[7]->value 77 | 78 | -------------------------------------------------------------------------------- /can_dbc_0.2.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1523178827 source:/home/nvidia/hhl2/dbc_load_0.2/BO_Index.c 3 | 4 | 5 | 6 | "BO.h" 7 | "BO_Index.h" 8 | 9 | 1524448107 h" 10 | 11 | 1524102134 /home/nvidia/hhl2/dbc_load_0.2/BO.h 12 | 13 | 1523178735 /home/nvidia/hhl2/dbc_load_0.2/BO_Index.h 14 | 15 | 1524106656 source:/home/nvidia/hhl2/dbc_load_0.2/dbc_timer.c 16 | 17 | 18 | 19 | 20 | 21 | "dbc_timer.h" 22 | "canbus.h" 23 | 24 | 1523864941 25 | 26 | 1524106662 /home/nvidia/hhl2/dbc_load_0.2/dbc_timer.h 27 | "canbus.h" 28 | 29 | 1524106935 /home/nvidia/hhl2/dbc_load_0.2/canbus.h 30 | 31 | 32 | 33 | 34 | 35 | 1523519284 .h> 36 | 37 | 1524105746 source:/home/nvidia/hhl2/dbc_load_0.2/main.c 38 | 39 | 40 | 41 | 42 | 43 | 44 | "BO.h" 45 | "BO_Index.h" 46 | "menu.h" 47 | "canbus.h" 48 | "main.h" 49 | "pharse.h" 50 | "package.h" 51 | "Tx2TryDBC_define.h" 52 | "dbc_timer.h" 53 | 54 | 1524105746 .h" 55 | 56 | 1523410226 /home/nvidia/hhl2/dbc_load_0.2/menu.h 57 | 58 | 1523519284 /home/nvidia/hhl2/dbc_load_0.2/main.h 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 1523864945 /home/nvidia/hhl2/dbc_load_0.2/pharse.h 67 | "main.h" 68 | "BO.h" 69 | 70 | 1523867185 71 | 72 | 1523867185 /home/nvidia/hhl2/dbc_load_0.2/package.h 73 | "main.h" 74 | "BO.h" 75 | 76 | 1523936528 /home/nvidia/hhl2/dbc_load_0.2/Tx2TryDBC_define.h 77 | 78 | 1523502917 source:/home/nvidia/hhl2/dbc_load_0.2/menu.c 79 | "menu.h" 80 | 81 | 82 | 83 | 1523866970 source:/home/nvidia/hhl2/dbc_load_0.2/package.c 84 | "package.h" 85 | 86 | 1524107102 " 87 | 88 | 1523864941 source:/home/nvidia/hhl2/dbc_load_0.2/pharse.c 89 | "pharse.h" 90 | 91 | 1524107102 source:/home/nvidia/hhl2/dbc_load_0.2/canbus.c 92 | "main.h" 93 | "canbus.h" 94 | "BO.h" 95 | "pharse.h" 96 | 97 | "dbc_timer.h" 98 | "package.h" 99 | 100 | 1524448107 source:c:\users\lenovo\desktop\dbc_load_0.2\bo_index.c 101 | 102 | 103 | 104 | "BO.h" 105 | "BO_Index.h" 106 | 107 | 1524102134 c:\users\lenovo\desktop\dbc_load_0.2\bo.h 108 | 109 | 1523178735 c:\users\lenovo\desktop\dbc_load_0.2\bo_index.h 110 | 111 | 1524448107 source:/home/nvidia/dbc_load_0.2/BO_Index.c 112 | 113 | 114 | 115 | "BO.h" 116 | "BO_Index.h" 117 | 118 | 1524102134 /home/nvidia/dbc_load_0.2/BO.h 119 | 120 | 1523178735 /home/nvidia/dbc_load_0.2/BO_Index.h 121 | 122 | 1525314743 source:/home/nvidia/dbc_load_0.2/canbus.c 123 | "main.h" 124 | "canbus.h" 125 | "BO.h" 126 | "pharse.h" 127 | 128 | "dbc_timer.h" 129 | "package.h" 130 | 131 | 1523519284 /home/nvidia/dbc_load_0.2/main.h 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 1525318044 /home/nvidia/dbc_load_0.2/canbus.h 140 | 141 | 142 | 143 | 144 | 145 | 1523864945 /home/nvidia/dbc_load_0.2/pharse.h 146 | "main.h" 147 | "BO.h" 148 | 149 | 1524106662 /home/nvidia/dbc_load_0.2/dbc_timer.h 150 | "canbus.h" 151 | 152 | 1523867185 /home/nvidia/dbc_load_0.2/package.h 153 | "main.h" 154 | "BO.h" 155 | 156 | 1525310317 source:/home/nvidia/dbc_load_0.2/dbc_timer.c 157 | 158 | 159 | 160 | 161 | 162 | "dbc_timer.h" 163 | "canbus.h" 164 | 165 | 1525314925 source:/home/nvidia/dbc_load_0.2/main.c 166 | 167 | 168 | 169 | 170 | 171 | 172 | "BO.h" 173 | "BO_Index.h" 174 | "menu.h" 175 | "canbus.h" 176 | "main.h" 177 | "pharse.h" 178 | "package.h" 179 | "Tx2TryDBC_define.h" 180 | "dbc_timer.h" 181 | "MySql.h" 182 | 183 | 1523410226 /home/nvidia/dbc_load_0.2/menu.h 184 | 185 | 1523936528 /home/nvidia/dbc_load_0.2/Tx2TryDBC_define.h 186 | 187 | 1525316186 /home/nvidia/dbc_load_0.2/MySql.h 188 | 189 | 190 | 191 | 192 | "BO.h" 193 | 194 | 1523502917 source:/home/nvidia/dbc_load_0.2/menu.c 195 | "menu.h" 196 | 197 | 198 | 199 | 1525316481 source:/home/nvidia/dbc_load_0.2/MySql.c 200 | "MySql.h" 201 | "GetTime.h" 202 | "canbus.h" 203 | "pharse.h" 204 | "sys/time.h" 205 | 206 | 207 | 208 | 209 | 210 | 1524792071 /home/nvidia/dbc_load_0.2/GetTime.h 211 | 212 | 213 | 214 | 1524449581 source:/home/nvidia/dbc_load_0.2/package.c 215 | "package.h" 216 | 217 | 1525310432 source:/home/nvidia/dbc_load_0.2/pharse.c 218 | "pharse.h" 219 | 220 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "BO.h" 9 | #include "BO_Index.h" 10 | 11 | #include "menu.h" 12 | #include "canbus.h" 13 | #include "main.h" 14 | #include "pharse.h" 15 | #include "package.h" 16 | #include "Tx2TryDBC_define.h" 17 | #include "dbc_timer.h" 18 | #include "MySql.h" 19 | #include "PyCall.h" 20 | 21 | 22 | FILE * dbc_cfg_fd = NULL; //dbc file fd 23 | char *dbc_cfg_rdbuf = NULL; //dbc read buffer 24 | int can_fd; //can 设备句柄 25 | int can_fd2; //can设备句柄 26 | struct can_frame frame; //recv frame 接收buffer 27 | struct can_frame frame_send; //frame to be send发送buffer 28 | 29 | pthread_t printThread; //打印线程的线程句柄 30 | /*统计时间的变量*/ 31 | long read_time ; 32 | long parse_time ; 33 | long bypass_time ; 34 | long pack_time ; 35 | long write_time ; 36 | int count; 37 | 38 | /*打印线程*/ 39 | void PrintTask(void) 40 | { 41 | while(1) 42 | { 43 | system("clear"); 44 | int i =0; 45 | while(BO_List[i] != NULL) 46 | { 47 | printf("BO_ %d %s\n",BO_List[i]->message_id,BO_List[i]->message_name); 48 | int t = 0; 49 | while(BO_List[i]->SG_List[t] != NULL) /*SG_LOOP*/ 50 | { 51 | printf("%s",BO_List[i]->SG_List[t]->signal_name); 52 | printf(">>>%-10lf",BO_List[i]->SG_List[t]->value); 53 | printf("send>%-10lf\t",BO_List[i]->SG_List[t]->value_send); 54 | if((t+1)%2 == 0) 55 | { 56 | printf("\n"); 57 | } 58 | t ++; 59 | } 60 | printf("------------------------\n"); 61 | i++; 62 | } 63 | // printf(">>>>read time:%ld us<<<<\n",read_time); 64 | // printf(">>>>parse time:%ld us<<<<\n",parse_time); 65 | // printf(">>>>bypass time:%ld us<<<<\n",bypass_time); 66 | // printf(">>>>pack time:%ld us<<<<\n",pack_time); 67 | // printf(">>>>write time:%ld us<<<<\n",write_time); 68 | // printf("meg received : %d\n",count); 69 | // printf("MASTER_REQ_RollingCounter:%lf\n",MASTER_REQ_RollingCounter); 70 | usleep(10*1000); 71 | } 72 | } 73 | 74 | int main(int argc,char *argv[]) 75 | { 76 | //struct timeval start, end; 77 | int dbc_falg = 0; //dbc文件载入标志位 78 | dbc_cfg_rdbuf = malloc(100);//dbc文件读取buffer 79 | int BO_counter = 0; //dbc中的BO计数器 80 | memset(BO_List,0,4*50); //初始化 81 | 82 | printf("******************* dbc_load_program V0.2 *********************\n"); 83 | printf("******************* By intern huang honglei *******************\n"); 84 | printf("******************* 2018/4/23 *******************\n"); 85 | 86 | if(argc != 1) 87 | { 88 | if(NULL == (dbc_cfg_fd = fopen(argv[1],"r")) ) 89 | { 90 | printf("***dbc config file open failed!\n"); 91 | printf("Now no dbc file is loaded\n"); 92 | } 93 | else 94 | { 95 | Dbc_load(dbc_cfg_fd,dbc_cfg_rdbuf,BO_List);//读取dbc文件 96 | printf(">>>dbc config file loaded\n"); 97 | dbc_falg = 1; 98 | } 99 | } 100 | else if(argc == 1) 101 | { 102 | printf("Now no dbc file is loaded\n"); 103 | printf("No interface is loaded!\n"); 104 | print_usage(); 105 | } 106 | 107 | printf("Press Any Key \n"); 108 | getchar(); 109 | system("clear"); 110 | 111 | /*print state*/ 112 | if(1 == dbc_falg) 113 | { 114 | printf("Canbus Mode:%s\t\n",argv[1]); 115 | } 116 | 117 | 118 | /*choose打印菜单*/ 119 | printf("1:Canbus MySql\n2:Fork\n -->can0;can1-->\n <--can0;can1<--\n3:-->can0;can1-->\n <--can0;can1<--\n4:csv pycall\n5:for test\n"); 120 | //int nbytes; 121 | int choice; 122 | scanf("%d",&choice); 123 | 124 | canbuscmd_t cmd; 125 | cmd.interface = "can0"; 126 | cmd.record = 1; 127 | cmd.show = 0; 128 | cmd.loopback = 0; 129 | switch(choice) 130 | { 131 | case 1: 132 | CanbusRecvRecord(&cmd); 133 | RecordDataCsv(); 134 | break; 135 | 136 | case 2: 137 | PthreadCanbusTest();//can0和can1回环功能测试 138 | break; 139 | 140 | case 3: 141 | CanBusTestMode();//10ms 20ms 50ms 100ms程序测试 142 | break; 143 | case 4: 144 | PyInit(); 145 | CanbusRecvRecord(&cmd); 146 | RecordDataCsv(); 147 | break; 148 | case 5: 149 | PyInit(); 150 | PyCallfun("test01", "testprint", "test arg!"); 151 | 152 | break; 153 | default: 154 | printf("Invaild parameter\n"); 155 | break; 156 | 157 | } 158 | while(1); 159 | /*free malloc*/ 160 | Free_BO_(BO_counter); 161 | return 0; 162 | } 163 | 164 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LinuxCanbusTool 2 | 3 | A comprehensive Linux CAN bus tool with DBC file parsing, CAN message transceiver, data recording and database storage capabilities. 4 | 5 | ## 🚀 Features 6 | 7 | ### Core Functions 8 | - **DBC File Parsing** - Support for reading and parsing standard DBC format files 9 | - **CAN Message Parsing** - Automatic parsing of CAN message signals based on DBC definitions 10 | - **CAN Message Packaging** - Package signal values into CAN messages according to DBC definitions 11 | - **Bidirectional Communication** - Support for both CAN message transmission and reception 12 | - **Real-time Monitoring** - Real-time display of CAN signal value changes 13 | 14 | ### Data Processing 15 | - **CSV Data Recording** - Real-time CAN data recording and saving in CSV format 16 | - **MySQL Database** - Save CAN data to MySQL database 17 | - **Python Integration** - Support for calling Python scripts for data processing 18 | - **Multi-interface Support** - Support for multiple CAN interfaces like can0, can1, etc. 19 | 20 | ### Testing Features 21 | - **Loopback Testing** - Loopback functionality testing between can0 and can1 interfaces 22 | - **Timed Transmission** - Support for different transmission cycles (10ms, 20ms, 50ms, 100ms) 23 | - **Performance Statistics** - Statistics for message parsing, packaging, and transmission/reception timing 24 | 25 | ## 📋 Requirements 26 | 27 | - **Operating System**: Linux (with SocketCAN support) 28 | - **Compiler**: GCC with C99 support 29 | - **Dependencies**: 30 | - pthread (for multi-threading support) 31 | - MySQL client library (optional, for database functionality) 32 | - Python development headers (optional, for Python integration) 33 | 34 | ## 🔧 Build 35 | 36 | ### Using Code::Blocks 37 | The project includes Code::Blocks project files (`*.cbp`) that can be opened and compiled directly in Code::Blocks. 38 | 39 | ### Manual Compilation with GCC 40 | ```bash 41 | gcc -o dbc_load_tool main.c canbus.c pharse.c package.c BO_Index.c \ 42 | dbc_timer.c GetTime.c MySql.c PyCall.c menu.c \ 43 | -lpthread -lmysqlclient -lpython3.x 44 | ``` 45 | 46 | ## 📖 Usage 47 | 48 | ### Basic Usage 49 | ```bash 50 | ./dbc_load_tool 51 | ``` 52 | 53 | ### Example 54 | ```bash 55 | ./dbc_load_tool Huanghonglei.dbc 56 | ``` 57 | 58 | ### Operating Modes 59 | After starting the program, a menu will be displayed with the following options: 60 | 61 | 1. **Canbus MySql** - CAN data reception and storage to MySQL database 62 | 2. **Fork** - Dual-interface loopback test mode for can0 and can1 63 | 3. **Test Mode** - Timed transmission test mode 64 | 4. **CSV + Python** - CSV recording mode with Python script integration 65 | 5. **Test** - Python integration functionality testing 66 | 67 | ### DBC File Format 68 | Supports standard DBC file format including: 69 | - `BO_` message definitions 70 | - `SG_` signal definitions 71 | - Signal properties (start bit, length, byte order, sign, factor, offset, etc.) 72 | 73 | ## 📁 Project Structure 74 | 75 | ``` 76 | LinuxCanbusTool/ 77 | ├── main.c # Main program entry point 78 | ├── canbus.c/.h # CAN bus interface wrapper 79 | ├── pharse.c/.h # DBC parsing functionality 80 | ├── package.c/.h # CAN message packaging functionality 81 | ├── BO.h # CAN message and signal data structure definitions 82 | ├── BO_Index.c/.h # DBC file loading and indexing 83 | ├── dbc_timer.c/.h # Timed transmission functionality 84 | ├── MySql.c/.h # MySQL database interface 85 | ├── PyCall.c/.h # Python integration interface 86 | ├── GetTime.c/.h # Time statistics utility 87 | ├── menu.c/.h # User interface menu 88 | ├── *.dbc # DBC file examples 89 | └── bin/Debug/ # Compilation output directory 90 | ``` 91 | 92 | ## 🔧 Configuration 93 | 94 | ### CAN Interface Setup 95 | Ensure the CAN interface is properly configured: 96 | ```bash 97 | # Setup CAN interface 98 | sudo ip link set can0 type can bitrate 500000 99 | sudo ip link set up can0 100 | ``` 101 | 102 | ### MySQL Configuration 103 | If using database functionality, ensure MySQL service is running and configure the appropriate database connection parameters. 104 | 105 | ### Python Environment 106 | If using Python integration features, ensure Python development environment is installed. 107 | 108 | ## 📊 Performance 109 | 110 | - **Real-time Performance** - Supports real-time processing of high-frequency CAN messages 111 | - **Multi-threading** - Multi-threaded architecture with separated transmission/reception and display 112 | - **Memory Management** - Dynamic memory allocation supporting large DBC files 113 | - **Time Statistics** - Built-in performance monitoring with processing time statistics 114 | 115 | ## 🤝 Contributing 116 | 117 | Issues and Pull Requests are welcome to improve the project. 118 | 119 | ## 📄 License 120 | 121 | Please check the LICENSE file in the project root directory for license information. 122 | 123 | ## 👨‍💻 Author 124 | 125 | - **Huang Honglei** - Intern Project 2018/4/23 126 | 127 | ## 📞 Support 128 | 129 | For questions or suggestions, please contact via: 130 | - Submit GitHub Issues 131 | - Email project maintainers 132 | 133 | --- 134 | 135 | *Note: This tool is primarily designed for automotive electronics CAN bus development and testing, suitable for vehicle ECU communication debugging, CAN protocol analysis, and similar scenarios.* 136 | -------------------------------------------------------------------------------- /Huanghonglei.dbc: -------------------------------------------------------------------------------- 1 | VERSION "" 2 | 3 | 4 | NS_ : 5 | NS_DESC_ 6 | CM_ 7 | BA_DEF_ 8 | BA_ 9 | VAL_ 10 | CAT_DEF_ 11 | CAT_ 12 | FILTER 13 | BA_DEF_DEF_ 14 | EV_DATA_ 15 | ENVVAR_DATA_ 16 | SGTYPE_ 17 | SGTYPE_VAL_ 18 | BA_DEF_SGTYPE_ 19 | BA_SGTYPE_ 20 | SIG_TYPE_REF_ 21 | VAL_TABLE_ 22 | SIG_GROUP_ 23 | SIG_VALTYPE_ 24 | SIGTYPE_VALTYPE_ 25 | BO_TX_BU_ 26 | BA_DEF_REL_ 27 | BA_REL_ 28 | BA_DEF_DEF_REL_ 29 | BU_SG_REL_ 30 | BU_EV_REL_ 31 | BU_BO_REL_ 32 | SG_MUL_VAL_ 33 | SSFDSFSDAFBO_ SFDHJFHSJKF789SD789 34 | BS_: 35 | 36 | BU_: APM CanBlue Car_PC BMS DCDC SCU BRS_ECU 37 | 38 | 39 | BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX 40 | SG_ MASTER_ESA_CheckSum : 0|8@0+ (1,0) [0|255] "" Vector__XXX 41 | SG_ MASTER_REQ_CheckSum : 0|8@0+ (1,0) [0|255] "" Vector__XXX 42 | 43 | BO_ 384 SAS_180_CAN1: 8 Vector__XXX 44 | SG_ SAS_SteeringAngle : 7|16@0- (0.1,-780) [-1320|-240] "degree" BRS_ECU 45 | 46 | BO_ 613 PredictiveOS_LoadCollective3_ECU: 8 BRS_ECU 47 | SG_ miopt_w : 55|16@0+ (0.00152587890625,0) [0|99.9984741210938] "%" Vector__XXX 48 | SG_ zwout : 47|8@0- (0.75,0) [-96|95.25] "" Vector__XXX 49 | SG_ zwopt : 39|8@0- (0.75,0) [-96|95.25] "Grad KW" Vector__XXX 50 | SG_ mifal_w : 23|16@0+ (0.00152587890625,0) [0|99.9984741210938] "%" Vector__XXX 51 | SG_ mifa_w : 7|16@0+ (0.00152587890625,0) [0|99.9984741210938] "%" Vector__XXX 52 | 53 | BO_ 612 PredictiveOS_LoadCollective2_ECU: 8 BRS_ECU 54 | SG_ PCA_CurrGearSelect : 15|8@0+ (1,-1) [-1|254] "" Vector__XXX 55 | SG_ CoPOM_stOperModEdrv : 5|4@0+ (1,0) [0|7] "" Vector__XXX 56 | SG_ CoPOM_tqDesEdrv : 55|16@0- (0.1,0) [-3276.8|3276.7] "Nm" Vector__XXX 57 | SG_ IOT_B_koe : 6|1@0+ (1,0) [0|1] "" Vector__XXX 58 | SG_ B_stoanf : 7|1@0+ (1,0) [0|1] "" Vector__XXX 59 | SG_ lamsbg_w : 39|16@0+ (0.000244140625,0) [0|15.999755859375] "" Vector__XXX 60 | SG_ mrped_w : 23|16@0+ (0.0030517578125,0) [0|199.996948242188] "%" Vector__XXX 61 | 62 | BO_ 610 PredictiveOS_CanBlue2_ECU: 8 BRS_ECU 63 | SG_ rl_w : 7|16@0+ (0.0234375,0) [0|1535.9765625] "%" CanBlue 64 | SG_ CoPOM_bPcaRcptActv : 56|1@0+ (1,0) [0|1] "" CanBlue 65 | SG_ CoPOM_bPcaCoastActv : 57|1@0+ (1,0) [0|1] "" CanBlue 66 | SG_ PEM_StFunction : 59|2@0+ (1,0) [0|3] "" CanBlue 67 | SG_ PCA_StFunction : 61|2@0+ (1,0) [0|3] "" CanBlue 68 | SG_ B_cbs_ua : 40|1@0+ (1,0) [0|1] "" CanBlue 69 | SG_ CoPOM_tqElMDesPca : 55|10@0+ (0.1,-50) [-50|0] "" CanBlue 70 | SG_ PCA_stCstProc : 43|3@0+ (1,0) [0|7] "" CanBlue 71 | SG_ PT_bNoGrip : 44|1@0+ (1,0) [0|1] "" CanBlue 72 | SG_ B_kuppl : 45|1@0+ (1,0) [0|1] "" CanBlue 73 | SG_ IOT_B_sa : 46|1@0+ (1,0) [0|1] "" CanBlue 74 | SG_ CoPOM_POS_bBrsErr : 47|1@0+ (1,0) [0|1] "" CanBlue 75 | SG_ Eem_stAct : 31|16@0+ (1,0) [0|56636] "" CanBlue 76 | SG_ IOT_Tmot : 23|8@0+ (0.75,-48) [-48|143.25] "" CanBlue 77 | 78 | BO_ 609 PredictiveOS_CanBlue1_ECU: 8 BRS_ECU 79 | SG_ VehV_a : 47|16@0- (0.001,0) [-32.768|32.767] "" CanBlue 80 | SG_ PCA_vSpdLim_kmh : 63|8@0+ (1,0) [0|255] "" CanBlue 81 | SG_ PCA_lDst2Des : 1|10@0+ (1,0) [0|1000] "" CanBlue 82 | SG_ PCA_stSpdLmt : 29|3@0+ (1,0) [0|7] "" CanBlue 83 | SG_ PCA_stCoastMode : 3|2@0+ (1,0) [0|3] "" CanBlue 84 | SG_ Brs_BRS_Sta : 26|1@0+ (1,0) [0|1] "" CanBlue 85 | SG_ Brk_r : 25|10@0+ (0.1,0) [0|100] "" CanBlue 86 | SG_ PCA_flgPedLiftRecom : 4|1@0+ (1,0) [0|1] "" CanBlue 87 | SG_ PCA_flgDrvTakRecom : 5|1@0+ (1,0) [0|1] "" CanBlue 88 | SG_ CoPOM_rRelSOCDesPred : 23|10@0+ (0.1,0) [0|100] "" CanBlue 89 | SG_ CoPOM_flgSOCDesPred : 6|1@0+ (1,0) [0|1] "" CanBlue 90 | SG_ CoPOM_flgIdleCoastEna : 7|1@0+ (1,0) [0|1] "" CanBlue 91 | 92 | BO_ 512 Camera_Radar_Data: 7 Car_PC 93 | SG_ Radar_RelativeV_kmh : 39|9@0+ (0.5,-128) [-128|127] "km/h" BRS_ECU 94 | SG_ Radar_RelativeD_m : 23|10@0+ (0.5,0) [0|250] "m" BRS_ECU 95 | SG_ Camera_TimeLeft_s : 55|8@0+ (1,0) [0|60] "s" BRS_ECU 96 | SG_ Camera_LightColor : 9|2@0+ (1,0) [0|3] "" BRS_ECU 97 | SG_ Camera_Distance_footway : 7|9@0+ (0.5,0) [0|255] "m" BRS_ECU 98 | 99 | BO_ 1280 VEH_MSG: 8 BRS_ECU 100 | SG_ EMS_VehicleSpeed : 12|13@0+ (0.05625,0) [0|360] "km/h" BMS 101 | SG_ EMS_VehicleSpeedValid : 13|1@0+ (1,0) [0|1] "" BMS 102 | SG_ veh_cb_cmd_e : 0|1@0+ (1,0) [0|1] "" BMS 103 | 104 | 105 | 106 | CM_ BO_ 3221225472 "This is a message for not used signals, created by Vector CANdb++ DBC OLE DB Provider."; 107 | CM_ SG_ 613 zwout "Ignition angle output value"; 108 | CM_ SG_ 613 zwopt "Optimized model reference ignition angle"; 109 | CM_ SG_ 613 mifal_w "Indicated driver's wish torque for torque coordination cylinder filling"; 110 | CM_ SG_ 613 mifa_w "Desired indicated engine torque"; 111 | CM_ SG_ 612 PCA_CurrGearSelect "Engaged gear"; 112 | CM_ SG_ 612 CoPOM_stOperModEdrv "0 - idle 113 | 1 - charge 114 | 2 - Reku 115 | 3 - Boost 116 | 4 - discharge"; 117 | CM_ SG_ 612 CoPOM_tqDesEdrv "Desired Electric drive torque."; 118 | CM_ SG_ 612 IOT_B_koe "Condition for AC-compressor ON"; 119 | CM_ SG_ 612 mrped_w "Relative torque request by accelerator pedal"; 120 | CM_ SG_ 610 PEM_StFunction "01 PEM enable 121 | 10 PEM disable"; 122 | CM_ SG_ 610 PCA_StFunction "01 PCA Enable 123 | 10 PCA Disable"; 124 | CM_ SG_ 610 B_cbs_ua "Condition clutch sensor indicate clutch on bottom"; 125 | CM_ SG_ 610 IOT_B_sa "fuel off"; 126 | CM_ SG_ 609 VehV_a "The acceleration of the vehicle"; 127 | CM_ SG_ 609 PCA_stSpdLmt "1 TrafficLight Speed Limit 128 | 2 Curve Speed Limit 129 | 3 Speed limit sign 130 | 4 Front Vehicle speed limit"; 131 | CM_ SG_ 609 PCA_stCoastMode "stCstMode 0 No coast 132 | 1 Full Coasting 133 | 2 CR"; 134 | CM_ SG_ 512 Radar_RelativeD_m "Distance to front vehicle in the same lane 135 | 0x3FF Invalid value"; 136 | CM_ SG_ 512 Camera_TimeLeft_s "Left Time : 137 | invalid value:0xFF 138 | 0:60 Normal"; 139 | CM_ SG_ 512 Camera_LightColor "Tarffic light color"; 140 | CM_ SG_ 512 Camera_Distance_footway "Distance to footway by Camera recognization. 141 | invalid value : 0x1FF"; 142 | CM_ SG_ 1280 veh_cb_cmd_e "Circuit Breaker command from the Vehicle/Tester."; 143 | BA_DEF_ BO_ "GenMsgILSupport" ENUM "No","Yes"; 144 | BA_DEF_ SG_ "GenSigStartValue" INT 0 0; 145 | BA_DEF_ BO_ "GenMsgSendType" ENUM "Cyclic"; 146 | BA_DEF_ BO_ "GenMsgCycleTime" INT 10 1000; 147 | BA_DEF_ "BusType" STRING ; 148 | BA_DEF_DEF_ "GenMsgILSupport" "Yes"; 149 | BA_DEF_DEF_ "GenSigStartValue" 0; 150 | BA_DEF_DEF_ "GenMsgSendType" "Cyclic"; 151 | BA_DEF_DEF_ "GenMsgCycleTime" 10; 152 | BA_DEF_DEF_ "BusType" ""; 153 | BA_ "BusType" "CAN"; 154 | BA_ "GenMsgCycleTime" BO_ 613 100; 155 | BA_ "GenMsgCycleTime" BO_ 612 100; 156 | BA_ "GenMsgCycleTime" BO_ 610 100; 157 | BA_ "GenMsgCycleTime" BO_ 609 100; 158 | BA_ "GenMsgCycleTime" BO_ 512 50; 159 | BA_ "GenMsgCycleTime" BO_ 1280 50; 160 | BA_ "GenSigStartValue" SG_ 612 PCA_CurrGearSelect 1; 161 | BA_ "GenSigStartValue" SG_ 610 CoPOM_tqElMDesPca 500; 162 | BA_ "GenSigStartValue" SG_ 610 IOT_Tmot 64; 163 | VAL_ 512 Camera_LightColor 3 "red light" 2 "yellow light" 1 "green light" 0 "Overrange" ; 164 | VAL_ 1280 veh_cb_cmd_e 1 "VEH_CB_CMD_CLOSE" 0 "VEH_CB_CMD_OPEN" ; 165 | 166 | -------------------------------------------------------------------------------- /bin/Debug/Huanghonglei.dbc: -------------------------------------------------------------------------------- 1 | VERSION "" 2 | 3 | 4 | NS_ : 5 | NS_DESC_ 6 | CM_ 7 | BA_DEF_ 8 | BA_ 9 | VAL_ 10 | CAT_DEF_ 11 | CAT_ 12 | FILTER 13 | BA_DEF_DEF_ 14 | EV_DATA_ 15 | ENVVAR_DATA_ 16 | SGTYPE_ 17 | SGTYPE_VAL_ 18 | BA_DEF_SGTYPE_ 19 | BA_SGTYPE_ 20 | SIG_TYPE_REF_ 21 | VAL_TABLE_ 22 | SIG_GROUP_ 23 | SIG_VALTYPE_ 24 | SIGTYPE_VALTYPE_ 25 | BO_TX_BU_ 26 | BA_DEF_REL_ 27 | BA_REL_ 28 | BA_DEF_DEF_REL_ 29 | BU_SG_REL_ 30 | BU_EV_REL_ 31 | BU_BO_REL_ 32 | SG_MUL_VAL_ 33 | SSFDSFSDAFBO_ SFDHJFHSJKF789SD789 34 | BS_: 35 | 36 | BU_: APM CanBlue Car_PC BMS DCDC SCU BRS_ECU 37 | 38 | 39 | BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX 40 | SG_ MASTER_ESA_CheckSum : 0|8@0+ (1,0) [0|255] "" Vector__XXX 41 | SG_ MASTER_REQ_CheckSum : 0|8@0+ (1,0) [0|255] "" Vector__XXX 42 | 43 | BO_ 384 SAS_180_CAN1: 8 Vector__XXX 44 | SG_ SAS_SteeringAngle : 7|16@0- (0.1,-780) [-1320|-240] "degree" BRS_ECU 45 | 46 | BO_ 613 PredictiveOS_LoadCollective3_ECU: 8 BRS_ECU 47 | SG_ miopt_w : 55|16@0+ (0.00152587890625,0) [0|99.9984741210938] "%" Vector__XXX 48 | SG_ zwout : 47|8@0- (0.75,0) [-96|95.25] "" Vector__XXX 49 | SG_ zwopt : 39|8@0- (0.75,0) [-96|95.25] "Grad KW" Vector__XXX 50 | SG_ mifal_w : 23|16@0+ (0.00152587890625,0) [0|99.9984741210938] "%" Vector__XXX 51 | SG_ mifa_w : 7|16@0+ (0.00152587890625,0) [0|99.9984741210938] "%" Vector__XXX 52 | 53 | BO_ 612 PredictiveOS_LoadCollective2_ECU: 8 BRS_ECU 54 | SG_ PCA_CurrGearSelect : 15|8@0+ (1,-1) [-1|254] "" Vector__XXX 55 | SG_ CoPOM_stOperModEdrv : 5|4@0+ (1,0) [0|7] "" Vector__XXX 56 | SG_ CoPOM_tqDesEdrv : 55|16@0- (0.1,0) [-3276.8|3276.7] "Nm" Vector__XXX 57 | SG_ IOT_B_koe : 6|1@0+ (1,0) [0|1] "" Vector__XXX 58 | SG_ B_stoanf : 7|1@0+ (1,0) [0|1] "" Vector__XXX 59 | SG_ lamsbg_w : 39|16@0+ (0.000244140625,0) [0|15.999755859375] "" Vector__XXX 60 | SG_ mrped_w : 23|16@0+ (0.0030517578125,0) [0|199.996948242188] "%" Vector__XXX 61 | 62 | BO_ 610 PredictiveOS_CanBlue2_ECU: 8 BRS_ECU 63 | SG_ rl_w : 7|16@0+ (0.0234375,0) [0|1535.9765625] "%" CanBlue 64 | SG_ CoPOM_bPcaRcptActv : 56|1@0+ (1,0) [0|1] "" CanBlue 65 | SG_ CoPOM_bPcaCoastActv : 57|1@0+ (1,0) [0|1] "" CanBlue 66 | SG_ PEM_StFunction : 59|2@0+ (1,0) [0|3] "" CanBlue 67 | SG_ PCA_StFunction : 61|2@0+ (1,0) [0|3] "" CanBlue 68 | SG_ B_cbs_ua : 40|1@0+ (1,0) [0|1] "" CanBlue 69 | SG_ CoPOM_tqElMDesPca : 55|10@0+ (0.1,-50) [-50|0] "" CanBlue 70 | SG_ PCA_stCstProc : 43|3@0+ (1,0) [0|7] "" CanBlue 71 | SG_ PT_bNoGrip : 44|1@0+ (1,0) [0|1] "" CanBlue 72 | SG_ B_kuppl : 45|1@0+ (1,0) [0|1] "" CanBlue 73 | SG_ IOT_B_sa : 46|1@0+ (1,0) [0|1] "" CanBlue 74 | SG_ CoPOM_POS_bBrsErr : 47|1@0+ (1,0) [0|1] "" CanBlue 75 | SG_ Eem_stAct : 31|16@0+ (1,0) [0|56636] "" CanBlue 76 | SG_ IOT_Tmot : 23|8@0+ (0.75,-48) [-48|143.25] "" CanBlue 77 | 78 | BO_ 609 PredictiveOS_CanBlue1_ECU: 8 BRS_ECU 79 | SG_ VehV_a : 47|16@0- (0.001,0) [-32.768|32.767] "" CanBlue 80 | SG_ PCA_vSpdLim_kmh : 63|8@0+ (1,0) [0|255] "" CanBlue 81 | SG_ PCA_lDst2Des : 1|10@0+ (1,0) [0|1000] "" CanBlue 82 | SG_ PCA_stSpdLmt : 29|3@0+ (1,0) [0|7] "" CanBlue 83 | SG_ PCA_stCoastMode : 3|2@0+ (1,0) [0|3] "" CanBlue 84 | SG_ Brs_BRS_Sta : 26|1@0+ (1,0) [0|1] "" CanBlue 85 | SG_ Brk_r : 25|10@0+ (0.1,0) [0|100] "" CanBlue 86 | SG_ PCA_flgPedLiftRecom : 4|1@0+ (1,0) [0|1] "" CanBlue 87 | SG_ PCA_flgDrvTakRecom : 5|1@0+ (1,0) [0|1] "" CanBlue 88 | SG_ CoPOM_rRelSOCDesPred : 23|10@0+ (0.1,0) [0|100] "" CanBlue 89 | SG_ CoPOM_flgSOCDesPred : 6|1@0+ (1,0) [0|1] "" CanBlue 90 | SG_ CoPOM_flgIdleCoastEna : 7|1@0+ (1,0) [0|1] "" CanBlue 91 | 92 | BO_ 512 Camera_Radar_Data: 7 Car_PC 93 | SG_ Radar_RelativeV_kmh : 39|9@0+ (0.5,-128) [-128|127] "km/h" BRS_ECU 94 | SG_ Radar_RelativeD_m : 23|10@0+ (0.5,0) [0|250] "m" BRS_ECU 95 | SG_ Camera_TimeLeft_s : 55|8@0+ (1,0) [0|60] "s" BRS_ECU 96 | SG_ Camera_LightColor : 9|2@0+ (1,0) [0|3] "" BRS_ECU 97 | SG_ Camera_Distance_footway : 7|9@0+ (0.5,0) [0|255] "m" BRS_ECU 98 | 99 | BO_ 1280 VEH_MSG: 8 BRS_ECU 100 | SG_ EMS_VehicleSpeed : 12|13@0+ (0.05625,0) [0|360] "km/h" BMS 101 | SG_ EMS_VehicleSpeedValid : 13|1@0+ (1,0) [0|1] "" BMS 102 | SG_ veh_cb_cmd_e : 0|1@0+ (1,0) [0|1] "" BMS 103 | 104 | 105 | 106 | CM_ BO_ 3221225472 "This is a message for not used signals, created by Vector CANdb++ DBC OLE DB Provider."; 107 | CM_ SG_ 613 zwout "Ignition angle output value"; 108 | CM_ SG_ 613 zwopt "Optimized model reference ignition angle"; 109 | CM_ SG_ 613 mifal_w "Indicated driver's wish torque for torque coordination cylinder filling"; 110 | CM_ SG_ 613 mifa_w "Desired indicated engine torque"; 111 | CM_ SG_ 612 PCA_CurrGearSelect "Engaged gear"; 112 | CM_ SG_ 612 CoPOM_stOperModEdrv "0 - idle 113 | 1 - charge 114 | 2 - Reku 115 | 3 - Boost 116 | 4 - discharge"; 117 | CM_ SG_ 612 CoPOM_tqDesEdrv "Desired Electric drive torque."; 118 | CM_ SG_ 612 IOT_B_koe "Condition for AC-compressor ON"; 119 | CM_ SG_ 612 mrped_w "Relative torque request by accelerator pedal"; 120 | CM_ SG_ 610 PEM_StFunction "01 PEM enable 121 | 10 PEM disable"; 122 | CM_ SG_ 610 PCA_StFunction "01 PCA Enable 123 | 10 PCA Disable"; 124 | CM_ SG_ 610 B_cbs_ua "Condition clutch sensor indicate clutch on bottom"; 125 | CM_ SG_ 610 IOT_B_sa "fuel off"; 126 | CM_ SG_ 609 VehV_a "The acceleration of the vehicle"; 127 | CM_ SG_ 609 PCA_stSpdLmt "1 TrafficLight Speed Limit 128 | 2 Curve Speed Limit 129 | 3 Speed limit sign 130 | 4 Front Vehicle speed limit"; 131 | CM_ SG_ 609 PCA_stCoastMode "stCstMode 0 No coast 132 | 1 Full Coasting 133 | 2 CR"; 134 | CM_ SG_ 512 Radar_RelativeD_m "Distance to front vehicle in the same lane 135 | 0x3FF Invalid value"; 136 | CM_ SG_ 512 Camera_TimeLeft_s "Left Time : 137 | invalid value:0xFF 138 | 0:60 Normal"; 139 | CM_ SG_ 512 Camera_LightColor "Tarffic light color"; 140 | CM_ SG_ 512 Camera_Distance_footway "Distance to footway by Camera recognization. 141 | invalid value : 0x1FF"; 142 | CM_ SG_ 1280 veh_cb_cmd_e "Circuit Breaker command from the Vehicle/Tester."; 143 | BA_DEF_ BO_ "GenMsgILSupport" ENUM "No","Yes"; 144 | BA_DEF_ SG_ "GenSigStartValue" INT 0 0; 145 | BA_DEF_ BO_ "GenMsgSendType" ENUM "Cyclic"; 146 | BA_DEF_ BO_ "GenMsgCycleTime" INT 10 1000; 147 | BA_DEF_ "BusType" STRING ; 148 | BA_DEF_DEF_ "GenMsgILSupport" "Yes"; 149 | BA_DEF_DEF_ "GenSigStartValue" 0; 150 | BA_DEF_DEF_ "GenMsgSendType" "Cyclic"; 151 | BA_DEF_DEF_ "GenMsgCycleTime" 10; 152 | BA_DEF_DEF_ "BusType" ""; 153 | BA_ "BusType" "CAN"; 154 | BA_ "GenMsgCycleTime" BO_ 613 100; 155 | BA_ "GenMsgCycleTime" BO_ 612 100; 156 | BA_ "GenMsgCycleTime" BO_ 610 100; 157 | BA_ "GenMsgCycleTime" BO_ 609 100; 158 | BA_ "GenMsgCycleTime" BO_ 512 50; 159 | BA_ "GenMsgCycleTime" BO_ 1280 50; 160 | BA_ "GenSigStartValue" SG_ 612 PCA_CurrGearSelect 1; 161 | BA_ "GenSigStartValue" SG_ 610 CoPOM_tqElMDesPca 500; 162 | BA_ "GenSigStartValue" SG_ 610 IOT_Tmot 64; 163 | VAL_ 512 Camera_LightColor 3 "red light" 2 "yellow light" 1 "green light" 0 "Overrange" ; 164 | VAL_ 1280 veh_cb_cmd_e 1 "VEH_CB_CMD_CLOSE" 0 "VEH_CB_CMD_OPEN" ; 165 | 166 | -------------------------------------------------------------------------------- /MySql.c: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | *Author : huanghonglei 3 | *Date : 2018/4/27 4 | *function: through MySql record the canbus Data 5 | ***********************************************************/ 6 | #include "MySql.h" 7 | #include "PyCall.h" 8 | #include "GetTime.h" 9 | #include "canbus.h" 10 | #include "pharse.h" 11 | #include "sys/time.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | #define STEPTIME 100 //ms 19 | 20 | #define CSV_NAME_SIZE 50 21 | #define MAX_FILE_NUMBER 3 22 | #define DATATRIGSIZE 200 // 23 | 24 | long long sqlCounter = 1; 25 | const char *g_host_name = "localhost"; 26 | const char *g_user_name = "root"; 27 | const char *g_password = "nvidia"; 28 | const char *g_db_name = "test"; 29 | const unsigned int g_db_port = 3306; 30 | 31 | struct timeval t_start; 32 | struct timeval t_end; 33 | 34 | void print_mysql_error(const char *msg) 35 | { 36 | if(msg) 37 | printf("%s:%s\n", msg, mysql_error(g_conn)); 38 | else 39 | puts(mysql_error(g_conn)); 40 | } 41 | 42 | /*execute the MySql language 43 | const char *sql : the MySql language to be executed 44 | */ 45 | int executesql(const char *sql) 46 | { 47 | if(mysql_real_query(g_conn, sql,strlen(sql))) 48 | return -1; 49 | return 0; 50 | } 51 | 52 | int init_mysql() 53 | { 54 | g_conn = mysql_init(NULL); 55 | if(!mysql_real_connect(g_conn, g_host_name, g_user_name, g_password, g_db_name, g_db_port, NULL, 0)) 56 | return -1; 57 | 58 | if(executesql("set names utf8")) 59 | return -1; 60 | 61 | return 0; 62 | } 63 | 64 | int CreateTable(char* sqlbuf, char * tableName, BO_Unit_t **boList) 65 | { 66 | int i = 0; 67 | int j = 0; 68 | /*Create an new table named by date and time */ 69 | sprintf(sqlbuf, "create table t_%s (id int(32) primary key auto_increment not null);", tableName); 70 | printf(">>>%s\n",sqlbuf); 71 | if(executesql(sqlbuf)) 72 | print_mysql_error(NULL); 73 | memset(sqlbuf, 0, MAX_BUF_SIZE); 74 | 75 | 76 | /*iterate the boList to establish the table*/ 77 | while(boList[i]) 78 | { 79 | printf(">>>%s\n",boList[i]->message_name); 80 | while(boList[i]->SG_List[j]) 81 | { 82 | printf(" %s\n",boList[i]->SG_List[j]->signal_name); 83 | sprintf(sqlbuf, "alter table t_%s add %s double(6,2)", tableName, boList[i]->SG_List[j]->signal_name); 84 | if(executesql(sqlbuf)) 85 | print_mysql_error(NULL); 86 | memset(sqlbuf, 0, MAX_BUF_SIZE); 87 | j++; 88 | } 89 | j = 0; 90 | i++; 91 | } 92 | return 1; 93 | } 94 | 95 | void CanbusRecord(mySqlTask_t *taskArg) 96 | { 97 | int i = 0; 98 | int j = 0; 99 | sprintf(taskArg->sqlbuf, "insert into t_%s (id) values(%lld);",taskArg->tableName,sqlCounter); 100 | if(executesql(taskArg->sqlbuf)) 101 | print_mysql_error(NULL); 102 | memset(taskArg->sqlbuf, 0, MAX_BUF_SIZE); 103 | while(taskArg->boList[i]) 104 | { 105 | //printf(">>>%s\n",taskArg->boList[i]->message_name); 106 | while(taskArg->boList[i]->SG_List[j]) 107 | { 108 | //printf(" %s\n",taskArg->boList[i]->SG_List[j]->signal_name); 109 | sprintf(taskArg->sqlbuf, "update t_%s set %s = %.2lf where id = %lld", taskArg->tableName, taskArg->boList[i]->SG_List[j]->signal_name, taskArg->boList[i]->SG_List[j]->value,sqlCounter); 110 | if(executesql(taskArg->sqlbuf)) 111 | { 112 | print_mysql_error(NULL); 113 | //printf("ERR>>> %s\n<<",taskArg->sqlbuf); 114 | } 115 | memset(taskArg->sqlbuf, 0, MAX_BUF_SIZE); 116 | j++; 117 | } 118 | j = 0; 119 | i++; 120 | } 121 | sqlCounter++; 122 | } 123 | 124 | 125 | extern void PrintTask(void); 126 | /*mysql record test program*/ 127 | void CanbusMySqlTest() 128 | { 129 | pthread_t showThread; 130 | pthread_create(&showThread, NULL, (void *)PrintTask, NULL); //创建打印线程 131 | char date[30]; //date is the TableName!!! 132 | char sql[MAX_BUF_SIZE]; 133 | mySqlTask_t task; 134 | task.boList = BO_List; 135 | task.sqlbuf = sql; 136 | task.tableName = date; 137 | 138 | /*Get current Time*/ 139 | GetTime(&timeSaved,timeDate,date); 140 | printf("Date>>>%s",date); 141 | 142 | /*init MySql*/ 143 | if(init_mysql()); 144 | print_mysql_error(NULL); 145 | 146 | /*Create a blank table*/ 147 | CreateTable(sql, date, BO_List); 148 | int nbytes = 0; 149 | canBus_t *CAN0 = CanBusInit("can0");//初始化can设备 150 | int counter = 0; 151 | while(1) 152 | { 153 | gettimeofday(&t_start,NULL); 154 | nbytes = read(CAN0->canFd, &CAN0->recvBuffer, sizeof(struct can_frame)); 155 | if(nbytes > 0) 156 | { 157 | parse3(&CAN0->recvBuffer,BO_List); 158 | CanbusRecord(&task); 159 | counter ++; 160 | //printf("sum = %d\n",counter); 161 | } 162 | gettimeofday(&t_end,NULL); 163 | //printf("time>> %ld,%ld\n",t_end.tv_sec - t_start.tv_sec,t_end.tv_usec - t_start.tv_usec ); 164 | //usleep(10*1000); 165 | } 166 | } 167 | 168 | void CreateCsv(FILE ** f,char *fname) 169 | { 170 | *f = fopen(fname,"w+"); 171 | int i = 0, j = 0; 172 | //Create csv list tittle 173 | while(BO_List[i]) 174 | { 175 | //printf(">>>%s\n",taskArg->boList[i]->message_name); 176 | while(BO_List[i]->SG_List[j]) 177 | { 178 | fwrite(BO_List[i]->SG_List[j]->signal_name,1,strlen(BO_List[i]->SG_List[j]->signal_name),*f); 179 | fwrite(",",1,1,*f); 180 | //printf("write once\n"); 181 | j++; 182 | } 183 | j = 0; 184 | i++; 185 | } 186 | fwrite("\n",1,1,*f); 187 | } 188 | //void RecordData(FILE ** f) 189 | void RecordData(FILE ** f) 190 | { 191 | //printf("record thread starting!\n"); 192 | int i = 0, j = 0; 193 | //Create csv list tittle 194 | while(BO_List[i]) 195 | { 196 | //printf(">>>%s\n",taskArg->boList[i]->message_name); 197 | while(BO_List[i]->SG_List[j]) 198 | { 199 | fprintf(*f,"%f",BO_List[i]->SG_List[j]->value); 200 | fwrite(",",1,1,*f); 201 | //printf("write once\n"); 202 | j++; 203 | } 204 | j = 0; 205 | i++; 206 | } 207 | fwrite("\n",1,1,*f); 208 | usleep(STEPTIME*1000); 209 | } 210 | 211 | void * CsvThread(void *arg) 212 | { 213 | csvTask_t* argIn = (csvTask_t*)arg; 214 | 215 | FILE ** f = argIn->fptr; 216 | int i = 0, j = 0; 217 | while(1) 218 | { 219 | while(BO_List[i]) 220 | { 221 | //printf(">>>%s\n",taskArg->boList[i]->message_name); 222 | while(BO_List[i]->SG_List[j]) 223 | { 224 | int a; 225 | a = fprintf(*f,"%f",BO_List[i]->SG_List[j]->value); 226 | printf("write :%d\n",a); 227 | //fwrite(",",1,1,recordFile); 228 | fprintf(*f,","); 229 | j++; 230 | } 231 | j = 0; 232 | i++; 233 | } 234 | fwrite("\n",1,1,*f); 235 | usleep(STEPTIME*1000); 236 | } 237 | } 238 | 239 | int AddCsvFile(csvFileList_t* list,char* fileName) 240 | { 241 | if(list->counter < MAX_FILE_NUMBER) 242 | { 243 | strcpy(list->fileNameList[list->counter],fileName); 244 | list->counter++; 245 | } 246 | if(list->counter == MAX_FILE_NUMBER) 247 | { 248 | if(-1 == remove(list->fileNameList[0])) 249 | printf("remove file error!"); 250 | int i; 251 | for(i = 0; i< list->counter; i++) 252 | { 253 | strcpy(list->fileNameList[i],list->fileNameList[i+1]); 254 | } 255 | strcpy(list->fileNameList[list->counter - 1],fileName); 256 | list->counter--; 257 | } 258 | return 0; 259 | } 260 | 261 | 262 | 263 | void RecordDataCsv() 264 | { 265 | long counter = 0; 266 | unsigned short csvFileCounter = 0; 267 | char csvName[CSV_NAME_SIZE]; //date is the TableName!!! 268 | csvFileList_t csvList; 269 | memset(&csvList, 0, sizeof(csvList)); 270 | pthread_t pytask; 271 | pyCallTask_t pyTask; 272 | GetTime(&timeSaved, timeDate, csvName); 273 | strcat(csvName,".csv"); 274 | //sprintf(csvName, "%s.csv", csvName); 275 | if(0 == access(csvName,0)) 276 | { 277 | strtok(csvName,"."); 278 | strcat(csvName,"_new.csv"); 279 | CreateCsv(&recordFile,csvName); 280 | AddCsvFile(&csvList,csvName); 281 | csvFileCounter ++; 282 | } 283 | else 284 | { 285 | CreateCsv(&recordFile,csvName); 286 | AddCsvFile(&csvList,csvName); 287 | csvFileCounter++; 288 | } 289 | 290 | pyTask.fileName = (char *)malloc(50); 291 | // pthread_t recordThread; 292 | // pthread_create(&recordThread,NULL,RecordData,&recordFile); 293 | // csvTask_t csvarg; 294 | // csvarg.fptr = &recordFile; 295 | // 296 | // pthread_t csvThread; 297 | // pthread_create(&csvThread,NULL,CsvThread,&csvarg); 298 | while(1) 299 | { 300 | RecordData(&recordFile); 301 | counter ++; 302 | 303 | system("clear"); 304 | printf("size is %ld\n",counter); 305 | fflush(stdout); 306 | 307 | if(counter >= DATATRIGSIZE) 308 | { 309 | //printf("size is triged!\n"); 310 | counter = 0; 311 | fclose(recordFile); //close file! 312 | printf("call py funciotn!\n"); 313 | /*cal py*/ 314 | //pyTask.fileName = csvName; 315 | strcpy(pyTask.fileName,csvName); 316 | pyTask.fun = "readcsv"; 317 | pyTask.module = "test01"; 318 | pthread_create(&pytask,NULL,PyProcessThread,&pyTask); 319 | 320 | //memset(&pyTask,0,sizeof(pyTask)); 321 | //PyCallfun("test01", "readcsv", csvName); 322 | printf("done!\n"); 323 | 324 | /*done*/ 325 | memset(csvName,0,CSV_NAME_SIZE); 326 | GetTime(&timeSaved, timeDate, csvName); //create new file 327 | strcat(csvName,".csv"); 328 | if(0 == access(csvName,0)) 329 | { 330 | strtok(csvName,"."); 331 | strcat(csvName,"_new.csv"); 332 | CreateCsv(&recordFile,csvName); 333 | AddCsvFile(&csvList,csvName); 334 | csvFileCounter++; 335 | } 336 | else 337 | { 338 | CreateCsv(&recordFile,csvName); 339 | AddCsvFile(&csvList,csvName); 340 | csvFileCounter++; 341 | } 342 | sleep(10); 343 | } 344 | } 345 | 346 | } 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | -------------------------------------------------------------------------------- /canbus.c: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | canbus.c 3 | 创建者:黄洪磊 4 | 时间:2018/4/23 5 | 功能:实现can设备收发 6 | *******************************************************************/ 7 | #include "main.h" 8 | #include "canbus.h" 9 | #include "BO.h" 10 | #include "pharse.h" 11 | #include 12 | #include "dbc_timer.h" 13 | #include "package.h" 14 | 15 | 16 | 17 | unsigned long min_num=0; //随机发送最小值 18 | unsigned long max_num=0xffffffff; //随机发送最大值 19 | unsigned long random_num; //随机数 20 | unsigned long random_num_h ; //随机数高位 21 | unsigned long random_num_l ; //随机数低位 22 | 23 | extern struct can_frame frame ; //发送buffer 24 | 25 | /* 26 | can设备初始化函数 27 | char *interface:设备接口名 如"can0" 28 | */ 29 | int SocketCAN_init(char *interface) 30 | { 31 | //int enable_canfd = 1; 32 | 33 | //struct can_frame frame ; 34 | int can_fd; 35 | //frame_ptr = (struct can_frame *)malloc(sizeof(struct can_frame)); 36 | struct sockaddr_can addr; 37 | struct ifreq ifr; 38 | if((can_fd = socket(PF_CAN,SOCK_RAW,CAN_RAW))<0) 39 | { 40 | printf("socket err!\n"); 41 | } 42 | 43 | strcpy(ifr.ifr_name,interface); 44 | if(-1 == (ioctl(can_fd,SIOCGIFINDEX,&ifr))) 45 | { 46 | printf("ioctl err!\n"); 47 | } 48 | 49 | strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1); //pass the interface to the ifr 50 | ifr.ifr_name[IFNAMSIZ - 1] = '\0'; 51 | ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name); //check if the interface really exists 52 | if (!ifr.ifr_ifindex) { 53 | perror("if_nametoindex"); 54 | return 1; 55 | } 56 | 57 | 58 | addr.can_family = AF_CAN; 59 | addr.can_ifindex = ifr.ifr_ifindex; 60 | /*enable fd can*/ 61 | // if (setsockopt(can_fd, SOL_CAN_RAW, CAN_RAW_FD_FRAMES, 62 | // &enable_canfd, sizeof(enable_canfd))){ 63 | // printf("error when enabling CAN FD support\n"); 64 | // return 1; 65 | // } 66 | if((bind(can_fd,(struct sockaddr*)&addr,sizeof(addr))) < 0) 67 | { 68 | printf("bind err!\n"); 69 | } 70 | return can_fd; 71 | } 72 | 73 | /* 74 | can设备随机发送函数 75 | struct can_frame * frameptr:发送buffer 76 | int can_fd:can设备句柄 77 | */ 78 | int CAN_Send_Random(struct can_frame * frameptr,int can_fd) 79 | { 80 | int i; 81 | int sended_msg_num = 0; 82 | int error_msg_num = 0; 83 | frameptr->can_id = 0x123; 84 | frameptr->can_dlc = 8; 85 | //ptr convert 86 | unsigned long *tmp = (unsigned long *)(frameptr->data); 87 | //create random number 88 | random_num_h = (rand()%(max_num-min_num+1)+min_num); 89 | random_num_l = (rand()%(max_num-min_num+1)+min_num); 90 | 91 | random_num = ((random_num_h << 32) | random_num_l); 92 | //by pass the randomnum 93 | *tmp = random_num; 94 | //transmit the msg 95 | int nbytes = write(can_fd,frameptr,sizeof(*frameptr)); 96 | 97 | //for show 98 | //reverse the msg! 99 | if(nbytes == sizeof(*frameptr)) 100 | { 101 | for(i = 0;i<4;i++) 102 | { 103 | unsigned char show_num = random_num_l >> 8*i; 104 | printf("%X " , show_num); 105 | } 106 | printf("\t"); 107 | for(i = 0;i<4;i++) 108 | { 109 | unsigned char show_num = random_num_h >> 8*i; 110 | printf("%X " , show_num); 111 | } 112 | printf("\n"); 113 | sended_msg_num++; 114 | 115 | } 116 | if(nbytes != sizeof(*frameptr)) 117 | { 118 | #ifdef SNDDEBUG 119 | printf("send err!"); 120 | printf("nbytes is :%d\n",nbytes); 121 | #endif 122 | error_msg_num ++; 123 | } 124 | return 0; 125 | } 126 | 127 | /* 128 | canbus初始化函数 129 | char *interface:can设备接口名 130 | canBus_t * :返回的canbus结构体 131 | */ 132 | canBus_t * CanBusInit(char *interface) 133 | { 134 | canBus_t *canbus_ptr = (canBus_t *)malloc(sizeof(canBus_t)); 135 | memset(canbus_ptr, 0, sizeof(canBus_t)); 136 | pthread_mutex_init(&canbus_ptr->rdwrLock, NULL); 137 | struct sockaddr_can addr; 138 | struct ifreq ifr; 139 | if((canbus_ptr->canFd = socket(PF_CAN,SOCK_RAW,CAN_RAW))<0) 140 | { 141 | printf("socket err!\n"); 142 | } 143 | strcpy(ifr.ifr_name,interface); 144 | if(-1 == (ioctl(canbus_ptr->canFd,SIOCGIFINDEX,&ifr))) 145 | { 146 | printf("ioctl err!\n"); 147 | } 148 | 149 | strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1); //pass the interface to the ifr 150 | ifr.ifr_name[IFNAMSIZ - 1] = '\0'; 151 | ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name); //check if the interface really exists 152 | if (!ifr.ifr_ifindex) { 153 | perror("if_nametoindex"); 154 | return 0; 155 | } 156 | addr.can_family = AF_CAN; 157 | addr.can_ifindex = ifr.ifr_ifindex; 158 | 159 | if((bind(canbus_ptr->canFd,(struct sockaddr*)&addr,sizeof(addr))) < 0) 160 | { 161 | printf("bind err!\n"); 162 | } 163 | 164 | return canbus_ptr; 165 | } 166 | 167 | 168 | /* 169 | canbus接收线程 170 | canBus_t *can:用于执行线程的结构体 171 | */ 172 | void CanRecvThread(canBus_t *can) 173 | { 174 | int nbytes; 175 | while(1) 176 | { 177 | nbytes = read(can->canFd, &can->recvBuffer, sizeof(struct can_frame)); //œÓÊÕ±šÎÄ//ÏÔÊŸ±šÎÄ 178 | if(nbytes > 0) 179 | { 180 | parse3(&can->recvBuffer,BO_List); 181 | 182 | } 183 | } 184 | } 185 | /* 186 | 回环线程 187 | */ 188 | void CanRecvLoopBack(canBus_t *can) 189 | { 190 | int nbytes; 191 | while(1) 192 | { 193 | nbytes = read(can->canFd, &can->recvBuffer, sizeof(struct can_frame)); //œÓÊÕ±šÎÄ//ÏÔÊŸ±šÎÄ 194 | if(nbytes > 0) 195 | { 196 | parse3(&can->recvBuffer,BO_List); 197 | int n =0; 198 | while(BO_List[n] != NULL) 199 | { 200 | if(BO_List[n]->message_id == can->recvBuffer.can_id) 201 | { 202 | int m = 0; 203 | while(BO_List[n]->SG_List[m] != NULL) /*SG_LOOP*/ 204 | { 205 | BO_List[n]->SG_List[m]->value_send = BO_List[n]->SG_List[m]->value; //bypass phy value 206 | m ++; 207 | } 208 | break; 209 | } 210 | n++; 211 | } 212 | } 213 | } 214 | } 215 | /* 216 | can设备发送线程 217 | */ 218 | void CanSendThread(taskArg_t *arg) 219 | { 220 | package_bo3(&arg->can->sendBuffer,BO_List,arg->boId); 221 | 222 | pthread_mutex_lock(&arg->can->rdwrLock); 223 | 224 | write(arg->can->canFd,&arg->can->sendBuffer,sizeof(struct can_frame)); 225 | 226 | pthread_mutex_unlock(&arg->can->rdwrLock); 227 | 228 | memset(&arg->can->sendBuffer,0,sizeof(struct can_frame)); 229 | printf("send thread done!\n"); 230 | } 231 | 232 | void CanProcessThread() 233 | { 234 | 235 | 236 | 237 | 238 | } 239 | 240 | extern void PrintTask(void); 241 | pthread_t printThread; 242 | 243 | /* 244 | 采用10ms 20ms 50ms 100ms的测试程序 245 | */ 246 | int CanBusTestMode() 247 | { 248 | timerThread = TimerRoutineInit();//初始化timer线程 249 | canBus_t *CAN0 = CanBusInit("can0");//初始化can设备 250 | canBus_t *CAN1 = CanBusInit("can1"); 251 | pthread_t canRecvCan0; //can0接收线程句柄 252 | pthread_t canRecvCan1; 253 | pthread_create(&canRecvCan0,NULL,(void *)CanRecvLoopBack,CAN0);//创建can0回环线程 254 | pthread_create(&canRecvCan1,NULL,(void *)CanRecvLoopBack,CAN1); 255 | 256 | pthread_create(&printThread, NULL, (void *)PrintTask, NULL); //创建打印线程 257 | 258 | /*创建一个任务*/ 259 | TaskAdd_t MASTER_CTRL_ESA_Task;//创建任务名 260 | MASTER_CTRL_ESA_Task.task = CanSendThread;//任务为发送线程 261 | MASTER_CTRL_ESA_Task.arg.boId = 1366;//获取的canbus报文为1366 262 | MASTER_CTRL_ESA_Task.arg.can = CAN1;//操作的设备为can1 263 | AddTimerTask(&MASTER_CTRL_ESA_Task, _10msTask);//添加任务,任务循环时间为10ms 264 | 265 | TaskAdd_t MASTER_CTRL_REQ_Task; 266 | MASTER_CTRL_REQ_Task.task = CanSendThread; 267 | MASTER_CTRL_REQ_Task.arg.boId = 1364; 268 | MASTER_CTRL_REQ_Task.arg.can = CAN1; 269 | AddTimerTask(&MASTER_CTRL_REQ_Task, _10msTask); 270 | 271 | TaskAdd_t SCU_STATUS_Task; 272 | SCU_STATUS_Task.task = CanSendThread; 273 | SCU_STATUS_Task.arg.boId = 1619; 274 | SCU_STATUS_Task.arg.can = CAN0; 275 | AddTimerTask(&SCU_STATUS_Task, _10msTask); 276 | 277 | TaskAdd_t SCU_DIAG_Task; 278 | SCU_DIAG_Task.task = CanSendThread; 279 | SCU_DIAG_Task.arg.boId = 1621; 280 | SCU_DIAG_Task.arg.can = CAN0; 281 | AddTimerTask(&SCU_DIAG_Task, _100msTask); 282 | 283 | TaskAdd_t SCU_FUNCTIONAL_Task; 284 | SCU_FUNCTIONAL_Task.task = CanSendThread; 285 | SCU_FUNCTIONAL_Task.arg.boId = 1620; 286 | SCU_FUNCTIONAL_Task.arg.can = CAN0; 287 | AddTimerTask(&SCU_FUNCTIONAL_Task, _10msTask); 288 | 289 | TaskAdd_t SCU_PREDICTION_Task; 290 | SCU_PREDICTION_Task.task = CanSendThread; 291 | SCU_PREDICTION_Task.arg.boId = 1624; 292 | SCU_PREDICTION_Task.arg.can = CAN0; 293 | AddTimerTask(&SCU_PREDICTION_Task, _10msTask); 294 | while(1); 295 | return 0; 296 | } 297 | 298 | /* 299 | 采用多进程的回环测试程序 300 | */ 301 | void PthreadCanbusTest() 302 | { 303 | pthread_t showThread; 304 | pthread_create(&showThread, NULL, (void *)PrintTask, NULL); //创建打印线程 305 | canBus_t *CAN0 = CanBusInit("can0");//初始化can设备 306 | canBus_t *CAN1 = CanBusInit("can1"); 307 | 308 | pid_t pid; 309 | pid = fork(); 310 | /* 311 | 创建两个进程 312 | 一个进程为can0收can1发 313 | 另一个为can1收can0发 314 | */ 315 | if((pid) == 0) 316 | { 317 | printf("Child thread in progress\n"); 318 | int nbytes; 319 | while(1) 320 | { 321 | nbytes = read(CAN0->canFd, &CAN0->recvBuffer, sizeof(struct can_frame)); //œÓÊÕ±šÎÄ//ÏÔÊŸ±šÎÄ 322 | if(nbytes > 0) 323 | { 324 | parse3(&CAN0->recvBuffer,BO_List); 325 | /*loop back*/ 326 | int n =0; 327 | while(BO_List[n] != NULL) 328 | { 329 | if(BO_List[n]->message_id == CAN0->recvBuffer.can_id) 330 | { 331 | int m = 0; 332 | while(BO_List[n]->SG_List[m] != NULL) /*SG_LOOP*/ 333 | { 334 | BO_List[n]->SG_List[m]->value_send = BO_List[n]->SG_List[m]->value; //bypass phy value 335 | m ++; 336 | } 337 | break; 338 | } 339 | n++; 340 | } 341 | /*package*/ 342 | package_bo3(&CAN0->sendBuffer,BO_List,CAN0->recvBuffer.can_id); 343 | /*send*/ 344 | nbytes = write(CAN0->canFd,&CAN0->sendBuffer,sizeof(struct can_frame)); 345 | memset(&CAN0->sendBuffer,0,sizeof(struct can_frame)); 346 | } 347 | } 348 | } 349 | else if(pid > 0) 350 | { 351 | printf("Father thread in progress!\n"); 352 | int nbytes; 353 | while(1) 354 | { 355 | nbytes = read(CAN1->canFd, &CAN1->recvBuffer, sizeof(struct can_frame)); //œÓÊÕ±šÎÄ//ÏÔÊŸ±šÎÄ 356 | if(nbytes > 0) 357 | { 358 | parse3(&frame,BO_List); 359 | /*loop back*/ 360 | int n =0; 361 | while(BO_List[n] != NULL) 362 | { 363 | if(BO_List[n]->message_id == CAN1->recvBuffer.can_id) 364 | { 365 | int m = 0; 366 | while(BO_List[n]->SG_List[m] != NULL) /*SG_LOOP*/ 367 | { 368 | BO_List[n]->SG_List[m]->value_send = BO_List[n]->SG_List[m]->value; //bypass phy value 369 | m ++; 370 | } 371 | break; 372 | } 373 | n++; 374 | } 375 | /*package*/ 376 | package_bo3(&CAN1->sendBuffer,BO_List,CAN1->recvBuffer.can_id); 377 | /*send*/ 378 | nbytes = write(CAN1->canFd,&CAN1->sendBuffer,sizeof(struct can_frame)); 379 | memset(&CAN1->sendBuffer,0,sizeof(struct can_frame)); 380 | } 381 | } 382 | } 383 | } 384 | 385 | 386 | void CanbusRecvRecord(canbuscmd_t* cmd) 387 | { 388 | //canBus_t *CANTASK = CanBusInit(cmd->interface);//初始化can设备 389 | canBus_t *CANTASK = CanBusInit("can0");//初始化can设备 390 | pthread_t can_recv; 391 | pthread_create(&can_recv,NULL,(void *)CanRecvThread,CANTASK);//创建can0回环线程 392 | if(cmd->show) 393 | { 394 | pthread_t showThread; 395 | pthread_create(&showThread, NULL, (void *)PrintTask, NULL); //创建打印线程 396 | } 397 | if(cmd->record) 398 | { 399 | 400 | } 401 | if(cmd->loopback) 402 | { 403 | 404 | } 405 | } 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | -------------------------------------------------------------------------------- /bin/Debug/Tx2TryDBC.dbc: -------------------------------------------------------------------------------- 1 | VERSION "" 2 | 3 | 4 | NS_ : 5 | NS_DESC_ 6 | CM_ 7 | BA_DEF_ 8 | BA_ 9 | VAL_ 10 | CAT_DEF_ 11 | CAT_ 12 | FILTER 13 | BA_DEF_DEF_ 14 | EV_DATA_ 15 | ENVVAR_DATA_ 16 | SGTYPE_ 17 | SGTYPE_VAL_ 18 | BA_DEF_SGTYPE_ 19 | BA_SGTYPE_ 20 | SIG_TYPE_REF_ 21 | VAL_TABLE_ 22 | SIG_GROUP_ 23 | SIG_VALTYPE_ 24 | SIGTYPE_VALTYPE_ 25 | BO_TX_BU_ 26 | BA_DEF_REL_ 27 | BA_REL_ 28 | BA_DEF_DEF_REL_ 29 | BU_SG_REL_ 30 | BU_EV_REL_ 31 | BU_BO_REL_ 32 | SG_MUL_VAL_ 33 | 34 | BS_: 35 | 36 | BU_: SCU BRS_ECU 37 | 38 | 39 | BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX 40 | SG_ MASTER_ESA_CheckSum : 0|8@0+ (1,0) [0|255] "" Vector__XXX 41 | SG_ MASTER_REQ_CheckSum : 0|8@0+ (1,0) [0|255] "" Vector__XXX 42 | SG_ New_Signal_263 : 0|8@1+ (1,0) [0|0] "" Vector__XXX 43 | SG_ New_Signal_262 : 0|8@1+ (1,0) [0|0] "" Vector__XXX 44 | SG_ VehV_a : 0|16@0- (0.001,0) [-32.768|32.767] "" Vector__XXX 45 | 46 | BO_ 1366 MASTER_CTRL_ESA: 8 BRS_ECU 47 | SG_ MASTER_ESA_TorqueLimitation : 7|6@0+ (-1,0) [-44|0] "Nm" SCU 48 | SG_ MASTER_ESA_Speedgradient : 10|10@0+ (-10,0) [-8000|0] "Rpm/s" SCU 49 | SG_ MASTER_ESA_EndSpeed : 1|7@0+ (10,0) [0|1000] "Rpm" SCU 50 | SG_ MASTER_ESA_DurationMax : 16|5@0+ (0.1,0) [0|2] "s" SCU 51 | SG_ MASTER_DIS_ExMaxCurrent : 27|6@0+ (0.1,0) [0|5] "A" SCU 52 | SG_ MASTER_ESA_RollingCounter : 51|4@0+ (1,0) [0|15] "" SCU 53 | SG_ MASTER_Generator_RegVoltage : 47|9@0+ (0.1,10) [20|54] "V" SCU 54 | SG_ MASTER_Generator_TrqLimitation : 37|6@0+ (-1,0) [-30|0] "Nm" SCU 55 | 56 | BO_ 1624 SCU_PREDICTION: 8 SCU 57 | SG_ SCU_Negative_Trq_Prediction_10s : 13|10@0+ (0.1,-55) [-55|0] "" BRS_ECU 58 | SG_ SCU_PREDICTION_CheckSum : 63|8@0+ (1,0) [0|255] "" BRS_ECU 59 | SG_ SCU_PREDICTION_RollingCounter : 51|4@0+ (1,0) [0|15] "" BRS_ECU 60 | SG_ SCU_Positive_Trq_Prediction_10s : 7|10@0+ (0.1,0) [0|55] "NM" BRS_ECU 61 | 62 | BO_ 1621 SCU_DIAG: 8 SCU 63 | SG_ SCU_12V_VOLTAGE_LOW : 36|1@0+ (1,0) [0|1] "" BRS_ECU 64 | SG_ SCU_REVERSE_SPEED_FAULT : 35|1@0+ (1,0) [0|1] "" BRS_ECU 65 | SG_ SCU_12V_VOLTAGE_HIGH : 37|1@0+ (1,0) [0|1] "" BRS_ECU 66 | SG_ SCU_BUSOFF_FAULT : 38|1@0+ (1,0) [0|1] "" BRS_ECU 67 | SG_ SCU_UNLOCK_PTL_FAULT : 20|1@0+ (1,0) [0|1] "" BRS_ECU 68 | SG_ SCU_DIAG_RollingCounter : 51|4@0+ (1,0) [0|15] "" BRS_ECU 69 | SG_ SCU_DIAG_CheckSum : 63|8@0+ (1,0) [0|255] "" BRS_ECU 70 | SG_ SCU_BRUSH_WEAR_FAULT : 27|1@0+ (1,0) [0|1] "" BRS_ECU 71 | SG_ SCU_EXC_OPENCIRCUIT_FAULT : 39|1@0+ (1,0) [0|1] "" BRS_ECU 72 | SG_ SCU_EXC_LATENT_FAULT : 24|1@0+ (1,0) [0|1] "" BRS_ECU 73 | SG_ SCU_EXC_HSM_FAULT : 25|1@0+ (1,0) [0|1] "" BRS_ECU 74 | SG_ SCU_CAN_COM_ERROR : 26|1@0+ (1,0) [0|1] "" BRS_ECU 75 | SG_ SCU_DC_VOLTAGEMEAS_SENSOR_FAULT : 28|1@0+ (1,0) [0|1] "" BRS_ECU 76 | SG_ SCU_PHX_CURRENT_SENSOR_FAULT : 17|3@0+ (1,0) [0|6] "" BRS_ECU 77 | SG_ SCU_MACHINE_TEMP_SENSOR_FAULT : 18|1@0+ (1,0) [0|1] "" BRS_ECU 78 | SG_ SCU_INVERTER_TEMP_SENSOR_FAULT : 19|1@0+ (1,0) [0|1] "" BRS_ECU 79 | SG_ SCU_POSITION_SENSORS_FAULT : 21|1@0+ (1,0) [0|1] "" BRS_ECU 80 | SG_ SCU_STATOR_FAULT : 22|1@0+ (1,0) [0|1] "" BRS_ECU 81 | SG_ SCU_INVERTER_FAULT : 23|1@0+ (1,0) [0|1] "" BRS_ECU 82 | SG_ SCU_TORQUE_CTRL_TIMEOUT : 8|1@0+ (1,0) [0|1] "" BRS_ECU 83 | SG_ SCU_TORQUE_SIGN_FAULT : 9|1@0+ (1,0) [0|1] "" BRS_ECU 84 | SG_ SCU_TORQUE_LEVEL_FAULT : 10|1@0+ (1,0) [0|1] "" BRS_ECU 85 | SG_ SCU_ROTOR_OVERCURRENT : 11|1@0+ (1,0) [0|1] "" BRS_ECU 86 | SG_ SCU_STATOR_OVERCURRENT : 14|3@0+ (1,0) [0|6] "" BRS_ECU 87 | SG_ SCU_LOADDUMP : 15|1@0+ (1,0) [0|1] "" BRS_ECU 88 | SG_ SCU_OVERVOLTAGE : 0|1@0+ (1,0) [0|1] "" BRS_ECU 89 | SG_ SCU_MOSFET_JUNCTION_PROTECTION : 1|1@0+ (1,0) [0|1] "" BRS_ECU 90 | SG_ SCU_OVERHEATING : 2|1@0+ (1,0) [0|1] "" BRS_ECU 91 | SG_ SCU_STARTER_WARNING : 3|1@0+ (1,0) [0|1] "" BRS_ECU 92 | SG_ SCU_THERMAL_DERATING : 4|1@0+ (1,0) [0|1] "" BRS_ECU 93 | SG_ SCU_STALLED_ROTOR_PROTECTION : 6|1@0+ (1,0) [0|1] "" BRS_ECU 94 | SG_ SCU_TORQUE_SUSPENSION : 7|1@0+ (1,0) [0|1] "" BRS_ECU 95 | 96 | BO_ 1620 SCU_FUNCTIONAL: 8 SCU 97 | SG_ SCU_FUNCTIONAL_RollingCounter : 51|4@0+ (1,0) [0|15] "" BRS_ECU 98 | SG_ SCU_FUNCTIONAL_CheckSum : 63|8@0+ (1,0) [0|255] "" BRS_ECU 99 | SG_ SCU_Positive_Trq_Prediction_1s : 12|10@0+ (0.1,0) [0|55] "Nm" BRS_ECU 100 | SG_ SCU_Negative_Trq_Prediction_1s : 18|10@0+ (-0.1,0) [-55|0] "Nm" BRS_ECU 101 | SG_ SCU_IDC_Current : 24|10@0+ (1,-400) [-400|400] "A" BRS_ECU 102 | SG_ SCU_Estimated_Torque : 7|11@0+ (0.1,-55) [-55|55] "Nm" BRS_ECU 103 | 104 | BO_ 1364 MASTER_CTRL_REQ: 8 BRS_ECU 105 | SG_ MASTER_REQ_RollingCounter : 51|4@0+ (1,0) [0|15] "" SCU 106 | SG_ MASTER_TRQCTRL_POS_TRQ_LIM : 3|6@0+ (1,0) [0|55] "Nm" SCU 107 | SG_ MASTER_TRQCTRL_NEG_TRQ_LIM : 13|6@0+ (-1,0) [-44|0] "Nm" SCU 108 | SG_ MASTER_NEGATIVE_TORQUE_GRADIENT : 24|7@0+ (-10,0) [-1000|0] "Nm/s" SCU 109 | SG_ MASTER_POSITIVE_TORQUE_GRADIENT : 31|7@0+ (10,0) [0|1000] "Nm/s" SCU 110 | SG_ MASTER_TorqueCtrl_RegTorque : 23|8@0+ (0.5,-44) [-44|55] "Nm" SCU 111 | SG_ MASTER_MM_REQUEST : 7|4@0+ (1,0) [1|8] "" SCU 112 | 113 | BO_ 1619 SCU_STATUS: 8 SCU 114 | SG_ SCU_STATUS_RollingCounter : 51|4@0+ (1,0) [0|15] "" BRS_ECU 115 | SG_ SCU_STATUS_CheckSum : 63|8@0+ (1,0) [0|255] "" BRS_ECU 116 | SG_ CRANK_POSSIBLE_IF_STOPPED : 43|1@0+ (1,0) [0|1] "" BRS_ECU 117 | SG_ SCU_ENA_STATUS : 44|1@0+ (1,0) [0|1] "" BRS_ECU 118 | SG_ iBSG_Temperature_Rate : 31|7@0+ (1,0) [0|120] "%" BRS_ECU 119 | SG_ SCU_Rotor_Speed : 15|15@0+ (1,-2000) [-2000|22000] "Rpm" BRS_ECU 120 | SG_ SCU_BUS_VOLTAGE : 24|12@0+ (0.02,0) [0|70] "V" BRS_ECU 121 | SG_ SCU_MM_STATUS : 7|8@0+ (1,0) [16|131] "" BRS_ECU 122 | 123 | 124 | 125 | CM_ BO_ 3221225472 "This is a message for not used signals, created by Vector CANdb++ DBC OLE DB Provider."; 126 | CM_ SG_ 3221225472 VehV_a "The acceleration of the vehicle"; 127 | CM_ SG_ 1366 MASTER_ESA_TorqueLimitation "Torque limitation set point in ESA mode"; 128 | CM_ SG_ 1366 MASTER_ESA_Speedgradient "Negative speed gradient in ESA mode"; 129 | CM_ SG_ 1366 MASTER_ESA_EndSpeed "Machine end speed for ESA mode"; 130 | CM_ SG_ 1366 MASTER_ESA_DurationMax "Maximum duration of ESA"; 131 | CM_ SG_ 1366 MASTER_DIS_ExMaxCurrent "Maximum excitation current during discharge"; 132 | CM_ SG_ 1366 MASTER_Generator_RegVoltage "Voltage regulation Value in GENERATOR mode"; 133 | CM_ SG_ 1366 MASTER_Generator_TrqLimitation "Machine torque limitation in GENERATOR mode"; 134 | CM_ BO_ 1621 "Signal description for Diagnostics"; 135 | CM_ SG_ 1621 SCU_EXC_OPENCIRCUIT_FAULT "Rotor open circuit detection"; 136 | CM_ SG_ 1621 SCU_EXC_LATENT_FAULT "Excitation circuit DMAG mosfet failure detection"; 137 | CM_ SG_ 1621 SCU_EXC_HSM_FAULT "Excitation circuit High side mosfet failure detection"; 138 | CM_ SG_ 1621 SCU_CAN_COM_ERROR "CAN fault detection"; 139 | CM_ SG_ 1621 SCU_DC_VOLTAGEMEAS_SENSOR_FAULT "+BAT48V Voltage sensor fault detection"; 140 | CM_ SG_ 1621 SCU_PHX_CURRENT_SENSOR_FAULT "Phase current sensor fault detection"; 141 | CM_ SG_ 1621 SCU_MACHINE_TEMP_SENSOR_FAULT "Temperature sensor fault detection on Stator"; 142 | CM_ SG_ 1621 SCU_INVERTER_TEMP_SENSOR_FAULT "Temperature sensor fault detection on Control board"; 143 | CM_ SG_ 1621 SCU_POSITION_SENSORS_FAULT "Power module failure detection in functional mode"; 144 | CM_ SG_ 1621 SCU_STATOR_FAULT "Power module failure detection in functional mode"; 145 | CM_ SG_ 1621 SCU_INVERTER_FAULT "Power module failure detection in functional mode"; 146 | CM_ SG_ 1621 SCU_TORQUE_CTRL_TIMEOUT "Torque control mode timeout detection at max current"; 147 | CM_ SG_ 1621 SCU_TORQUE_SIGN_FAULT "Unexpected torque sign detection"; 148 | CM_ SG_ 1621 SCU_TORQUE_LEVEL_FAULT "Unexpected torque level detection"; 149 | CM_ SG_ 1621 SCU_ROTOR_OVERCURRENT "Rotor over current detection in functional mode"; 150 | CM_ SG_ 1621 SCU_STATOR_OVERCURRENT "Functional Phase over current detection"; 151 | CM_ SG_ 1621 SCU_LOADDUMP "LOADDUMP detection on +BAT48V"; 152 | CM_ SG_ 1621 SCU_OVERVOLTAGE "Too high voltage detection on +BAT48V detection"; 153 | CM_ SG_ 1621 SCU_MOSFET_JUNCTION_PROTECTION "Power module junction temperature overheating detection in functional mode"; 154 | CM_ SG_ 1621 SCU_OVERHEATING "Thermal overheating protection Flag for stator, rotor, Power module, Control Board and Excitation board"; 155 | CM_ SG_ 1621 SCU_STARTER_WARNING "Starter mode warning detection due to high temperature"; 156 | CM_ SG_ 1621 SCU_THERMAL_DERATING "Output Power Derating due to temperature"; 157 | CM_ SG_ 1621 SCU_STALLED_ROTOR_PROTECTION "Inverter thermal protection during cranking phase (stalled rotor)"; 158 | CM_ SG_ 1621 SCU_TORQUE_SUSPENSION "Negative speed detection in during a start attempt"; 159 | CM_ BO_ 1620 "Return Machine Inverter Torque data"; 160 | CM_ SG_ 1620 SCU_IDC_Current "Continuous side current during Machine Mode"; 161 | CM_ SG_ 1620 SCU_Estimated_Torque "Instantaneous estimated torque "; 162 | CM_ BO_ 1364 "Send Machine Inverter Control Request"; 163 | CM_ SG_ 1364 MASTER_TRQCTRL_POS_TRQ_LIM "Positive torque limitation in torque control mode"; 164 | CM_ SG_ 1364 MASTER_TRQCTRL_NEG_TRQ_LIM "Negative torque limitation in torque control mode"; 165 | CM_ SG_ 1364 MASTER_NEGATIVE_TORQUE_GRADIENT "Negative Torque Gradient"; 166 | CM_ SG_ 1364 MASTER_POSITIVE_TORQUE_GRADIENT "Positive Torque Gradient"; 167 | CM_ SG_ 1364 MASTER_TorqueCtrl_RegTorque "Torque request parameter"; 168 | CM_ SG_ 1364 MASTER_MM_REQUEST "Requested Mode"; 169 | CM_ BO_ 1619 "Return Machine Inverter Status"; 170 | CM_ SG_ 1619 CRANK_POSSIBLE_IF_STOPPED "Engine status for restart need"; 171 | CM_ SG_ 1619 SCU_ENA_STATUS "SCU mode enable status"; 172 | CM_ SG_ 1619 iBSG_Temperature_Rate "IBSG Temperature Rate"; 173 | CM_ SG_ 1619 SCU_Rotor_Speed "Mechanical Machine Speed"; 174 | CM_ SG_ 1619 SCU_BUS_VOLTAGE "+BAT48V storage voltage"; 175 | CM_ SG_ 1619 SCU_MM_STATUS "Machine functional status"; 176 | BA_DEF_ BO_ "GenMsgILSupport" ENUM "No","Yes"; 177 | BA_DEF_ SG_ "GenSigStartValue" INT 0 0; 178 | BA_DEF_ BO_ "GenMsgSendType" ENUM "Cyclic"; 179 | BA_DEF_ BO_ "GenMsgCycleTime" INT 10 1000; 180 | BA_DEF_ "BusType" STRING ; 181 | BA_DEF_DEF_ "GenMsgILSupport" "Yes"; 182 | BA_DEF_DEF_ "GenSigStartValue" 0; 183 | BA_DEF_DEF_ "GenMsgSendType" "Cyclic"; 184 | BA_DEF_DEF_ "GenMsgCycleTime" 10; 185 | BA_DEF_DEF_ "BusType" ""; 186 | BA_ "BusType" "CAN"; 187 | BA_ "GenMsgCycleTime" BO_ 1621 100; 188 | BA_ "GenSigStartValue" SG_ 1366 MASTER_ESA_TorqueLimitation -0; 189 | BA_ "GenSigStartValue" SG_ 1366 MASTER_ESA_Speedgradient 200; 190 | BA_ "GenSigStartValue" SG_ 1366 MASTER_ESA_EndSpeed 10; 191 | BA_ "GenSigStartValue" SG_ 1366 MASTER_ESA_DurationMax 10; 192 | BA_ "GenSigStartValue" SG_ 1366 MASTER_DIS_ExMaxCurrent 20; 193 | BA_ "GenSigStartValue" SG_ 1366 MASTER_Generator_RegVoltage 380; 194 | BA_ "GenSigStartValue" SG_ 1366 MASTER_Generator_TrqLimitation 10; 195 | BA_ "GenSigStartValue" SG_ 1624 SCU_Negative_Trq_Prediction_10s 550; 196 | BA_ "GenSigStartValue" SG_ 1620 SCU_Positive_Trq_Prediction_1s 500; 197 | BA_ "GenSigStartValue" SG_ 1620 SCU_Negative_Trq_Prediction_1s 440; 198 | BA_ "GenSigStartValue" SG_ 1620 SCU_IDC_Current 400; 199 | BA_ "GenSigStartValue" SG_ 1620 SCU_Estimated_Torque 550; 200 | BA_ "GenSigStartValue" SG_ 1364 MASTER_TRQCTRL_POS_TRQ_LIM 30; 201 | BA_ "GenSigStartValue" SG_ 1364 MASTER_TRQCTRL_NEG_TRQ_LIM 30; 202 | BA_ "GenSigStartValue" SG_ 1364 MASTER_NEGATIVE_TORQUE_GRADIENT 10; 203 | BA_ "GenSigStartValue" SG_ 1364 MASTER_POSITIVE_TORQUE_GRADIENT 10; 204 | BA_ "GenSigStartValue" SG_ 1364 MASTER_TorqueCtrl_RegTorque 88; 205 | BA_ "GenSigStartValue" SG_ 1364 MASTER_MM_REQUEST 1; 206 | BA_ "GenSigStartValue" SG_ 1619 SCU_Rotor_Speed 2000; 207 | BA_ "GenSigStartValue" SG_ 1619 SCU_BUS_VOLTAGE 0; 208 | BA_ "GenSigStartValue" SG_ 1619 SCU_MM_STATUS 16; 209 | VAL_ 1621 SCU_EXC_OPENCIRCUIT_FAULT 1 "Fault" 0 "No fault" ; 210 | VAL_ 1621 SCU_EXC_LATENT_FAULT 1 "Fault" 0 "No fault" ; 211 | VAL_ 1621 SCU_EXC_HSM_FAULT 1 "Fault" 0 "No fault" ; 212 | VAL_ 1621 SCU_CAN_COM_ERROR 1 "Fault" 0 "No fault" ; 213 | VAL_ 1621 SCU_DC_VOLTAGEMEAS_SENSOR_FAULT 1 "Fault" 0 "No fault" ; 214 | VAL_ 1621 SCU_PHX_CURRENT_SENSOR_FAULT 6 "Phase 6 Fault" 5 "Phase 5 Fault" 4 "Phase 4 Fault" 3 "Phase 3 Fault" 2 "Phase 2 Fault" 1 "Phase 1 Fault" 0 "No fault" ; 215 | VAL_ 1621 SCU_MACHINE_TEMP_SENSOR_FAULT 1 "Fault" 0 "No fault" ; 216 | VAL_ 1621 SCU_INVERTER_TEMP_SENSOR_FAULT 1 "Fault" 0 "No fault" ; 217 | VAL_ 1621 SCU_POSITION_SENSORS_FAULT 1 "Fault" 0 "No fault" ; 218 | VAL_ 1621 SCU_STATOR_FAULT 1 "Fault" 0 "No fault" ; 219 | VAL_ 1621 SCU_INVERTER_FAULT 1 "Fault" 0 "No fault" ; 220 | VAL_ 1621 SCU_TORQUE_CTRL_TIMEOUT 1 "Fault" 0 "No fault" ; 221 | VAL_ 1621 SCU_TORQUE_SIGN_FAULT 1 "Fault" 0 "No fault" ; 222 | VAL_ 1621 SCU_TORQUE_LEVEL_FAULT 1 "Fault" 0 "No fault" ; 223 | VAL_ 1621 SCU_ROTOR_OVERCURRENT 1 "Fault" 0 "No fault" ; 224 | VAL_ 1621 SCU_STATOR_OVERCURRENT 6 "Phase 6 Fault" 5 "Phase 5 Fault" 4 "Phase 4 Fault" 3 "Phase 3 Fault" 2 "Phase 2 Fault" 1 "Phase 1 Fault" 0 "No fault" ; 225 | VAL_ 1621 SCU_LOADDUMP 1 "Fault" 0 "No fault" ; 226 | VAL_ 1621 SCU_OVERVOLTAGE 1 "Fault" 0 "No fault" ; 227 | VAL_ 1621 SCU_MOSFET_JUNCTION_PROTECTION 1 "Fault" 0 "No fault" ; 228 | VAL_ 1621 SCU_OVERHEATING 1 "Fault" 0 "No fault" ; 229 | VAL_ 1621 SCU_STARTER_WARNING 1 "Fault" 0 "No fault" ; 230 | VAL_ 1621 SCU_THERMAL_DERATING 1 "Fault" 0 "No fault" ; 231 | VAL_ 1621 SCU_STALLED_ROTOR_PROTECTION 1 "Fault" 0 "No fault" ; 232 | VAL_ 1621 SCU_TORQUE_SUSPENSION 1 "Fault" 0 "No fault" ; 233 | VAL_ 1364 MASTER_MM_REQUEST 8 "DISCHARGE" 7 "ESA" 5 "TORQUE_CTRL" 4 "GENERATOR" 1 "NEUTRAL" ; 234 | VAL_ 1619 CRANK_POSSIBLE_IF_STOPPED 1 "ACTIVE" 0 "NOT_ACTIVE" ; 235 | VAL_ 1619 SCU_ENA_STATUS 1 "ACTIVE" 0 "NOT_ACTIVE" ; 236 | VAL_ 1619 SCU_MM_STATUS 131 "DISCHARGE_OUT_OF_RANGE" 130 "DISCHARGE_FAULT" 129 "DISCHARGE_DONE" 128 "DISCHARGE_ACTIVE" 116 "ESA_INHIB" 115 "ESA_OUT_OF_RANGE" 114 " ESA_FAULT" 113 "ESA_DONE" 112 " ESA_ACTIVE" 86 "TORQUE_CTRL_MAX" 85 "TORQUE_CTRL_DERATING" 84 "TORQUE_CTRL_INHIB" 83 "TORQUE_CTRL_OUT_OF_RANGE" 82 "TORQUE_CTRL_FAULT" 81 "TORQUE_CTRL_IDLE" 80 "TORQUE_CTRL_ACTIVE" 68 " GENERATOR_MAX" 67 "GENERATOR_DERATING" 66 "GENERATOR_OUT_OF_RANGE" 65 "GENERATOR_FAULT" 64 "GENERATOR_ACTIVE" 16 "NEUTRAL" ; 237 | 238 | --------------------------------------------------------------------------------