![](/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:
- 24:c9c7dcdcbbc5
- Parent:
- 23:1a29761becd2
- Child:
- 25:76c6f417eb48
diff -r 1a29761becd2 -r c9c7dcdcbbc5 main.cpp --- a/main.cpp Sat Oct 22 19:06:09 2016 +0000 +++ b/main.cpp Sun Oct 23 13:10:00 2016 +0000 @@ -79,7 +79,7 @@ bool key_switch = 0; -void flip() +/*void flip() { key_switch = !key_switch; led = key_switch; @@ -92,7 +92,20 @@ // to_send = 1; } -Ticker flipper; +*/ +volatile float cells[36]; + +void cvprint(){ + + int i=0; + for(i=0; i<=35; i=i+1) + printf("data: %f, cell : %d\n", cells[i],i); + + } + + +//Ticker flipper; +Ticker cvprinter; typedef union can_union { int i[2]; @@ -100,12 +113,18 @@ float f[2]; } data; + + + int main() { + + int n=0; can.frequency(1000000); // set bit rate to 1Mbps can.attach(&onMsgReceived); // attach 'CAN receive-complete' interrupt handler - flipper.attach(&flip, 30); // turn on or off + // flipper.attach(&flip, 30); // turn on or off + cvprinter.attach(&cvprint, 30); led=key_switch; timer.start(); // start timer @@ -121,20 +140,42 @@ 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]); + // printf(" Id: %d, data: %f, counter : %d\n", rxMsg.id, data.f[0],rxMsg.data[4]); + + + n = (rxMsg.id-11)*12+rxMsg.data[4]; + + cells[n]=data.f[0]; + //------------------------------ + + /* + + if(rxMsg.id==11){ + cells[rxMsg.data[4]]=data.f[0]; + } + if(rxMsg.id==12){ + cells[rxMsg.data[4]+12]=data.f[0]; + } + if(rxMsg.id==13){ + cells[rxMsg.data[4]+24]=data.f[0]; + } + */ + + //---------------------------- /* printf("\r\nreceived message ID: \t%d\n\r", rxMsg.id); for(int i=0; i<len; i++) { printf("\t%x",rxMsg.data[i]); }*/ - printf("\r\n"); - counter++; - if(rxMsg.data[4] == 1) { //counter == 12 + //printf("\r\n"); + //counter++; + /*if(rxMsg.data[4] == 1) { //counter == 12 counter = 0; printf("\r\n""""""""""""""""""""""""""""""""""""""""""""""""\r\n"); } + */ // Filtering performed by software: } if(to_send) {