aboutsummaryrefslogtreecommitdiff
path: root/remote_plot.c
diff options
context:
space:
mode:
authorXiao Pan <xyz@flylightning.xyz>2025-04-30 20:19:49 -0700
committerXiao Pan <xyz@flylightning.xyz>2025-04-30 20:19:49 -0700
commit3471413e9f07fd7ab7f2ba22f952bce5cadb037d (patch)
treea43828ffadd36c4ee6db303f860997bd97c8a49a /remote_plot.c
parent60bacfb2b464134596bfa92f68332c2a361c5ff6 (diff)
use correct .dbc file from spartanracingelectric/SR16-CustomBMS, rewrite code based on correct dbc file
Diffstat (limited to 'remote_plot.c')
-rw-r--r--remote_plot.c304
1 files changed, 159 insertions, 145 deletions
diff --git a/remote_plot.c b/remote_plot.c
index e636635..b86dd3f 100644
--- a/remote_plot.c
+++ b/remote_plot.c
@@ -36,147 +36,161 @@
// max wire unsigned number is 65535
// max wire signed number maybe is -32768 to 32767
-// voltage max format 6 bytes ,5.999
-// temp max format 6 bytes ,-49.9
+// voltage max format 7 bytes ,4.9999
+// temp max format 4 bytes ,100
// timestamp max 10 bytes 1745742182
-// 1 timestamp, 96 voltage, 32 temp, 1 \n
-// 10+96*6+32*6+1=779 bytes
-#define ENTRY_SIZE 779
+// 1 timestamp, 96 voltage, 48 temp, 1 \n
+// 10+96*7+48*4+1=875 bytes
+#define ENTRY_SIZE 875
// 16 KiB == 16384 bytes
-// 16384/ENTRY_SIZE == 21
-// 21*ENTRY_SIZE == 16359
// https://api.libssh.org/stable/libssh_tutor_sftp.html
#define MAX_XFER_BUF_SIZE 16384/ENTRY_SIZE*ENTRY_SIZE
const char *checkbutton_names[]={
- "0x630_BMS_Cell_4_Voltage",
- "0x630_BMS_Cell_3_Voltage",
- "0x630_BMS_Cell_2_Voltage",
- "0x630_BMS_Cell_1_Voltage",
- "0x631_BMS_Cell_8_Voltage",
- "0x631_BMS_Cell_7_Voltage",
- "0x631_BMS_Cell_6_Voltage",
- "0x631_BMS_Cell_5_Voltage",
- "0x632_BMS_Cell_12_Voltage",
- "0x632_BMS_Cell_11_Voltage",
- "0x632_BMS_Cell_10_Voltage",
- "0x632_BMS_Cell_9_Voltage",
- "0x633_BMS_Cell_4_Voltage",
- "0x633_BMS_Cell_3_Voltage",
- "0x633_BMS_Cell_2_Voltage",
- "0x633_BMS_Cell_1_Voltage",
- "0x634_BMS_Cell_8_Voltage",
- "0x634_BMS_Cell_7_Voltage",
- "0x634_BMS_Cell_6_Voltage",
- "0x634_BMS_Cell_5_Voltage",
- "0x635_BMS_Cell_12_Voltage",
- "0x635_BMS_Cell_11_Voltage",
- "0x635_BMS_Cell_10_Voltage",
- "0x635_BMS_Cell_9_Voltage",
- "0x636_BMS_Cell_4_Voltage",
- "0x636_BMS_Cell_3_Voltage",
- "0x636_BMS_Cell_2_Voltage",
- "0x636_BMS_Cell_1_Voltage",
- "0x637_BMS_Cell_8_Voltage",
- "0x637_BMS_Cell_7_Voltage",
- "0x637_BMS_Cell_6_Voltage",
- "0x637_BMS_Cell_5_Voltage",
- "0x638_BMS_Cell_12_Voltage",
- "0x638_BMS_Cell_11_Voltage",
- "0x638_BMS_Cell_10_Voltage",
- "0x638_BMS_Cell_9_Voltage",
- "0x639_BMS_Cell_4_Voltage",
- "0x639_BMS_Cell_3_Voltage",
- "0x639_BMS_Cell_2_Voltage",
- "0x639_BMS_Cell_1_Voltage",
- "0x63a_BMS_Cell_8_Voltage",
- "0x63a_BMS_Cell_7_Voltage",
- "0x63a_BMS_Cell_6_Voltage",
- "0x63a_BMS_Cell_5_Voltage",
- "0x63b_BMS_Cell_12_Voltage",
- "0x63b_BMS_Cell_11_Voltage",
- "0x63b_BMS_Cell_10_Voltage",
- "0x63b_BMS_Cell_9_Voltage",
- "0x63c_BMS_Cell_4_Voltage",
- "0x63c_BMS_Cell_3_Voltage",
- "0x63c_BMS_Cell_2_Voltage",
- "0x63c_BMS_Cell_1_Voltage",
- "0x63d_BMS_Cell_8_Voltage",
- "0x63d_BMS_Cell_7_Voltage",
- "0x63d_BMS_Cell_6_Voltage",
- "0x63d_BMS_Cell_5_Voltage",
- "0x63e_BMS_Cell_12_Voltage",
- "0x63e_BMS_Cell_11_Voltage",
- "0x63e_BMS_Cell_10_Voltage",
- "0x63e_BMS_Cell_9_Voltage",
- "0x63f_BMS_Cell_4_Voltage",
- "0x63f_BMS_Cell_3_Voltage",
- "0x63f_BMS_Cell_2_Voltage",
- "0x63f_BMS_Cell_1_Voltage",
- "0x640_BMS_Cell_8_Voltage",
- "0x640_BMS_Cell_7_Voltage",
- "0x640_BMS_Cell_6_Voltage",
- "0x640_BMS_Cell_5_Voltage",
- "0x641_BMS_Cell_12_Voltage",
- "0x641_BMS_Cell_11_Voltage",
- "0x641_BMS_Cell_10_Voltage",
- "0x641_BMS_Cell_9_Voltage",
- "0x642_BMS_Cell_4_Voltage",
- "0x642_BMS_Cell_3_Voltage",
- "0x642_BMS_Cell_2_Voltage",
- "0x642_BMS_Cell_1_Voltage",
- "0x643_BMS_Cell_8_Voltage",
- "0x643_BMS_Cell_7_Voltage",
- "0x643_BMS_Cell_6_Voltage",
- "0x643_BMS_Cell_5_Voltage",
- "0x644_BMS_Cell_12_Voltage",
- "0x644_BMS_Cell_11_Voltage",
- "0x644_BMS_Cell_10_Voltage",
- "0x644_BMS_Cell_9_Voltage",
- "0x645_BMS_Cell_4_Voltage",
- "0x645_BMS_Cell_3_Voltage",
- "0x645_BMS_Cell_2_Voltage",
- "0x645_BMS_Cell_1_Voltage",
- "0x646_BMS_Cell_8_Voltage",
- "0x646_BMS_Cell_7_Voltage",
- "0x646_BMS_Cell_6_Voltage",
- "0x646_BMS_Cell_5_Voltage",
- "0x647_BMS_Cell_12_Voltage",
- "0x647_BMS_Cell_11_Voltage",
- "0x647_BMS_Cell_10_Voltage",
- "0x647_BMS_Cell_9_Voltage",
- "0x680_BMS_Section_4_Temp",
- "0x680_BMS_Section_3_Temp",
- "0x680_BMS_Section_2_Temp",
- "0x680_BMS_Section_1_Temp",
- "0x683_BMS_Section_4_Temp",
- "0x683_BMS_Section_3_Temp",
- "0x683_BMS_Section_2_Temp",
- "0x683_BMS_Section_1_Temp",
- "0x686_BMS_Section_4_Temp",
- "0x686_BMS_Section_3_Temp",
- "0x686_BMS_Section_2_Temp",
- "0x686_BMS_Section_1_Temp",
- "0x689_BMS_Section_4_Temp",
- "0x689_BMS_Section_3_Temp",
- "0x689_BMS_Section_2_Temp",
- "0x689_BMS_Section_1_Temp",
- "0x68c_BMS_Section_4_Temp",
- "0x68c_BMS_Section_3_Temp",
- "0x68c_BMS_Section_2_Temp",
- "0x68c_BMS_Section_1_Temp",
- "0x68f_BMS_Section_4_Temp",
- "0x68f_BMS_Section_3_Temp",
- "0x68f_BMS_Section_2_Temp",
- "0x68f_BMS_Section_1_Temp",
- "0x692_BMS_Section_4_Temp",
- "0x692_BMS_Section_3_Temp",
- "0x692_BMS_Section_2_Temp",
- "0x692_BMS_Section_1_Temp",
- "0x695_BMS_Section_4_Temp",
- "0x695_BMS_Section_3_Temp",
- "0x695_BMS_Section_2_Temp",
- "0x695_BMS_Section_1_Temp"
+ "0x630_BMS_M1_Cell_1_Voltage",
+ "0x630_BMS_M1_Cell_2_Voltage",
+ "0x630_BMS_M1_Cell_3_Voltage",
+ "0x630_BMS_M1_Cell_4_Voltage",
+ "0x631_BMS_M1_Cell_5_Voltage",
+ "0x631_BMS_M1_Cell_6_Voltage",
+ "0x631_BMS_M1_Cell_7_Voltage",
+ "0x631_BMS_M1_Cell_8_Voltage",
+ "0x632_BMS_M1_Cell_9_Voltage",
+ "0x632_BMS_M1_Cell_10_Voltage",
+ "0x632_BMS_M1_Cell_11_Voltage",
+ "0x632_BMS_M1_Cell_12_Voltage",
+ "0x633_BMS_M2_Cell_1_Voltage",
+ "0x633_BMS_M2_Cell_2_Voltage",
+ "0x633_BMS_M2_Cell_3_Voltage",
+ "0x633_BMS_M2_Cell_4_Voltage",
+ "0x634_BMS_M2_Cell_5_Voltage",
+ "0x634_BMS_M2_Cell_6_Voltage",
+ "0x634_BMS_M2_Cell_7_Voltage",
+ "0x634_BMS_M2_Cell_8_Voltage",
+ "0x635_BMS_M2_Cell_9_Voltage",
+ "0x635_BMS_M2_Cell_10_Voltage",
+ "0x635_BMS_M2_Cell_11_Voltage",
+ "0x635_BMS_M2_Cell_12_Voltage",
+ "0x636_BMS_M3_Cell_1_Voltage",
+ "0x636_BMS_M3_Cell_2_Voltage",
+ "0x636_BMS_M3_Cell_3_Voltage",
+ "0x636_BMS_M3_Cell_4_Voltage",
+ "0x637_BMS_M3_Cell_5_Voltage",
+ "0x637_BMS_M3_Cell_6_Voltage",
+ "0x637_BMS_M3_Cell_7_Voltage",
+ "0x637_BMS_M3_Cell_8_Voltage",
+ "0x638_BMS_M3_Cell_9_Voltage",
+ "0x638_BMS_M3_Cell_10_Voltage",
+ "0x638_BMS_M3_Cell_11_Voltage",
+ "0x638_BMS_M3_Cell_12_Voltage",
+ "0x639_BMS_M4_Cell_1_Voltage",
+ "0x639_BMS_M4_Cell_2_Voltage",
+ "0x639_BMS_M4_Cell_3_Voltage",
+ "0x639_BMS_M4_Cell_4_Voltage",
+ "0x63a_BMS_M4_Cell_5_Voltage",
+ "0x63a_BMS_M4_Cell_6_Voltage",
+ "0x63a_BMS_M4_Cell_7_Voltage",
+ "0x63a_BMS_M4_Cell_8_Voltage",
+ "0x63b_BMS_M4_Cell_9_Voltage",
+ "0x63b_BMS_M4_Cell_11_Voltage",
+ "0x63b_BMS_M4_Cell_10_Voltage",
+ "0x63b_BMS_M4_Cell_12_Voltage",
+ "0x63c_BMS_M5_Cell_1_Voltage",
+ "0x63c_BMS_M5_Cell_2_Voltage",
+ "0x63c_BMS_M5_Cell_3_Voltage",
+ "0x63c_BMS_M5_Cell_4_Voltage",
+ "0x63d_BMS_M5_Cell_5_Voltage",
+ "0x63d_BMS_M5_Cell_6_Voltage",
+ "0x63d_BMS_M5_Cell_7_Voltage",
+ "0x63d_BMS_M5_Cell_8_Voltage",
+ "0x63e_BMS_M5_Cell_9_Voltage",
+ "0x63e_BMS_M5_Cell_10_Voltage",
+ "0x63e_BMS_M5_Cell_11_Voltage",
+ "0x63e_BMS_M5_Cell_12_Voltage",
+ "0x63f_BMS_M6_Cell_1_Voltage",
+ "0x63f_BMS_M6_Cell_2_Voltage",
+ "0x63f_BMS_M6_Cell_3_Voltage",
+ "0x63f_BMS_M6_Cell_4_Voltage",
+ "0x640_BMS_M6_Cell_5_Voltage",
+ "0x640_BMS_M6_Cell_6_Voltage",
+ "0x640_BMS_M6_Cell_7_Voltage",
+ "0x640_BMS_M6_Cell_8_Voltage",
+ "0x641_BMS_M6_Cell_9_Voltage",
+ "0x641_BMS_M6_Cell_10_Voltage",
+ "0x641_BMS_M6_Cell_11_Voltage",
+ "0x641_BMS_M6_Cell_12_Voltage",
+ "0x642_BMS_M7_Cell_1_Voltage",
+ "0x642_BMS_M7_Cell_2_Voltage",
+ "0x642_BMS_M7_Cell_3_Voltage",
+ "0x642_BMS_M7_Cell_4_Voltage",
+ "0x643_BMS_M7_Cell_5_Voltage",
+ "0x643_BMS_M7_Cell_6_Voltage",
+ "0x643_BMS_M7_Cell_7_Voltage",
+ "0x643_BMS_M7_Cell_8_Voltage",
+ "0x644_BMS_M7_Cell_9_Voltage",
+ "0x644_BMS_M7_Cell_10_Voltage",
+ "0x644_BMS_M7_Cell_11_Voltage",
+ "0x644_BMS_M7_Cell_12_Voltage",
+ "0x645_BMS_M8_Cell_1_Voltage",
+ "0x645_BMS_M8_Cell_2_Voltage",
+ "0x645_BMS_M8_Cell_3_Voltage",
+ "0x645_BMS_M8_Cell_4_Voltage",
+ "0x646_BMS_M8_Cell_5_Voltage",
+ "0x646_BMS_M8_Cell_6_Voltage",
+ "0x646_BMS_M8_Cell_7_Voltage",
+ "0x646_BMS_M8_Cell_8_Voltage",
+ "0x647_BMS_M8_Cell_9_Voltage",
+ "0x647_BMS_M8_Cell_10_Voltage",
+ "0x647_BMS_M8_Cell_11_Voltage",
+ "0x647_BMS_M8_Cell_12_Voltage",
+ "0x680_BMS_M1_Cell_1_Temperature",
+ "0x680_BMS_M1_Cell_2_Temperature",
+ "0x680_BMS_M1_Cell_3_Temperature",
+ "0x680_BMS_M1_Cell_4_Temperature",
+ "0x681_BMS_M1_Cell_5_Temperature",
+ "0x681_BMS_M1_Cell_6_Temperature",
+ "0x681_BMS_M1_Cell_7_Temperature",
+ "0x681_BMS_M1_Cell_8_Temperature",
+ "0x682_BMS_M1_Cell_9_Temperature",
+ "0x682_BMS_M1_Cell_10_Temperature",
+ "0x682_BMS_M1_Cell_11_Temperature",
+ "0x682_BMS_M1_Cell_12_Temperature",
+ "0x683_BMS_M2_Cell_1_Temperature",
+ "0x683_BMS_M2_Cell_2_Temperature",
+ "0x683_BMS_M2_Cell_3_Temperature",
+ "0x683_BMS_M2_Cell_4_Temperature",
+ "0x684_BMS_M2_Cell_5_Temperature",
+ "0x684_BMS_M2_Cell_6_Temperature",
+ "0x684_BMS_M2_Cell_7_Temperature",
+ "0x684_BMS_M2_Cell_8_Temperature",
+ "0x685_BMS_M2_Cell_9_Temperature",
+ "0x685_BMS_M2_Cell_10_Temperature",
+ "0x685_BMS_M2_Cell_11_Temperature",
+ "0x685_BMS_M2_Cell_12_Temperature",
+ "0x686_BMS_M3_Cell_1_Temperature",
+ "0x686_BMS_M3_Cell_2_Temperature",
+ "0x686_BMS_M3_Cell_3_Temperature",
+ "0x686_BMS_M3_Cell_4_Temperature",
+ "0x687_BMS_M3_Cell_5_Temperature",
+ "0x687_BMS_M3_Cell_6_Temperature",
+ "0x687_BMS_M3_Cell_7_Temperature",
+ "0x687_BMS_M3_Cell_8_Temperature",
+ "0x688_BMS_M3_Cell_9_Temperature",
+ "0x688_BMS_M3_Cell_10_Temperature",
+ "0x688_BMS_M3_Cell_11_Temperature",
+ "0x688_BMS_M3_Cell_12_Temperature",
+ "0x689_BMS_M4_Cell_1_Temperature",
+ "0x689_BMS_M4_Cell_2_Temperature",
+ "0x689_BMS_M4_Cell_3_Temperature",
+ "0x689_BMS_M4_Cell_4_Temperature",
+ "0x68a_BMS_M4_Cell_5_Temperature",
+ "0x68a_BMS_M4_Cell_6_Temperature",
+ "0x68a_BMS_M4_Cell_7_Temperature",
+ "0x68a_BMS_M4_Cell_8_Temperature",
+ "0x68b_BMS_M4_Cell_9_Temperature",
+ "0x68b_BMS_M4_Cell_10_Temperature",
+ "0x68b_BMS_M4_Cell_11_Temperature",
+ "0x68b_BMS_M4_Cell_12_Temperature"
};
typedef struct {
@@ -222,7 +236,7 @@ static gboolean read_data(gpointer user_data)
{
//printf("start read_data local for loop\n");
Item temp;
- int ct=fscanf(fp,"%u,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&temp.t,&temp.volt[0],&temp.volt[1],&temp.volt[2],&temp.volt[3],&temp.volt[4],&temp.volt[5],&temp.volt[6],&temp.volt[7],&temp.volt[8],&temp.volt[9],&temp.volt[10],&temp.volt[11],&temp.volt[12],&temp.volt[13],&temp.volt[14],&temp.volt[15],&temp.volt[16],&temp.volt[17],&temp.volt[18],&temp.volt[19],&temp.volt[20],&temp.volt[21],&temp.volt[22],&temp.volt[23],&temp.volt[24],&temp.volt[25],&temp.volt[26],&temp.volt[27],&temp.volt[28],&temp.volt[29],&temp.volt[30],&temp.volt[31],&temp.volt[32],&temp.volt[33],&temp.volt[34],&temp.volt[35],&temp.volt[36],&temp.volt[37],&temp.volt[38],&temp.volt[39],&temp.volt[40],&temp.volt[41],&temp.volt[42],&temp.volt[43],&temp.volt[44],&temp.volt[45],&temp.volt[46],&temp.volt[47],&temp.volt[48],&temp.volt[49],&temp.volt[50],&temp.volt[51],&temp.volt[52],&temp.volt[53],&temp.volt[54],&temp.volt[55],&temp.volt[56],&temp.volt[57],&temp.volt[58],&temp.volt[59],&temp.volt[60],&temp.volt[61],&temp.volt[62],&temp.volt[63],&temp.volt[64],&temp.volt[65],&temp.volt[66],&temp.volt[67],&temp.volt[68],&temp.volt[69],&temp.volt[70],&temp.volt[71],&temp.volt[72],&temp.volt[73],&temp.volt[74],&temp.volt[75],&temp.volt[76],&temp.volt[77],&temp.volt[78],&temp.volt[79],&temp.volt[80],&temp.volt[81],&temp.volt[82],&temp.volt[83],&temp.volt[84],&temp.volt[85],&temp.volt[86],&temp.volt[87],&temp.volt[88],&temp.volt[89],&temp.volt[90],&temp.volt[91],&temp.volt[92],&temp.volt[93],&temp.volt[94],&temp.volt[95],&temp.temp[0],&temp.temp[1],&temp.temp[2],&temp.temp[3],&temp.temp[4],&temp.temp[5],&temp.temp[6],&temp.temp[7],&temp.temp[8],&temp.temp[9],&temp.temp[10],&temp.temp[11],&temp.temp[12],&temp.temp[13],&temp.temp[14],&temp.temp[15],&temp.temp[16],&temp.temp[17],&temp.temp[18],&temp.temp[19],&temp.temp[20],&temp.temp[21],&temp.temp[22],&temp.temp[23],&temp.temp[24],&temp.temp[25],&temp.temp[26],&temp.temp[27],&temp.temp[28],&temp.temp[29],&temp.temp[30],&temp.temp[31]);
+ int ct=fscanf(fp,"%u,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu",&temp.t,&temp.volt[0],&temp.volt[1],&temp.volt[2],&temp.volt[3],&temp.volt[4],&temp.volt[5],&temp.volt[6],&temp.volt[7],&temp.volt[8],&temp.volt[9],&temp.volt[10],&temp.volt[11],&temp.volt[12],&temp.volt[13],&temp.volt[14],&temp.volt[15],&temp.volt[16],&temp.volt[17],&temp.volt[18],&temp.volt[19],&temp.volt[20],&temp.volt[21],&temp.volt[22],&temp.volt[23],&temp.volt[24],&temp.volt[25],&temp.volt[26],&temp.volt[27],&temp.volt[28],&temp.volt[29],&temp.volt[30],&temp.volt[31],&temp.volt[32],&temp.volt[33],&temp.volt[34],&temp.volt[35],&temp.volt[36],&temp.volt[37],&temp.volt[38],&temp.volt[39],&temp.volt[40],&temp.volt[41],&temp.volt[42],&temp.volt[43],&temp.volt[44],&temp.volt[45],&temp.volt[46],&temp.volt[47],&temp.volt[48],&temp.volt[49],&temp.volt[50],&temp.volt[51],&temp.volt[52],&temp.volt[53],&temp.volt[54],&temp.volt[55],&temp.volt[56],&temp.volt[57],&temp.volt[58],&temp.volt[59],&temp.volt[60],&temp.volt[61],&temp.volt[62],&temp.volt[63],&temp.volt[64],&temp.volt[65],&temp.volt[66],&temp.volt[67],&temp.volt[68],&temp.volt[69],&temp.volt[70],&temp.volt[71],&temp.volt[72],&temp.volt[73],&temp.volt[74],&temp.volt[75],&temp.volt[76],&temp.volt[77],&temp.volt[78],&temp.volt[79],&temp.volt[80],&temp.volt[81],&temp.volt[82],&temp.volt[83],&temp.volt[84],&temp.volt[85],&temp.volt[86],&temp.volt[87],&temp.volt[88],&temp.volt[89],&temp.volt[90],&temp.volt[91],&temp.volt[92],&temp.volt[93],&temp.volt[94],&temp.volt[95],&temp.temp[0],&temp.temp[1],&temp.temp[2],&temp.temp[3],&temp.temp[4],&temp.temp[5],&temp.temp[6],&temp.temp[7],&temp.temp[8],&temp.temp[9],&temp.temp[10],&temp.temp[11],&temp.temp[12],&temp.temp[13],&temp.temp[14],&temp.temp[15],&temp.temp[16],&temp.temp[17],&temp.temp[18],&temp.temp[19],&temp.temp[20],&temp.temp[21],&temp.temp[22],&temp.temp[23],&temp.temp[24],&temp.temp[25],&temp.temp[26],&temp.temp[27],&temp.temp[28],&temp.temp[29],&temp.temp[30],&temp.temp[31],&temp.temp[32],&temp.temp[33],&temp.temp[34],&temp.temp[35],&temp.temp[36],&temp.temp[37],&temp.temp[38],&temp.temp[39],&temp.temp[40],&temp.temp[41],&temp.temp[42],&temp.temp[43],&temp.temp[44],&temp.temp[45],&temp.temp[46],&temp.temp[47]);
if(ct == EOF)
break;
else if(ct<(VOLTLEN+TEMPLEN+1))
@@ -305,8 +319,8 @@ static gboolean read_data(gpointer user_data)
for(int j=0;j<VOLTLEN;j++)
temp.volt[j]=atof(strtok(NULL,","));
for(int j=0;j<(TEMPLEN-1);j++)
- temp.temp[j]=atof(strtok(NULL,","));
- temp.temp[TEMPLEN-1]=atof(strtok(NULL,"\n"));
+ temp.temp[j]=atoi(strtok(NULL,","));
+ temp.temp[TEMPLEN-1]=atoi(strtok(NULL,"\n"));
//printf("before AddItem\n");
if(AddItem(temp,&data->cans)==false)
{
@@ -325,9 +339,9 @@ static gboolean read_data(gpointer user_data)
}
fprintf(fp,"%u",temp.t);
for(int j=0;j<VOLTLEN;j++)
- fprintf(fp,",%5.3f",temp.volt[j]);
+ fprintf(fp,",%6.4f",temp.volt[j]);
for(int j=0;j<TEMPLEN;j++)
- fprintf(fp,",%5.1f",temp.temp[j]);
+ fprintf(fp,",%3hu",temp.temp[j]);
fprintf(fp,"\n");
fclose(fp);
}
@@ -349,14 +363,14 @@ static gboolean read_data(gpointer user_data)
if(new_entry)
{
double sum,avg;
- // max 28 char + 1 \0: Average temperature: 6553.5 C
- char str[29];
+ // max 27 char + 1 \0: Average temperature: 99.9 C
+ char str[28];
sum=avg=0;
for(int i=0;i<VOLTLEN;i++)
sum+=data->cans.end->item.volt[i];
avg=sum/VOLTLEN;
- sprintf(str,"Average voltage: %.3f V",avg);
+ sprintf(str,"Average voltage: %.4f V",avg);
gtk_label_set_text(GTK_LABEL(data->volt_label),str);
sum=0;
for(int i=0;i<TEMPLEN;i++)
@@ -582,9 +596,9 @@ static void print_data (GtkWidget *widget, gpointer user_data)
DATA *data=user_data;
printf("%u",data->cans.end->item.t);
for(int i=0;i<VOLTLEN;i++)
- printf(",%5.3f",data->cans.end->item.volt[i]);
+ printf(",%6.4f",data->cans.end->item.volt[i]);
for(int i=0;i<TEMPLEN;i++)
- printf(",%5.1f",data->cans.end->item.temp[i]);
+ printf(",%3hu",data->cans.end->item.temp[i]);
putchar('\n');
}