Safeguard serial error prints

This commit is contained in:
Phillip Kühne 2025-02-16 13:08:25 +01:00
parent b410338109
commit a48dd7c9dd
Signed by: phillip
GPG Key ID: E4C1C4D2F90902AA
7 changed files with 31 additions and 10 deletions

View File

@ -81,7 +81,9 @@ void Communication::begin(void) {
PowerParameters::CurrentConsumptions::CURRENT_WIFI_BASE, PowerParameters::CurrentConsumptions::CURRENT_WIFI_BASE,
MESH_MAX_EXECUTION_DELAY_MS, NULL)) { MESH_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG, "Failed to get power for mesh initialization"); ESP_LOGE(TAG, "Failed to get power for mesh initialization");
Serial.println("Failed to get power for mesh initialization"); if(Serial) {
Serial.println("Failed to get power for mesh initialization");
}
} }
mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT); mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT);
mesh.onReceive(&receivedCallback); mesh.onReceive(&receivedCallback);

View File

@ -18,7 +18,9 @@ void Display::begin(void){
PowerParameters::PowerConsumers::DISPLAY_OLED, PowerParameters::CurrentConsumptions::CURRENT_DISPLAY PowerParameters::PowerConsumers::DISPLAY_OLED, PowerParameters::CurrentConsumptions::CURRENT_DISPLAY
,DISPLAY_MAX_EXECUTION_DELAY_MS, NULL)){ ,DISPLAY_MAX_EXECUTION_DELAY_MS, NULL)){
ESP_LOGE(TAG,"Could not get power for Display"); ESP_LOGE(TAG,"Could not get power for Display");
Serial.println("Could not get power for Display"); if (Serial) {
Serial.println("Could not get power for Display");
}
} }
//set Mux Ratio //set Mux Ratio
sendDisplayCMD(muxRatio); sendDisplayCMD(muxRatio);

View File

@ -69,7 +69,10 @@ void LightDetection::beginInfrared(void){
PowerParameters::CurrentConsumptions::CURRENT_PT * 4, PowerParameters::CurrentConsumptions::CURRENT_PT * 4,
LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)) { LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG,"Could not get power for Infrared Phototransistors"); ESP_LOGE(TAG,"Could not get power for Infrared Phototransistors");
Serial.println("Could not get power for Infrared Phototransistors"); if(Serial){
Serial.println(
"Could not get power for Infrared Phototransistors");
}
} }
digitalWrite(IR_PT_ENABLE,true); digitalWrite(IR_PT_ENABLE,true);
pinMode(IR_PT_ENABLE, OUTPUT); pinMode(IR_PT_ENABLE, OUTPUT);
@ -85,7 +88,10 @@ void LightDetection::beginDaylight(void){
PowerParameters::CurrentConsumptions::CURRENT_PT * 2, PowerParameters::CurrentConsumptions::CURRENT_PT * 2,
LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)) { LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG,"Could not get power for Daylight Phototransistors"); ESP_LOGE(TAG,"Could not get power for Daylight Phototransistors");
Serial.println("Could not get power for Daylight Phototransistors"); if(Serial){
Serial.println(
"Could not get power for Daylight Phototransistors");
}
} }
digitalWrite(DL_PT_ENABLE,true); digitalWrite(DL_PT_ENABLE,true);
pinMode(DL_PT_ENABLE, OUTPUT); pinMode(DL_PT_ENABLE, OUTPUT);

View File

@ -32,7 +32,9 @@ void Motion::moveTask(void * args) {
uint32_t runtime = (uint32_t)args; uint32_t runtime = (uint32_t)args;
if (!Motion::left.setSpeed(LEFT_MOTOR_DUTY) || !Motion::right.setSpeed(RIGHT_MOTOR_DUTY)) { if (!Motion::left.setSpeed(LEFT_MOTOR_DUTY) || !Motion::right.setSpeed(RIGHT_MOTOR_DUTY)) {
Serial.println("ailed to start motors due to power constraints"); if(Serial){
Serial.println("Failed to start motors due to power constraints");
}
Motion::stop(); // Use to clean up Motion::stop(); // Use to clean up
return; return;
} }
@ -123,7 +125,9 @@ void Motion::leftMotorTask(void * args) {
} }
Motion::right.setSpeed(0); Motion::right.setSpeed(0);
if(!Motion::left.setSpeed(LEFT_MOTOR_DUTY)){ if(!Motion::left.setSpeed(LEFT_MOTOR_DUTY)){
Serial.println("Can not rotate Clockwise due to power constraints"); if(Serial){
Serial.println("Can not rotate Clockwise due to power constraints");
}
Motion::stop(); Motion::stop();
return; return;
} }
@ -166,7 +170,10 @@ void Motion::rightMotorTask(void * args) {
xClockwiseTaskHandle = NULL; xClockwiseTaskHandle = NULL;
} }
if(!Motion::left.setSpeed(RIGHT_MOTOR_DUTY)){ if(!Motion::left.setSpeed(RIGHT_MOTOR_DUTY)){
Serial.println("Can not rotate Antilockwise due to power constraints"); if(Serial){
Serial.println(
"Can not rotate Antilcockwise due to power constraints");
}
Motion::stop(); Motion::stop();
return; return;
} }

View File

@ -11,7 +11,9 @@ void MotionDetection::begin(void){
PowerParameters::CurrentConsumptions::CURRENT_IMU, PowerParameters::CurrentConsumptions::CURRENT_IMU,
IMU_MAX_EXECUTION_DELAY_MS, NULL)) { IMU_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG, "Could not get power for MotionDetection"); ESP_LOGE(TAG, "Could not get power for MotionDetection");
Serial.println("Could not get power for MotionDetection"); if(Serial){
Serial.println("Could not get power for MotionDetection");
}
} }
pinMode(34,OUTPUT); pinMode(34,OUTPUT);
digitalWrite(34,HIGH); digitalWrite(34,HIGH);

View File

@ -19,7 +19,9 @@ void MultiColorLight::begin(void) {
PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_BASE, PowerParameters::CurrentConsumptions::CURRENT_LED_RGB_BASE,
MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL)) { MULTI_COLOR_LIGHT_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG, "Could not get power for MultiColorLight"); ESP_LOGE(TAG, "Could not get power for MultiColorLight");
Serial.println("Could not get power for MultiColorLight"); if(Serial){
Serial.println("Could not get power for MultiColorLight");
}
} }
rgbLeds.begin(); rgbLeds.begin();
this->turnOffLed(); this->turnOffLed();

View File

@ -137,7 +137,7 @@ bool PowerScheduler::waitForCurrentAllowance(
.requestedAt = initialTickCount, .requestedAt = initialTickCount,
.grantedAt = xTaskGetTickCount(), .grantedAt = xTaskGetTickCount(),
.granted = true}); .granted = true});
ESP_LOGV(TAG, "%d mA granted to consumer %d after %d ms", ESP_LOGI(TAG, "%d mA granted to consumer %d with a delay of %d ms",
neededCurrent, static_cast<int>(consumer), neededCurrent, static_cast<int>(consumer),
xTaskGetTickCount() - initialTickCount); xTaskGetTickCount() - initialTickCount);
return true; return true;