![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
all bms comunicating with nucleo board and balancing
Fork of Can_sniffer_BMS_GER by
Diff: main.cpp
- Revision:
- 37:1e1f3131fef5
- Parent:
- 36:00ea3ae2cead
- Child:
- 38:3e01f81f0808
--- a/main.cpp Wed Nov 09 10:14:03 2016 +0000 +++ b/main.cpp Wed Nov 09 12:11:05 2016 +0000 @@ -135,7 +135,7 @@ volatile bool msgAvailable = false; volatile bool to_send = false; float cellsv[36]; -int cellst[96]; +float cellst[96]; /** * @brief 'CAN receive-complete' interrup handler. * @note Called on arrival of new CAN message. @@ -188,7 +188,7 @@ int n; for(n=95; n>=0; n--){ //printf("cellsv0: %f cvprint\r\n", cellsv[0]); - printf("ntc: %d temperature: %d \r\n", n+1,cellst[n]); + printf("ntc: %d temperature: %f \r\n", n+1,cellst[n]); } printf("\r\n""""""""""""""""""""""""""""""""""""""""""""""""\r\n"); } @@ -203,12 +203,6 @@ float f[2]; } data; -typedef union can_union2 { - int i[2]; - char bytes[8]; - float f[2]; -} data2; - //bool to_charge_or_not_to_charge=true; // false = discharge bool charging = false; @@ -231,15 +225,14 @@ if(msgAvailable) { data data; - data2 data2; int len = can.read(rxMsg); + msgAvailable = false; if((rxMsg.id==11)||(rxMsg.id==12)||(rxMsg.id==13)){ data.bytes[0] = rxMsg.data[0]; data.bytes[1] = rxMsg.data[1]; data.bytes[2] = rxMsg.data[2]; data.bytes[3] = rxMsg.data[3]; - msgAvailable = false; // reset flag for next use // printf(" Id: %d, data: %f, counter : %d\n", rxMsg.id, data.f[0],rxMsg.data[4]); cellsv[(rxMsg.id-11)*12+rxMsg.data[4]-1]=data.f[0]; //printf("cell: %d\r\n", rxMsg.data[4]); @@ -255,17 +248,19 @@ } */ // Filtering performed by software: - } - - - if((rxMsg.id==21)||(rxMsg.id==22)||(rxMsg.id==23)){ - int len = can.read(rxMsg); + }else if((rxMsg.id==21)||(rxMsg.id==22)||(rxMsg.id==23)){ //printf("olaola\r\n"); // cellst[(rxMsg.id-21)*32+rxMsg.data[4]-1]=data.f[0]; - data2.bytes[0] = rxMsg.data[0]; - data2.bytes[1] = rxMsg.data[1]; - msgAvailable = false; - cellst[(rxMsg.id-21)*32+rxMsg.data[2]-1]=data2.i[0]; + + printf("OLA"); + + data.bytes[0] = rxMsg.data[0]; + data.bytes[1] = rxMsg.data[1]; + data.bytes[2] = rxMsg.data[2]; + data.bytes[3] = rxMsg.data[3]; + + + cellst[(rxMsg.id-21)*32+rxMsg.data[4]-1]=data.f[0]; //printf("temp: %d \r\n", rxMsg.data[1]); }