Skip to content

Commit

Permalink
Update diagnostic generic error parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
MSECode committed Mar 5, 2024
1 parent 7fcda93 commit 69f1446
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/libraries/icubmod/embObjLib/diagnosticInfoParsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/

#include <string>
#include "diagnosticLowLevelFormatter_hid.h"
#include "diagnosticLowLevelFormatter.h"
#include "EoBoards.h"
Expand Down Expand Up @@ -534,10 +533,9 @@ void ConfigParser::parseInfo()
/**************************************************************************************************************************/

// private class functions
void MotionControlParser::motorStatusBitsToString(uint32_t motorstatus, std::string &statusstring)
std::string MotionControlParser::motorStatusBitsToString(uint32_t motorstatus)
{
statusstring.clear();
static const std::array<std::string, 32> s_motor_fault_status =
static const std::array<std::string_view, 32> s_motor_fault_status =
{
//B0 L
"ExternalFaultAsserted",
Expand Down Expand Up @@ -581,15 +579,19 @@ void MotionControlParser::motorStatusBitsToString(uint32_t motorstatus, std::str
"PositionLimitLower"
};

std::stringstream mfaultss = {};

std::string statusstring = {};
statusstring.reserve(256);

for (uint8_t i = 0; i < s_motor_fault_status.size(); i++)
{
// check bit by bit and add to ss the faulted bits
if(embot::core::binary::bit::check(motorstatus, i))
mfaultss << " " << s_motor_fault_status.at(i);
{
statusstring.append(static_cast<const char*>(s_motor_fault_status.at(i).data()));
statusstring.append(" ");
}
}
statusstring = mfaultss.str();
return statusstring;
}

MotionControlParser::MotionControlParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
Expand Down Expand Up @@ -656,11 +658,11 @@ void MotionControlParser::parseInfo()

case eoerror_value_MC_generic_error: //TBD Check print
{
std::string motorStatusString;

uint16_t joint_num = m_dnginfo.param16;
uint32_t motor_status = m_dnginfo.param64 & 0xffffffff;
m_entityNameProvider.getAxisName(joint_num, m_dnginfo.baseInfo.axisName);
motorStatusBitsToString(motor_status, motorStatusString);
std::string motorStatusString = motorStatusBitsToString(motor_status);
snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d) (Errors:%s)",
m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, motorStatusString.c_str()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define __diagnosticLowLevelFormatter_hid_h__

#include <string>
#include <string_view>
#include <memory>
#include <yarp/os/LogStream.h>
#include "diagnosticLowLevelFormatter.h"
Expand Down Expand Up @@ -117,7 +118,7 @@ class Diagnostic::LowLevel::MotionControlParser : public Diagnostic::LowLevel::D
void parseInfo();

private:
void motorStatusBitsToString(uint32_t motorstatus, std::string &statusstring);
std::string motorStatusBitsToString(uint32_t motorstatus);
};

class Diagnostic::LowLevel::SkinParser : public Diagnostic::LowLevel::DefaultParser
Expand Down

0 comments on commit 69f1446

Please sign in to comment.