diff options
author | Xiao Pan <xyz@flylightning.xyz> | 2025-05-07 15:43:32 -0700 |
---|---|---|
committer | Xiao Pan <xyz@flylightning.xyz> | 2025-05-07 15:43:32 -0700 |
commit | a4dcf5ba5a79254c16341f060b227c6c97654012 (patch) | |
tree | dd0621a9198c1e071bfbc2ad7f02d0159518e534 /mycan.c | |
parent | cd4afbb8595770d6058f0bcc7b5953946d5e87c4 (diff) |
Save to a string then write to a file so maybe less corrupted .csv
Sudden power loss on pi may result to bad .csv file. Save to a string
first maybe can mitigate this issue a little bit. Also this way maybe
more optimized, not sure.
Diffstat (limited to 'mycan.c')
-rw-r--r-- | mycan.c | 618 |
1 files changed, 230 insertions, 388 deletions
@@ -36,6 +36,20 @@ cansend vcan0 680#00.FF.02.00.02.00.02.00 #define CAN_VOLT_LEN 24 #define CAN_TEMP_LEN 16 +#define VOLTLEN 96 +#define TEMPLEN 96 +// not consider \0 +#define STR_T_LEN 10 +#define STR_VOLT_LEN 7 +#define STR_TEMP_LEN 4 +// max wire unsigned number is 65535 +// max wire signed number maybe is -32768 to 32767 +// voltage max format 7 bytes ,6.5535 +// temp max format 4 bytes ,255 +// timestamp max 10 bytes 1745742182 +// 1 timestamp, 96 voltage, 48 temp, 1 \n +// 10+96*7+96*4+1=1067 bytes +#define ENTRY_SIZE (STR_T_LEN+VOLTLEN*STR_VOLT_LEN+TEMPLEN*STR_TEMP_LEN+1) // https://github.com/howerj/dbcc MIT static uint64_t u64_from_can_msg(const uint8_t m[8]) { @@ -66,6 +80,8 @@ int main(int argc, char **argv) sprintf(filename,"%s%s",dir,str); } + //printf("entry_size: %d\n",ENTRY_SIZE); + can_obj_all_sre_edited_h_t obj; dbcc_time_stamp_t t, t_before; uint64_t can_message_u64; @@ -129,8 +145,6 @@ int main(int argc, char **argv) { nbytes = read(s, &frame, sizeof(frame)); if(nbytes > 0) { - double out; - uint8_t iout; FILE * fp; // try FIFO, socket and other file types maybe better, not sure @@ -152,392 +166,220 @@ int main(int argc, char **argv) if(t>t_before) { t_before=t; - // Maybe better if concat strings and print all at once - fprintf(fp,"%u",t); - decode_can_0x630_BMS_M1_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x630_BMS_M1_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x630_BMS_M1_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x630_BMS_M1_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x631_BMS_M1_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x631_BMS_M1_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x631_BMS_M1_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x631_BMS_M1_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x632_BMS_M1_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x632_BMS_M1_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x632_BMS_M1_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x632_BMS_M1_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x633_BMS_M2_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x633_BMS_M2_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x633_BMS_M2_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x633_BMS_M2_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x634_BMS_M2_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x634_BMS_M2_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x634_BMS_M2_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x634_BMS_M2_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x635_BMS_M2_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x635_BMS_M2_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x635_BMS_M2_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x635_BMS_M2_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x636_BMS_M3_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x636_BMS_M3_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x636_BMS_M3_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x636_BMS_M3_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x637_BMS_M3_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x637_BMS_M3_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x637_BMS_M3_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x637_BMS_M3_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x638_BMS_M3_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x638_BMS_M3_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x638_BMS_M3_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x638_BMS_M3_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x639_BMS_M4_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x639_BMS_M4_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x639_BMS_M4_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x639_BMS_M4_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63a_BMS_M4_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63a_BMS_M4_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63a_BMS_M4_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63a_BMS_M4_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63b_BMS_M4_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63b_BMS_M4_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63b_BMS_M4_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63b_BMS_M4_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63c_BMS_M5_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63c_BMS_M5_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63c_BMS_M5_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63c_BMS_M5_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63d_BMS_M5_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63d_BMS_M5_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63d_BMS_M5_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63d_BMS_M5_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63e_BMS_M5_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63e_BMS_M5_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63e_BMS_M5_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63e_BMS_M5_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63f_BMS_M6_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63f_BMS_M6_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63f_BMS_M6_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x63f_BMS_M6_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x640_BMS_M6_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x640_BMS_M6_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x640_BMS_M6_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x640_BMS_M6_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x641_BMS_M6_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x641_BMS_M6_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x641_BMS_M6_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x641_BMS_M6_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x642_BMS_M7_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x642_BMS_M7_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x642_BMS_M7_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x642_BMS_M7_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x643_BMS_M7_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x643_BMS_M7_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x643_BMS_M7_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x643_BMS_M7_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x644_BMS_M7_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x644_BMS_M7_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x644_BMS_M7_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x644_BMS_M7_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x645_BMS_M8_Cell_1_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x645_BMS_M8_Cell_2_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x645_BMS_M8_Cell_3_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x645_BMS_M8_Cell_4_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x646_BMS_M8_Cell_5_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x646_BMS_M8_Cell_6_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x646_BMS_M8_Cell_7_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x646_BMS_M8_Cell_8_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x647_BMS_M8_Cell_9_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x647_BMS_M8_Cell_10_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x647_BMS_M8_Cell_11_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x647_BMS_M8_Cell_12_Voltage(&obj,&out); - fprintf(fp,",%6.4f",out); - decode_can_0x680_BMS_M1_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x680_BMS_M1_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x681_BMS_M1_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x681_BMS_M1_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x681_BMS_M1_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x681_BMS_M1_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x682_BMS_M2_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x683_BMS_M2_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x683_BMS_M2_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x683_BMS_M2_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x683_BMS_M2_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x684_BMS_M3_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x685_BMS_M3_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x685_BMS_M3_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x685_BMS_M3_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x685_BMS_M3_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x686_BMS_M4_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x687_BMS_M4_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x687_BMS_M4_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x687_BMS_M4_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x687_BMS_M4_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x688_BMS_M5_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x689_BMS_M5_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x689_BMS_M5_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x689_BMS_M5_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x689_BMS_M5_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68a_BMS_M6_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68b_BMS_M6_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68b_BMS_M6_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68b_BMS_M6_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68b_BMS_M6_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68c_BMS_M7_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68d_BMS_M7_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68d_BMS_M7_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68d_BMS_M7_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68d_BMS_M7_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_1_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_2_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_3_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_4_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_5_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_6_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_7_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68e_BMS_M8_Cell_8_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68f_BMS_M8_Cell_9_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68f_BMS_M8_Cell_10_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68f_BMS_M8_Cell_11_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu",iout); - decode_can_0x68f_BMS_M8_Cell_12_Thermistor(&obj,&iout); - fprintf(fp,",%3hhu\n",iout); + + char entry[ENTRY_SIZE+1]; + //char t_str[STR_T_LEN+1]; + double out[TEMPLEN]; + uint8_t iout[VOLTLEN]; + + decode_can_0x630_BMS_M1_Cell_1_Voltage (&obj,&out[0]); + decode_can_0x630_BMS_M1_Cell_2_Voltage (&obj,&out[1]); + decode_can_0x630_BMS_M1_Cell_3_Voltage (&obj,&out[2]); + decode_can_0x630_BMS_M1_Cell_4_Voltage (&obj,&out[3]); + decode_can_0x631_BMS_M1_Cell_5_Voltage (&obj,&out[4]); + decode_can_0x631_BMS_M1_Cell_6_Voltage (&obj,&out[5]); + decode_can_0x631_BMS_M1_Cell_7_Voltage (&obj,&out[6]); + decode_can_0x631_BMS_M1_Cell_8_Voltage (&obj,&out[7]); + decode_can_0x632_BMS_M1_Cell_9_Voltage (&obj,&out[8]); + decode_can_0x632_BMS_M1_Cell_10_Voltage(&obj,&out[9]); + decode_can_0x632_BMS_M1_Cell_11_Voltage(&obj,&out[10]); + decode_can_0x632_BMS_M1_Cell_12_Voltage(&obj,&out[11]); + decode_can_0x633_BMS_M2_Cell_1_Voltage (&obj,&out[12]); + decode_can_0x633_BMS_M2_Cell_2_Voltage (&obj,&out[13]); + decode_can_0x633_BMS_M2_Cell_3_Voltage (&obj,&out[14]); + decode_can_0x633_BMS_M2_Cell_4_Voltage (&obj,&out[15]); + decode_can_0x634_BMS_M2_Cell_5_Voltage (&obj,&out[16]); + decode_can_0x634_BMS_M2_Cell_6_Voltage (&obj,&out[17]); + decode_can_0x634_BMS_M2_Cell_7_Voltage (&obj,&out[18]); + decode_can_0x634_BMS_M2_Cell_8_Voltage (&obj,&out[19]); + decode_can_0x635_BMS_M2_Cell_9_Voltage (&obj,&out[20]); + decode_can_0x635_BMS_M2_Cell_10_Voltage(&obj,&out[21]); + decode_can_0x635_BMS_M2_Cell_11_Voltage(&obj,&out[22]); + decode_can_0x635_BMS_M2_Cell_12_Voltage(&obj,&out[23]); + decode_can_0x636_BMS_M3_Cell_1_Voltage (&obj,&out[24]); + decode_can_0x636_BMS_M3_Cell_2_Voltage (&obj,&out[25]); + decode_can_0x636_BMS_M3_Cell_3_Voltage (&obj,&out[26]); + decode_can_0x636_BMS_M3_Cell_4_Voltage (&obj,&out[27]); + decode_can_0x637_BMS_M3_Cell_5_Voltage (&obj,&out[28]); + decode_can_0x637_BMS_M3_Cell_6_Voltage (&obj,&out[29]); + decode_can_0x637_BMS_M3_Cell_7_Voltage (&obj,&out[30]); + decode_can_0x637_BMS_M3_Cell_8_Voltage (&obj,&out[31]); + decode_can_0x638_BMS_M3_Cell_9_Voltage (&obj,&out[32]); + decode_can_0x638_BMS_M3_Cell_10_Voltage(&obj,&out[33]); + decode_can_0x638_BMS_M3_Cell_11_Voltage(&obj,&out[34]); + decode_can_0x638_BMS_M3_Cell_12_Voltage(&obj,&out[35]); + decode_can_0x639_BMS_M4_Cell_1_Voltage (&obj,&out[36]); + decode_can_0x639_BMS_M4_Cell_2_Voltage (&obj,&out[37]); + decode_can_0x639_BMS_M4_Cell_3_Voltage (&obj,&out[38]); + decode_can_0x639_BMS_M4_Cell_4_Voltage (&obj,&out[39]); + decode_can_0x63a_BMS_M4_Cell_5_Voltage (&obj,&out[40]); + decode_can_0x63a_BMS_M4_Cell_6_Voltage (&obj,&out[41]); + decode_can_0x63a_BMS_M4_Cell_7_Voltage (&obj,&out[42]); + decode_can_0x63a_BMS_M4_Cell_8_Voltage (&obj,&out[43]); + decode_can_0x63b_BMS_M4_Cell_9_Voltage (&obj,&out[44]); + decode_can_0x63b_BMS_M4_Cell_10_Voltage(&obj,&out[45]); + decode_can_0x63b_BMS_M4_Cell_11_Voltage(&obj,&out[46]); + decode_can_0x63b_BMS_M4_Cell_12_Voltage(&obj,&out[47]); + decode_can_0x63c_BMS_M5_Cell_1_Voltage (&obj,&out[48]); + decode_can_0x63c_BMS_M5_Cell_2_Voltage (&obj,&out[49]); + decode_can_0x63c_BMS_M5_Cell_3_Voltage (&obj,&out[50]); + decode_can_0x63c_BMS_M5_Cell_4_Voltage (&obj,&out[51]); + decode_can_0x63d_BMS_M5_Cell_5_Voltage (&obj,&out[52]); + decode_can_0x63d_BMS_M5_Cell_6_Voltage (&obj,&out[53]); + decode_can_0x63d_BMS_M5_Cell_7_Voltage (&obj,&out[54]); + decode_can_0x63d_BMS_M5_Cell_8_Voltage (&obj,&out[55]); + decode_can_0x63e_BMS_M5_Cell_9_Voltage (&obj,&out[56]); + decode_can_0x63e_BMS_M5_Cell_10_Voltage(&obj,&out[57]); + decode_can_0x63e_BMS_M5_Cell_11_Voltage(&obj,&out[58]); + decode_can_0x63e_BMS_M5_Cell_12_Voltage(&obj,&out[59]); + decode_can_0x63f_BMS_M6_Cell_1_Voltage (&obj,&out[60]); + decode_can_0x63f_BMS_M6_Cell_2_Voltage (&obj,&out[61]); + decode_can_0x63f_BMS_M6_Cell_3_Voltage (&obj,&out[62]); + decode_can_0x63f_BMS_M6_Cell_4_Voltage (&obj,&out[63]); + decode_can_0x640_BMS_M6_Cell_5_Voltage (&obj,&out[64]); + decode_can_0x640_BMS_M6_Cell_6_Voltage (&obj,&out[65]); + decode_can_0x640_BMS_M6_Cell_7_Voltage (&obj,&out[66]); + decode_can_0x640_BMS_M6_Cell_8_Voltage (&obj,&out[67]); + decode_can_0x641_BMS_M6_Cell_9_Voltage (&obj,&out[68]); + decode_can_0x641_BMS_M6_Cell_10_Voltage(&obj,&out[69]); + decode_can_0x641_BMS_M6_Cell_11_Voltage(&obj,&out[70]); + decode_can_0x641_BMS_M6_Cell_12_Voltage(&obj,&out[71]); + decode_can_0x642_BMS_M7_Cell_1_Voltage (&obj,&out[72]); + decode_can_0x642_BMS_M7_Cell_2_Voltage (&obj,&out[73]); + decode_can_0x642_BMS_M7_Cell_3_Voltage (&obj,&out[74]); + decode_can_0x642_BMS_M7_Cell_4_Voltage (&obj,&out[75]); + decode_can_0x643_BMS_M7_Cell_5_Voltage (&obj,&out[76]); + decode_can_0x643_BMS_M7_Cell_6_Voltage (&obj,&out[77]); + decode_can_0x643_BMS_M7_Cell_7_Voltage (&obj,&out[78]); + decode_can_0x643_BMS_M7_Cell_8_Voltage (&obj,&out[79]); + decode_can_0x644_BMS_M7_Cell_9_Voltage (&obj,&out[80]); + decode_can_0x644_BMS_M7_Cell_10_Voltage(&obj,&out[81]); + decode_can_0x644_BMS_M7_Cell_11_Voltage(&obj,&out[82]); + decode_can_0x644_BMS_M7_Cell_12_Voltage(&obj,&out[83]); + decode_can_0x645_BMS_M8_Cell_1_Voltage (&obj,&out[84]); + decode_can_0x645_BMS_M8_Cell_2_Voltage (&obj,&out[85]); + decode_can_0x645_BMS_M8_Cell_3_Voltage (&obj,&out[86]); + decode_can_0x645_BMS_M8_Cell_4_Voltage (&obj,&out[87]); + decode_can_0x646_BMS_M8_Cell_5_Voltage (&obj,&out[88]); + decode_can_0x646_BMS_M8_Cell_6_Voltage (&obj,&out[89]); + decode_can_0x646_BMS_M8_Cell_7_Voltage (&obj,&out[90]); + decode_can_0x646_BMS_M8_Cell_8_Voltage (&obj,&out[91]); + decode_can_0x647_BMS_M8_Cell_9_Voltage (&obj,&out[92]); + decode_can_0x647_BMS_M8_Cell_10_Voltage(&obj,&out[93]); + decode_can_0x647_BMS_M8_Cell_11_Voltage(&obj,&out[94]); + decode_can_0x647_BMS_M8_Cell_12_Voltage(&obj,&out[95]); + decode_can_0x680_BMS_M1_Cell_1_Thermistor (&obj,&iout[0]); + decode_can_0x680_BMS_M1_Cell_2_Thermistor (&obj,&iout[1]); + decode_can_0x680_BMS_M1_Cell_3_Thermistor (&obj,&iout[2]); + decode_can_0x680_BMS_M1_Cell_4_Thermistor (&obj,&iout[3]); + decode_can_0x680_BMS_M1_Cell_5_Thermistor (&obj,&iout[4]); + decode_can_0x680_BMS_M1_Cell_6_Thermistor (&obj,&iout[5]); + decode_can_0x680_BMS_M1_Cell_7_Thermistor (&obj,&iout[6]); + decode_can_0x680_BMS_M1_Cell_8_Thermistor (&obj,&iout[7]); + decode_can_0x681_BMS_M1_Cell_9_Thermistor (&obj,&iout[8]); + decode_can_0x681_BMS_M1_Cell_10_Thermistor(&obj,&iout[9]); + decode_can_0x681_BMS_M1_Cell_11_Thermistor(&obj,&iout[10]); + decode_can_0x681_BMS_M1_Cell_12_Thermistor(&obj,&iout[11]); + decode_can_0x682_BMS_M2_Cell_1_Thermistor (&obj,&iout[12]); + decode_can_0x682_BMS_M2_Cell_2_Thermistor (&obj,&iout[13]); + decode_can_0x682_BMS_M2_Cell_3_Thermistor (&obj,&iout[14]); + decode_can_0x682_BMS_M2_Cell_4_Thermistor (&obj,&iout[15]); + decode_can_0x682_BMS_M2_Cell_5_Thermistor (&obj,&iout[16]); + decode_can_0x682_BMS_M2_Cell_6_Thermistor (&obj,&iout[17]); + decode_can_0x682_BMS_M2_Cell_7_Thermistor (&obj,&iout[18]); + decode_can_0x682_BMS_M2_Cell_8_Thermistor (&obj,&iout[19]); + decode_can_0x683_BMS_M2_Cell_9_Thermistor (&obj,&iout[20]); + decode_can_0x683_BMS_M2_Cell_10_Thermistor(&obj,&iout[21]); + decode_can_0x683_BMS_M2_Cell_11_Thermistor(&obj,&iout[22]); + decode_can_0x683_BMS_M2_Cell_12_Thermistor(&obj,&iout[23]); + decode_can_0x684_BMS_M3_Cell_1_Thermistor (&obj,&iout[24]); + decode_can_0x684_BMS_M3_Cell_2_Thermistor (&obj,&iout[25]); + decode_can_0x684_BMS_M3_Cell_3_Thermistor (&obj,&iout[26]); + decode_can_0x684_BMS_M3_Cell_4_Thermistor (&obj,&iout[27]); + decode_can_0x684_BMS_M3_Cell_5_Thermistor (&obj,&iout[28]); + decode_can_0x684_BMS_M3_Cell_6_Thermistor (&obj,&iout[29]); + decode_can_0x684_BMS_M3_Cell_7_Thermistor (&obj,&iout[30]); + decode_can_0x684_BMS_M3_Cell_8_Thermistor (&obj,&iout[31]); + decode_can_0x685_BMS_M3_Cell_9_Thermistor (&obj,&iout[32]); + decode_can_0x685_BMS_M3_Cell_10_Thermistor(&obj,&iout[33]); + decode_can_0x685_BMS_M3_Cell_11_Thermistor(&obj,&iout[34]); + decode_can_0x685_BMS_M3_Cell_12_Thermistor(&obj,&iout[35]); + decode_can_0x686_BMS_M4_Cell_1_Thermistor (&obj,&iout[36]); + decode_can_0x686_BMS_M4_Cell_2_Thermistor (&obj,&iout[37]); + decode_can_0x686_BMS_M4_Cell_3_Thermistor (&obj,&iout[38]); + decode_can_0x686_BMS_M4_Cell_4_Thermistor (&obj,&iout[39]); + decode_can_0x686_BMS_M4_Cell_5_Thermistor (&obj,&iout[40]); + decode_can_0x686_BMS_M4_Cell_6_Thermistor (&obj,&iout[41]); + decode_can_0x686_BMS_M4_Cell_7_Thermistor (&obj,&iout[42]); + decode_can_0x686_BMS_M4_Cell_8_Thermistor (&obj,&iout[43]); + decode_can_0x687_BMS_M4_Cell_9_Thermistor (&obj,&iout[44]); + decode_can_0x687_BMS_M4_Cell_10_Thermistor(&obj,&iout[45]); + decode_can_0x687_BMS_M4_Cell_11_Thermistor(&obj,&iout[46]); + decode_can_0x687_BMS_M4_Cell_12_Thermistor(&obj,&iout[47]); + decode_can_0x688_BMS_M5_Cell_1_Thermistor (&obj,&iout[48]); + decode_can_0x688_BMS_M5_Cell_2_Thermistor (&obj,&iout[49]); + decode_can_0x688_BMS_M5_Cell_3_Thermistor (&obj,&iout[50]); + decode_can_0x688_BMS_M5_Cell_4_Thermistor (&obj,&iout[51]); + decode_can_0x688_BMS_M5_Cell_5_Thermistor (&obj,&iout[52]); + decode_can_0x688_BMS_M5_Cell_6_Thermistor (&obj,&iout[53]); + decode_can_0x688_BMS_M5_Cell_7_Thermistor (&obj,&iout[54]); + decode_can_0x688_BMS_M5_Cell_8_Thermistor (&obj,&iout[55]); + decode_can_0x689_BMS_M5_Cell_9_Thermistor (&obj,&iout[56]); + decode_can_0x689_BMS_M5_Cell_10_Thermistor(&obj,&iout[57]); + decode_can_0x689_BMS_M5_Cell_11_Thermistor(&obj,&iout[58]); + decode_can_0x689_BMS_M5_Cell_12_Thermistor(&obj,&iout[59]); + decode_can_0x68a_BMS_M6_Cell_1_Thermistor (&obj,&iout[60]); + decode_can_0x68a_BMS_M6_Cell_2_Thermistor (&obj,&iout[61]); + decode_can_0x68a_BMS_M6_Cell_3_Thermistor (&obj,&iout[62]); + decode_can_0x68a_BMS_M6_Cell_4_Thermistor (&obj,&iout[63]); + decode_can_0x68a_BMS_M6_Cell_5_Thermistor (&obj,&iout[64]); + decode_can_0x68a_BMS_M6_Cell_6_Thermistor (&obj,&iout[65]); + decode_can_0x68a_BMS_M6_Cell_7_Thermistor (&obj,&iout[66]); + decode_can_0x68a_BMS_M6_Cell_8_Thermistor (&obj,&iout[67]); + decode_can_0x68b_BMS_M6_Cell_9_Thermistor (&obj,&iout[68]); + decode_can_0x68b_BMS_M6_Cell_10_Thermistor(&obj,&iout[69]); + decode_can_0x68b_BMS_M6_Cell_11_Thermistor(&obj,&iout[70]); + decode_can_0x68b_BMS_M6_Cell_12_Thermistor(&obj,&iout[71]); + decode_can_0x68c_BMS_M7_Cell_1_Thermistor (&obj,&iout[72]); + decode_can_0x68c_BMS_M7_Cell_2_Thermistor (&obj,&iout[73]); + decode_can_0x68c_BMS_M7_Cell_3_Thermistor (&obj,&iout[74]); + decode_can_0x68c_BMS_M7_Cell_4_Thermistor (&obj,&iout[75]); + decode_can_0x68c_BMS_M7_Cell_5_Thermistor (&obj,&iout[76]); + decode_can_0x68c_BMS_M7_Cell_6_Thermistor (&obj,&iout[77]); + decode_can_0x68c_BMS_M7_Cell_7_Thermistor (&obj,&iout[78]); + decode_can_0x68c_BMS_M7_Cell_8_Thermistor (&obj,&iout[79]); + decode_can_0x68d_BMS_M7_Cell_9_Thermistor (&obj,&iout[80]); + decode_can_0x68d_BMS_M7_Cell_10_Thermistor(&obj,&iout[81]); + decode_can_0x68d_BMS_M7_Cell_11_Thermistor(&obj,&iout[82]); + decode_can_0x68d_BMS_M7_Cell_12_Thermistor(&obj,&iout[83]); + decode_can_0x68e_BMS_M8_Cell_1_Thermistor (&obj,&iout[84]); + decode_can_0x68e_BMS_M8_Cell_2_Thermistor (&obj,&iout[85]); + decode_can_0x68e_BMS_M8_Cell_3_Thermistor (&obj,&iout[86]); + decode_can_0x68e_BMS_M8_Cell_4_Thermistor (&obj,&iout[87]); + decode_can_0x68e_BMS_M8_Cell_5_Thermistor (&obj,&iout[88]); + decode_can_0x68e_BMS_M8_Cell_6_Thermistor (&obj,&iout[89]); + decode_can_0x68e_BMS_M8_Cell_7_Thermistor (&obj,&iout[90]); + decode_can_0x68e_BMS_M8_Cell_8_Thermistor (&obj,&iout[91]); + decode_can_0x68f_BMS_M8_Cell_9_Thermistor (&obj,&iout[92]); + decode_can_0x68f_BMS_M8_Cell_10_Thermistor(&obj,&iout[93]); + decode_can_0x68f_BMS_M8_Cell_11_Thermistor(&obj,&iout[94]); + decode_can_0x68f_BMS_M8_Cell_12_Thermistor(&obj,&iout[95]); + + sprintf(entry,"%u",t); + for(int i=0;i<VOLTLEN;i++) + { + char out_str[STR_VOLT_LEN+1]; + sprintf(out_str,",%6.4f",out[i]); + strcat(entry,out_str); + } + for(int i=0;i<TEMPLEN;i++) + { + char iout_str[STR_TEMP_LEN+1]; + sprintf(iout_str,",%3hhu",iout[i]); + strcat(entry,iout_str); + } + strcat(entry,"\n"); + fprintf(fp,"%s",entry); } fclose(fp); |