...
Writing a MOOS app and need to post your array of data to ACOMMS_TRANSMIT_DATA? Here's two ways - one good and one bad:
Code Block |
---|
// bad - pass a pointer to Notify along with the size m_Comms.Notify( "ACOMMS_TRANSMIT_DATA", &packet[0], packet.size() ); // good - convert to a string and pass to NorifyNotify m_Comms.Notify( "ACOMMS_TRANSMIT_DATA", string( (char*) &packet[0], packet.size() ) ); |
Notify will actually While these two methods might look the same, and in fact calling the first will ultimate use the same string constructor in as the second method if you pass it a pointer as in the first method, so these two methods are identicalinside the Notify method, they do have slightly different outcomes. Using the first method will flag the message as a binary string while the latter will flag it as a normal string. Just like a moos variable can't be a double and a string, it also can't be a binary string and a normal string (even though they're the same). We want our variables to be flagged as normal strings only, so use the second method. To get your data from ACOMMS_RECEIVED_DATA on the receiving side:
...