Commit a13d324 1 parent 68c6862 commit a13d324 Copy full SHA for a13d324
File tree 2 files changed +36
-5
lines changed
2 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ void App::setup()
175
175
/* Initialize timers. */
176
176
m_sendWaypointTimer.start (SEND_WAYPOINT_TIMER_INTERVAL);
177
177
m_commandTimer.start (SEND_COMMANDS_TIMER_INTERVAL);
178
+ m_motorSpeedTimer.start (SEND_MOTOR_SPEED_TIMER_INTERVAL);
178
179
179
180
/* Start with startup state. */
180
181
m_systemStateMachine.setState (&StartupState::getInstance ());
@@ -356,15 +357,31 @@ void App::processPeriodicTasks()
356
357
m_commandTimer.restart ();
357
358
}
358
359
359
- if (true == m_sendWaypointTimer.isTimeout ())
360
+ if (( true == m_sendWaypointTimer.isTimeout ()) && ( true == m_mqttClient. isConnected () ))
360
361
{
361
362
if (false == m_v2vClient.sendWaypoint (m_latestVehicleData))
362
363
{
363
364
LOG_WARNING (" Waypoint could not be sent." );
364
365
}
365
- else
366
+
367
+ m_sendWaypointTimer.restart ();
368
+ }
369
+
370
+ if ((true == m_motorSpeedTimer.isTimeout ()) && (true == m_smpServer.isSynced ()))
371
+ {
372
+ int16_t centerSpeed = 0 ;
373
+
374
+ if (true == DrivingState::getInstance ().getTopMotorSpeed (centerSpeed))
366
375
{
367
- m_sendWaypointTimer.restart ();
376
+ SpeedData payload;
377
+ payload.center = centerSpeed;
378
+
379
+ if (false == m_smpServer.sendData (m_serialMuxProtChannelIdMotorSpeeds, &payload, sizeof (SpeedData)))
380
+ {
381
+ LOG_WARNING (" Failed to send motor speeds to RU." );
382
+ }
383
+
384
+ m_motorSpeedTimer.restart ();
368
385
}
369
386
}
370
387
}
Original file line number Diff line number Diff line change @@ -72,7 +72,11 @@ class App
72
72
m_smpServer (Board::getInstance().getDevice().getStream(), this ),
73
73
m_mqttClient (),
74
74
m_v2vClient (m_mqttClient),
75
- m_sendWaypointTimer ()
75
+ m_systemStateMachine (),
76
+ m_latestVehicleData (),
77
+ m_sendWaypointTimer (),
78
+ m_commandTimer (),
79
+ m_motorSpeedTimer ()
76
80
{
77
81
}
78
82
@@ -115,6 +119,9 @@ class App
115
119
/* * Send commands timer interval in ms. */
116
120
static const uint32_t SEND_COMMANDS_TIMER_INTERVAL = 100U ;
117
121
122
+ /* * Send motor speed timer interval in ms. */
123
+ static const uint32_t SEND_MOTOR_SPEED_TIMER_INTERVAL = 100U ;
124
+
118
125
/* * MQTT topic name for birth messages. */
119
126
static const char * TOPIC_NAME_BIRTH;
120
127
@@ -147,7 +154,9 @@ class App
147
154
*/
148
155
V2VClient m_v2vClient;
149
156
150
- /* * The system state machine. */
157
+ /* *
158
+ * The system state machine.
159
+ */
151
160
StateMachine m_systemStateMachine;
152
161
153
162
/* *
@@ -165,6 +174,11 @@ class App
165
174
*/
166
175
SimpleTimer m_commandTimer;
167
176
177
+ /* *
178
+ * Timer for sending motor speed to RU.
179
+ */
180
+ SimpleTimer m_motorSpeedTimer;
181
+
168
182
private:
169
183
/* *
170
184
* Handler of fatal errors in the Application.
You can’t perform that action at this time.
0 commit comments