Fix stack-overflow, Adjust logging, test-ready
enable all tasks in main for full function test with new driver
This commit is contained in:
@@ -81,7 +81,7 @@ void controlledMotor::handle(){
|
||||
//--- receive commands from queue ---
|
||||
if( xQueueReceive( commandQueue, &commandReceive, ( TickType_t ) 0 ) )
|
||||
{
|
||||
ESP_LOGI(TAG, "Read command from queue: state=%s, duty=%.2f", motorstateStr[(int)commandReceive.state], commandReceive.duty);
|
||||
ESP_LOGD(TAG, "Read command from queue: state=%s, duty=%.2f", motorstateStr[(int)commandReceive.state], commandReceive.duty);
|
||||
state = commandReceive.state;
|
||||
dutyTarget = commandReceive.duty;
|
||||
receiveTimeout = false;
|
||||
@@ -141,6 +141,7 @@ void controlledMotor::handle(){
|
||||
if (state == motorstate_t::BRAKE){
|
||||
ESP_LOGD(TAG, "braking - skip fading");
|
||||
motorSetCommand({motorstate_t::BRAKE, dutyTarget});
|
||||
ESP_LOGI(TAG, "Set Motordriver: state=%s, duty=%.2f - Measurements: current=%.2f, speed=N/A", motorstateStr[(int)state], dutyNow, currentNow);
|
||||
//dutyNow = 0;
|
||||
return; //no need to run the fade algorithm
|
||||
}
|
||||
@@ -174,8 +175,8 @@ void controlledMotor::handle(){
|
||||
|
||||
|
||||
//----- CURRENT LIMIT -----
|
||||
currentNow = cSensor.read();
|
||||
if ((config.currentLimitEnabled) && (dutyDelta != 0)){
|
||||
currentNow = cSensor.read();
|
||||
if (fabs(currentNow) > config.currentMax){
|
||||
float dutyOld = dutyNow;
|
||||
//adaptive decrement:
|
||||
@@ -231,6 +232,7 @@ void controlledMotor::handle(){
|
||||
|
||||
//--- apply new target to motor ---
|
||||
motorSetCommand({state, (float)fabs(dutyNow)});
|
||||
ESP_LOGI(TAG, "Set Motordriver: state=%s, duty=%.2f - Measurements: current=%.2f, speed=N/A", motorstateStr[(int)state], dutyNow, currentNow);
|
||||
//note: BRAKE state is handled earlier
|
||||
|
||||
|
||||
|
||||
@@ -236,12 +236,13 @@ float motorCommandToSignedDuty(motorCommand_t cmd){
|
||||
//-------- send byte --------
|
||||
//send byte via uart to sabertooth driver
|
||||
void sabertooth2x60a::sendByte(char data){
|
||||
//TODO mutex?
|
||||
if (!uart_isInitialized){
|
||||
ESP_LOGE(TAG, "uart not initialized, not sending command %d...", data);
|
||||
return;
|
||||
}
|
||||
uart_write_bytes(config.uart_num, &data, 1);
|
||||
ESP_LOGI(TAG, "sent data=%d to sabertooth driver via uart", data);
|
||||
ESP_LOGD(TAG, "sent data=%d to sabertooth driver via uart", data);
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +300,7 @@ void sabertooth2x60a::setRight(float dutyPerSigned) {
|
||||
data = static_cast<uint8_t>(192 + (dutyPerSigned / 100.0) * 63);
|
||||
}
|
||||
|
||||
ESP_LOGW(TAG, "set right motor to duty=%.2f, (data=%d)", dutyPerSigned, data);
|
||||
ESP_LOGI(TAG, "set right motor to duty=%.2f, (data=%d)", dutyPerSigned, data);
|
||||
sendByte(data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user