File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed
src/modm/platform/can/canusb Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ class CanUsb : public ::modm::Can
5353 inline bool
5454 isMessageAvailable ()
5555 {
56- return (!this ->readBuffer .empty ());
56+ MutexGuard stateGuard (readBufferLock);
57+ return (not this ->readBuffer .empty ());
5758 }
5859
5960 bool
Original file line number Diff line number Diff line change @@ -180,6 +180,7 @@ template <typename SerialPort>
180180bool
181181modm::platform::CanUsb<SerialPort>::getMessage(can::Message& message)
182182{
183+ MutexGuard stateGuard (readBufferLock);
183184 if (not this ->readBuffer .empty ())
184185 {
185186 message = this ->readBuffer .front ();
@@ -229,6 +230,7 @@ modm::platform::CanUsb<SerialPort>::update()
229230 if (modm::CanLawicelFormatter::convertToCanMessage (
230231 this ->tmpRead .c_str (), message))
231232 {
233+ MutexGuard stateGuard (readBufferLock);
232234 this ->readBuffer .push (message);
233235 }
234236 }
You can’t perform that action at this time.
0 commit comments