@@ -212,6 +212,12 @@ void commands_process_packet(unsigned char *data, unsigned int len,
212212
213213 send_buffer [ind ++ ] = 0 ; // No custom config
214214
215+ #ifdef HW_HAS_PHASE_FILTERS
216+ send_buffer [ind ++ ] = 1 ;
217+ #else
218+ send_buffer [ind ++ ] = 0 ;
219+ #endif
220+
215221 fw_version_sent_cnt ++ ;
216222
217223 reply_func (send_buffer , ind );
@@ -452,6 +458,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
452458 } break ;
453459
454460 case COMM_SET_MCCONF : {
461+ #ifndef HW_MCCONF_READ_ONLY
455462 mc_configuration * mcconf = mempools_alloc_mcconf ();
456463 * mcconf = * mc_interface_get_configuration ();
457464
@@ -484,6 +491,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
484491 }
485492
486493 mempools_free_mcconf (mcconf );
494+ #endif
487495 } break ;
488496
489497 case COMM_GET_MCCONF :
@@ -501,6 +509,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
501509 } break ;
502510
503511 case COMM_SET_APPCONF : {
512+ #ifndef HW_APPCONF_READ_ONLY
504513 app_configuration * appconf = mempools_alloc_appconf ();
505514 * appconf = * app_get_configuration ();
506515
@@ -526,6 +535,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
526535 }
527536
528537 mempools_free_appconf (appconf );
538+ #endif
529539 } break ;
530540
531541 case COMM_GET_APPCONF :
@@ -1179,6 +1189,56 @@ void commands_process_packet(unsigned char *data, unsigned int len,
11791189 break ;
11801190 }
11811191
1192+ // Power switch
1193+ case COMM_PSW_GET_STATUS : {
1194+ int32_t ind = 0 ;
1195+ bool by_id = data [ind ++ ];
1196+ int id_ind = buffer_get_int16 (data , & ind );
1197+
1198+ int psws_num = 0 ;
1199+ for (int i = 0 ;i < CAN_STATUS_MSGS_TO_STORE ;i ++ ) {
1200+ psw_status * stat = comm_can_get_psw_status_index (i );
1201+ if (stat -> id >= 0 ) {
1202+ psws_num ++ ;
1203+ } else {
1204+ break ;
1205+ }
1206+ }
1207+
1208+ psw_status * stat = 0 ;
1209+ if (by_id ) {
1210+ stat = comm_can_get_psw_status_id (id_ind );
1211+ } else if (id_ind < psws_num ) {
1212+ stat = comm_can_get_psw_status_index (id_ind );
1213+ }
1214+
1215+ if (stat ) {
1216+ ind = 0 ;
1217+ uint8_t send_buffer [70 ];
1218+
1219+ send_buffer [ind ++ ] = packet_id ;
1220+ buffer_append_int16 (send_buffer , stat -> id , & ind );
1221+ buffer_append_int16 (send_buffer , psws_num , & ind );
1222+ buffer_append_float32_auto (send_buffer , UTILS_AGE_S (stat -> rx_time ), & ind );
1223+ buffer_append_float32_auto (send_buffer , stat -> v_in , & ind );
1224+ buffer_append_float32_auto (send_buffer , stat -> v_out , & ind );
1225+ buffer_append_float32_auto (send_buffer , stat -> temp , & ind );
1226+ send_buffer [ind ++ ] = stat -> is_out_on ;
1227+ send_buffer [ind ++ ] = stat -> is_pch_on ;
1228+ send_buffer [ind ++ ] = stat -> is_dsc_on ;
1229+
1230+ reply_func (send_buffer , ind );
1231+ }
1232+ } break ;
1233+
1234+ case COMM_PSW_SWITCH : {
1235+ int32_t ind = 0 ;
1236+ int id = buffer_get_int16 (data , & ind );
1237+ bool is_on = data [ind ++ ];
1238+ bool plot = data [ind ++ ];
1239+ comm_can_psw_switch (id , is_on , plot );
1240+ } break ;
1241+
11821242 // Blocking commands. Only one of them runs at any given time, in their
11831243 // own thread. If other blocking commands come before the previous one has
11841244 // finished, they are discarded.
0 commit comments