|
@@ -36,7 +36,7 @@ void process_bms_message(can_frame_t *frame, int len){
|
|
|
// set_log_all(L_debug);
|
|
// set_log_all(L_debug);
|
|
|
switch(frame->key) {
|
|
switch(frame->key) {
|
|
|
case CAN_KEY_BMS_SET_POWER:
|
|
case CAN_KEY_BMS_SET_POWER:
|
|
|
- if (len != sizeof(pwr_cmd_t)){
|
|
|
|
|
|
|
+ if (len != sizeof(pwr_cmd_t) || frame->head.can_addr != 0x42){//¿ª¹Ø´óµç±ØÐë42·¢¹ýÀ´
|
|
|
result = 1;
|
|
result = 1;
|
|
|
}else {
|
|
}else {
|
|
|
pwr_cmd_t *cmd = (pwr_cmd_t *)frame->data;
|
|
pwr_cmd_t *cmd = (pwr_cmd_t *)frame->data;
|
|
@@ -211,24 +211,6 @@ void process_bms_message(can_frame_t *frame, int len){
|
|
|
}
|
|
}
|
|
|
protocol_send_ack(frame->head.can_addr, frame->key, result);
|
|
protocol_send_ack(frame->head.can_addr, frame->key, result);
|
|
|
break;
|
|
break;
|
|
|
- case CAN_KEY_START_CALI:
|
|
|
|
|
- if (len != sizeof(cali_cmd_t)) {
|
|
|
|
|
- current_calibrate();//just for debug
|
|
|
|
|
- result = 1;
|
|
|
|
|
- }else {
|
|
|
|
|
- cali_cmd_t * cmd = (cali_cmd_t *)frame->data;
|
|
|
|
|
- uint8_t adc = cmd->flags & 0x01;
|
|
|
|
|
- uint8_t flags = ((cmd->flags>>1) & 0x03);
|
|
|
|
|
- if (flags == 1) {
|
|
|
|
|
- result = measure_start_cali(adc, cmd->gain, cmd->totol_samples);
|
|
|
|
|
- }else if (flags == 2) {
|
|
|
|
|
- result = measure_continue_cali(adc, cmd->voltage, cmd->current);
|
|
|
|
|
- }else {
|
|
|
|
|
- result = measure_stop_cali(adc, cmd->gain);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- protocol_send_ack(frame->head.can_addr, frame->key, result);
|
|
|
|
|
- break;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|