Skip to content

Commit bd1e01d

Browse files
author
Tobias Haeckel
committed
Working SerMux
1 parent 775b423 commit bd1e01d

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

lib/APPRemoteControl/src/App.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ void App::reportVehicleData()
332332
int16_t leftSpeed = speedometer.getLinearSpeedLeft();
333333
int16_t rightSpeed = speedometer.getLinearSpeedRight();
334334
int16_t centerSpeed = speedometer.getLinearSpeedCenter();
335+
uint32_t timestamp = millis();
335336

336337
proximitySensors.read();
337338
leftCounts = proximitySensors.countsFrontWithLeftLeds();
@@ -343,7 +344,7 @@ void App::reportVehicleData()
343344

344345
odometry.getPosition(xPos, yPos);
345346

346-
payload.timestamp = static_cast<int64_t>(millis());
347+
payload.timestamp = timestamp;
347348

348349
payload.xPos = xPos;
349350
payload.yPos = yPos;
@@ -369,14 +370,11 @@ bool App::setupSerialMuxProt()
369370
m_smpServer.subscribeToChannel(TIME_SYNC_REQUEST_CHANNEL_NAME, App_timeSyncReqChannelCallback);
370371

371372
/* Channel creation. */
372-
m_serialMuxProtChannelIdRemoteCtrlRsp =
373-
m_smpServer.createChannel(COMMAND_RESPONSE_CHANNEL_NAME, COMMAND_RESPONSE_CHANNEL_DLC);
374-
m_serialMuxProtChannelIdCurrentVehicleData =
375-
m_smpServer.createChannel(CURRENT_VEHICLE_DATA_CHANNEL_NAME, CURRENT_VEHICLE_DATA_CHANNEL_DLC);
373+
m_serialMuxProtChannelIdRemoteCtrlRsp = m_smpServer.createChannel(COMMAND_RESPONSE_CHANNEL_NAME, COMMAND_RESPONSE_CHANNEL_DLC);
374+
m_serialMuxProtChannelIdCurrentVehicleData = m_smpServer.createChannel(CURRENT_VEHICLE_DATA_CHANNEL_NAME, CURRENT_VEHICLE_DATA_CHANNEL_DLC);
376375
m_serialMuxProtChannelIdStatus = m_smpServer.createChannel(STATUS_CHANNEL_NAME, STATUS_CHANNEL_DLC);
377376
m_serialMuxProtChannelIdLineSensors = m_smpServer.createChannel(LINE_SENSOR_CHANNEL_NAME, LINE_SENSOR_CHANNEL_DLC);
378-
m_serialMuxProtChannelIdTimeSyncRsp =
379-
m_smpServer.createChannel(TIME_SYNC_RESPONSE_CHANNEL_NAME, TIME_SYNC_RESPONSE_CHANNEL_DLC);
377+
m_serialMuxProtChannelIdTimeSyncRsp = m_smpServer.createChannel(TIME_SYNC_RESPONSE_CHANNEL_NAME, TIME_SYNC_RESPONSE_CHANNEL_DLC);
380378

381379
/* Channels succesfully created? */
382380
if ((0U != m_serialMuxProtChannelIdCurrentVehicleData) && (0U != m_serialMuxProtChannelIdRemoteCtrlRsp) &&
@@ -523,11 +521,10 @@ void App_timeSyncReqChannelCallback(const uint8_t* payload,
523521

524522
void App::handleTimeSyncRequest(const TimeSyncRequest& req, const uint32_t t2)
525523
{
526-
TimeSyncResponse rsp{req.seq, req.t1_ms, t2, millis()};
527-
528524
if (m_serialMuxProtChannelIdTimeSyncRsp == 0U)
529525
{
530526
return;
531527
}
528+
TimeSyncResponse rsp{req.seq, req.t1_ms, t2, millis()};
532529
(void)m_smpServer.sendData(m_serialMuxProtChannelIdTimeSyncRsp, &rsp, sizeof(rsp));
533530
}

lib/APPRemoteControl/src/SerialMuxChannels.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ typedef struct _RobotSpeed
208208
/** Struct of the "Current Vehicle Data" channel payload. */
209209
typedef struct _VehicleData
210210
{
211-
int64_t timestamp; /**< Timestamp [ms]. */
211+
uint32_t timestamp; /**< Timestamp [ms]. */
212212
int32_t xPos; /**< X position [mm]. */
213213
int32_t yPos; /**< Y position [mm]. */
214214
int32_t orientation; /**< Orientation [mrad]. */

0 commit comments

Comments
 (0)