Skip to content

Commit

Permalink
Sent data using a void pointer.
Browse files Browse the repository at this point in the history
Structs defined in SerialMuxChannels can be sent without recasting
  • Loading branch information
gabryelreyes committed Nov 20, 2023
1 parent 2ac3ad0 commit 5ee6d1f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions examples/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ void gCounterChannelCallback(const uint8_t* payload, const uint8_t payloadSize,
{
Timestamp timestampData;
timestampData.timestamp = millis();
gSmpServer.sendData(gSerialMuxProtChannelIdTimestamp, reinterpret_cast<uint8_t*>(&timestampData),
sizeof(timestampData));
gSmpServer.sendData(gSerialMuxProtChannelIdTimestamp, &timestampData, sizeof(timestampData));
}
}
}
4 changes: 2 additions & 2 deletions src/SerialMuxProtServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class SerialMuxProtServer
* @param[in] payloadSize Amount of bytes to send.
* @returns If payload succesfully sent, returns true. Otherwise, false.
*/
bool sendData(uint8_t channelNumber, const uint8_t* payload, uint8_t payloadSize) const
bool sendData(uint8_t channelNumber, const void* payload, uint8_t payloadSize) const
{
bool isSent = false;

Expand Down Expand Up @@ -577,7 +577,7 @@ class SerialMuxProtServer
* @param[in] payloadSize Amount of bytes to send.
* @returns If payload succesfully sent, returns true. Otherwise, false.
*/
bool send(uint8_t channelNumber, const uint8_t* payload, uint8_t payloadSize) const
bool send(uint8_t channelNumber, const void* payload, uint8_t payloadSize) const
{
bool frameSent = false;
uint8_t channelDLC = getTxChannelDLC(channelNumber);
Expand Down

0 comments on commit 5ee6d1f

Please sign in to comment.