Skip to content

Commit

Permalink
Apply coding style corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Akram authored and Akram committed Aug 26, 2024
1 parent 4e2aec2 commit 2935cb3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
16 changes: 9 additions & 7 deletions lib/APPReinforcementLearning/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void App::loop()
payload = {SMPChannelPayload::Status::DONE};
}

m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdStatus, &payload, sizeof(payload));
m_dataSent = m_smpServer.sendData(m_serialMuxProtChannelIdStatus, &payload, sizeof(payload));

m_statusTimer.restart();
}
Expand All @@ -133,7 +133,7 @@ void App::loop()
if (true == m_sendLineSensorsDataInterval.isTimeout() &&
(&DrivingState::getInstance() == m_systemStateMachine.getState()))
{
sendLineSensorsData();
m_dataSent = sendLineSensorsData();

m_sendLineSensorsDataInterval.restart();
}
Expand All @@ -148,13 +148,13 @@ void App::loop()
SMPChannelPayload::Mode payload =
(1 == mode_options) ? SMPChannelPayload::Mode::DRIVING_MODE : SMPChannelPayload::Mode::TRAINING_MODE;

m_data_sent = m_smpServer.sendData(m_serialMuxProtChannelIdMode, &payload, sizeof(payload));
m_dataSent = m_smpServer.sendData(m_serialMuxProtChannelIdMode, &payload, sizeof(payload));

m_modeSelectionSent = true;
}
}

if (false == m_data_sent)
if (false == m_dataSent)
{
/* Failed to send data to the supervisor. Go to error state. */
ErrorState::getInstance().setErrorMsg("DSF");
Expand Down Expand Up @@ -201,12 +201,13 @@ void App::handleRemoteCommand(const Command& cmd)
* Private Methods
*****************************************************************************/

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

if (LINE_SENSOR_CHANNEL_DLC == (maxLineSensors * sizeof(uint16_t)))
Expand All @@ -219,8 +220,9 @@ void App::sendLineSensorsData()
}
}

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

return isDataSent;
}

bool App::setupSerialMuxProt()
Expand Down
6 changes: 3 additions & 3 deletions lib/APPReinforcementLearning/src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class App
m_statusTimer(),
m_sendLineSensorsDataInterval(),
m_modeSelectionSent(false),
m_data_sent(true),
m_dataSent(true),
m_smpServer(Serial, this)
{
}
Expand Down Expand Up @@ -143,7 +143,7 @@ class App
bool m_modeSelectionSent;

/** check if the data has been sent */
bool m_data_sent;
bool m_dataSent;

/**
* Setup the SerialMuxProt channels.
Expand All @@ -155,7 +155,7 @@ class App
/**
* Send line sensors data via SerialMuxProt.
*/
void sendLineSensorsData();
bool sendLineSensorsData() const;

/**
* Copy construction of an instance.
Expand Down
4 changes: 2 additions & 2 deletions lib/APPReinforcementLearning/src/ReadyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void ReadyState::entry()
display.print(m_lapTime);
display.print("ms");
}
m_stateTransitionTimer.start(m_state_Transition_period);
m_modeTimeoutTimer.start(mode_selected_period);
m_stateTransitionTimer.start(STATE_TRANSITION_PERIOD);
m_modeTimeoutTimer.start(MODE_SELECTED_PERIOD);
m_mode = IDLE;
m_isLastStartStopLineDetected = false;
m_isButtonAPressed = false;
Expand Down
4 changes: 2 additions & 2 deletions lib/APPReinforcementLearning/src/ReadyState.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ class ReadyState : public IState
};

/** Duration of the selected mode in ms. This is the maximum time to select a mode. */
static const uint32_t mode_selected_period = 100;
static const uint32_t MODE_SELECTED_PERIOD = 100U;

/** Duration to handle State changes in ms. */
static const uint32_t m_state_Transition_period = 150;
static const uint32_t STATE_TRANSITION_PERIOD = 150U;

/**
* The line sensor threshold (normalized) used to detect the track.
Expand Down

0 comments on commit 2935cb3

Please sign in to comment.