Skip to content

Commit

Permalink
Reset sendLineSensorsData function to its original state to fix issue…
Browse files Browse the repository at this point in the history
…s with sensor data transmission.
  • Loading branch information
Akram authored and Akram committed Aug 22, 2024
1 parent 0de39f7 commit cecb427
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
40 changes: 23 additions & 17 deletions lib/APPReinforcementLearning/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,7 @@ void App::loop()
if (true == m_sendLineSensorsDataInterval.isTimeout() &&
(&DrivingState::getInstance() == m_systemStateMachine.getState()))
{
ILineSensors& lineSensors = Board::getInstance().getLineSensors();
uint8_t maxLineSensors = lineSensors.getNumLineSensors();
const uint16_t* lineSensorValues = lineSensors.getSensorValues();
uint8_t lineSensorIdx = 0U;
LineSensorData payload;

if (LINE_SENSOR_CHANNEL_DLC == (maxLineSensors * sizeof(uint16_t)))
{
while (maxLineSensors > lineSensorIdx)
{
payload.lineSensorData[lineSensorIdx] = lineSensorValues[lineSensorIdx];

++lineSensorIdx;
}
}

m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdLineSensors, &payload, sizeof(payload));
sendLineSensorsData();

m_sendLineSensorsDataInterval.restart();
}
Expand Down Expand Up @@ -217,6 +201,28 @@ void App::handleRemoteCommand(const Command& cmd)
* Private Methods
*****************************************************************************/

void App::sendLineSensorsData()
{
ILineSensors& lineSensors = Board::getInstance().getLineSensors();
uint8_t maxLineSensors = lineSensors.getNumLineSensors();
const uint16_t* lineSensorValues = lineSensors.getSensorValues();
uint8_t lineSensorIdx = 0U;
LineSensorData payload;

if (LINE_SENSOR_CHANNEL_DLC == (maxLineSensors * sizeof(uint16_t)))
{
while (maxLineSensors > lineSensorIdx)
{
payload.lineSensorData[lineSensorIdx] = lineSensorValues[lineSensorIdx];

++lineSensorIdx;
}
}

/* Ignoring return value, as error handling is not available. */
m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdLineSensors, &payload, sizeof(payload));
}

bool App::setupSerialMuxProt()
{
bool isSuccessful = false;
Expand Down
7 changes: 6 additions & 1 deletion lib/APPReinforcementLearning/src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ class App
*
* @return If successful returns true, otherwise false.
*/
bool setupSerialMuxProt();
bool setupSerialMuxProt()

/**
* Send line sensors data via SerialMuxProt.
*/
void sendLineSensorsData() ;

/**
* Copy construction of an instance.
Expand Down

0 comments on commit cecb427

Please sign in to comment.