Skip to content

Commit 72d1425

Browse files
committed
Increased error printer memory
1 parent f213a93 commit 72d1425

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

Firmware/FFBoard/Src/CommandInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ void CDC_CommandInterface::sendReplies(std::vector<CommandResult>& results,Comma
218218
return;
219219
}
220220
std::string replystr;
221+
replystr.reserve(100);
221222
StringCommandInterface::formatReply(replystr,results, originalInterface != this && originalInterface != nullptr);
222223
if(!replystr.empty())
223224
CDCcomm::cdcSend(&replystr, 0);

Firmware/FFBoard/Src/ErrorHandler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "global_callbacks.h"
1010
#include "FFBoardMain.h"
1111
#include "cppmain.h"
12+
#include "critical.hpp"
1213

1314
std::vector<ErrorHandler*> ErrorHandler::errorHandlers;
1415
std::vector<Error> ErrorHandler::errors;
@@ -71,9 +72,11 @@ void ErrorHandler::addError(Error error){
7172
errors.push_back(error);
7273

7374
// Call all error handler with this error
75+
//cpp_freertos::CriticalSection::SuspendScheduler();
7476
for(ErrorHandler* e : errorHandlers){
7577
e->errorCallback(error, false);
7678
}
79+
//cpp_freertos::CriticalSection::ResumeScheduler();
7780
}
7881

7982
void ErrorHandler::clearError(Error error){
@@ -122,7 +125,7 @@ void ErrorHandler::errorCallback(Error &error, bool cleared){
122125
// return info;
123126
//}
124127

125-
ErrorPrinter::ErrorPrinter() : Thread("errprint",256,17){ // Higher than default task but low.
128+
ErrorPrinter::ErrorPrinter() : Thread("errprint",512,19){ // Higher than default task but low.
126129
this->Start();
127130
}
128131

Firmware/FFBoard/UserExtensions/Inc/TMC4671.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ class TMC4671 : public MotorDriver, public PersistentStorage, public Encoder, pu
438438
OutputPin enablePin = OutputPin(*DRV_ENABLE_GPIO_Port,DRV_ENABLE_Pin);
439439

440440

441-
Error lowVoltageError = Error(ErrorCode::undervoltage,ErrorType::warning,"Low motor voltage");
441+
const Error lowVoltageError = Error(ErrorCode::undervoltage,ErrorType::warning,"Low motor voltage");
442+
const Error communicationError = Error(ErrorCode::tmcCommunicationError, ErrorType::warning, "TMC not responding");
442443
ENC_InitState encstate = ENC_InitState::uninitialized;
443444
TMC_ControlState state = TMC_ControlState::uninitialized;
444445
TMC_ControlState laststate = TMC_ControlState::uninitialized;

Firmware/FFBoard/UserExtensions/Inc/eeprom_addresses.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) will return 1 if
4848
#define ADR_SPI_BTN_1_CONF_2 0x206
4949
#define ADR_SPI_BTN_2_CONF_2 0x207
5050

51+
// Local encoder
5152
#define ADR_ENCLOCAL_CPR 0x210
5253

5354
// PWM
@@ -150,6 +151,6 @@ uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) will return 1 if
150151
#define ADR_VESC_OFFSET 0x3E1
151152

152153
//MT Encoder
153-
#define ADR_MTENC_CONF1 0x3F0
154+
#define ADR_MTENC_CONF1 0x401
154155

155156
#endif /* EEPROM_ADDRESSES_H_ */

Firmware/FFBoard/UserExtensions/Src/TMC4671.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool TMC_1::isCreatable() {
2929

3030
ClassIdentifier TMC_2::info = {
3131
.name = "TMC4671 (CS 2)" ,
32-
.id=CLSID_MOT_TMC0, // 2
32+
.id=CLSID_MOT_TMC1,
3333
};
3434

3535

@@ -42,7 +42,7 @@ bool TMC_2::isCreatable() {
4242

4343
ClassIdentifier TMC4671::info = {
4444
.name = "TMC4671" ,
45-
.id=CLSID_MOT_TMC0, // 3
45+
.id=CLSID_MOT_TMC0,
4646
};
4747

4848

@@ -188,7 +188,7 @@ bool TMC4671::initialize(){
188188
// }
189189
// Check if a TMC4671 is active and replies correctly
190190
if(!pingDriver()){
191-
ErrorHandler::addError(Error(ErrorCode::tmcCommunicationError, ErrorType::warning, std::string(this->getInfo().name) + " " + std::to_string(this->getCommandHandlerInfo()->instance) + " not responding"));
191+
ErrorHandler::addError(communicationError);
192192
return false;
193193
}
194194

@@ -1157,8 +1157,10 @@ void TMC4671::stopMotor(){
11571157
void TMC4671::startMotor(){
11581158
active = true;
11591159
if(!initialized || emergency){
1160-
initialize();
1160+
//initialize();
11611161
emergency = false;
1162+
if(state != TMC_ControlState::Init_wait)
1163+
changeState(TMC_ControlState::Init_wait);
11621164
}
11631165

11641166
if(state == TMC_ControlState::Shutdown && initialized && encstate == ENC_InitState::OK){

0 commit comments

Comments
 (0)