Closed jamescookmd closed 2 years ago
@chipaudette please take a look. (And let me know if I'm doing the code review workflow wrong -- this is my first pull request!)
Hello @jamescookmd. Thanks for creating this pull request and bringing the issue to our attention. I found myself needing to extend the datastream capabilities so I added a way to set a callback when a multi-byte data stream message is received. I addressed the de-referenced type pun warning by using memcpy to avoid memory misalignment errors. I hope that you find it satisfactory. If not, please raise a concern at the new pull request.
Because this new pull request covers this issue as well, I am closing it. Thanks for your contributions! Feature_Add_Callback_for_Datastream_Messages
When I compile the first example (AudioPassThru) I get this warning: /Users/jamescook/Documents/Arduino/libraries/Tympan_Library/src/SerialManagerBase.cpp: In member function 'virtual void SerialManagerBase::respondToByte(char)': /Users/jamescook/Documents/Arduino/libraries/Tympan_Library/src/SerialManagerBase.cpp:56:46: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] stream_length = ((int)(stream_data));
The warning comes from the cast of byte stream_data[SIZE] to int*. See https://www.ibm.com/docs/en/ztpf/1.1.0.14?topic=warnings-type-pun-problems
Since the code appears to be correct, use reinterpret_cast<> and a separate local variable to avoid the warning.
This is my first github pull request, please let me know if I'm doing something wrong. :-)