|
|
@@ -177,14 +177,16 @@ static void process_foc_command(foc_cmd_body_t *command) {
|
|
|
}
|
|
|
case Foc_Set_Gear_Limit:
|
|
|
{
|
|
|
- if (command->len < 7) {
|
|
|
+ sys_debug("len = %d\n", command->len);
|
|
|
+ if (command->len < 9) {
|
|
|
erroCode = FOC_Param_Err;
|
|
|
}else {
|
|
|
u8 gear = decode_u8(command->data);
|
|
|
u16 maxRPM = decode_u16((u8 *)command->data + 1);
|
|
|
- u16 maxPhaseCurr = decode_u8((u8 *)command->data + 3);
|
|
|
- u16 maxiDC = decode_u8((u8 *)command->data + 5);
|
|
|
- u16 accline = decode_u8((u8 *)command->data + 7);
|
|
|
+ u16 maxPhaseCurr = decode_u16((u8 *)command->data + 3);
|
|
|
+ u16 maxiDC = decode_u16((u8 *)command->data + 5);
|
|
|
+ u16 accline = decode_u16((u8 *)command->data + 7);
|
|
|
+ sys_debug("gear 0x%x, rpm %d, phase %d idc %d acc %d\n", gear, maxRPM, maxPhaseCurr, maxiDC, accline);
|
|
|
if (!nv_set_gear_config((gear>>4 & 0xF), (gear & 0xF), maxRPM, maxPhaseCurr, maxiDC, accline)){
|
|
|
erroCode = FOC_Param_Err;
|
|
|
}
|
|
|
@@ -198,14 +200,15 @@ static void process_foc_command(foc_cmd_body_t *command) {
|
|
|
u16 maxPhaseCurr;
|
|
|
u16 maxiDC;
|
|
|
u16 accline;
|
|
|
+ sys_debug("gear = 0x%x\n", gear);
|
|
|
if (!nv_get_gear_config((gear>>4 & 0xF), (gear & 0xF), &maxRPM, &maxPhaseCurr, &maxiDC, &accline)){
|
|
|
erroCode = FOC_Param_Err;
|
|
|
}else {
|
|
|
encode_u8(response + 3, gear);
|
|
|
- encode_u8(response + 4, maxRPM);
|
|
|
- encode_u8(response + 6, maxPhaseCurr);
|
|
|
- encode_u8(response + 8, maxiDC);
|
|
|
- encode_u8(response + 10, accline);
|
|
|
+ encode_u16(response + 4, maxRPM);
|
|
|
+ encode_u16(response + 6, maxPhaseCurr);
|
|
|
+ encode_u16(response + 8, maxiDC);
|
|
|
+ encode_u16(response + 10, accline);
|
|
|
len += 9;
|
|
|
}
|
|
|
break;
|