mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
hmtrp: example: make sure string read is 0 terminated
defect #146 Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
7fbe71102a
commit
784e8a3eb8
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "hmtrp.h"
|
#include "hmtrp.h"
|
||||||
@ -128,7 +129,8 @@ int main (int argc, char **argv)
|
|||||||
// check to see if data is available first.
|
// check to see if data is available first.
|
||||||
if (radio->dataAvailable())
|
if (radio->dataAvailable())
|
||||||
{
|
{
|
||||||
int rv = radio->readData(radioBuffer, bufferLength);
|
memset(radioBuffer, 0, bufferLength);
|
||||||
|
int rv = radio->readData(radioBuffer, bufferLength - 1);
|
||||||
|
|
||||||
if (rv > 0)
|
if (rv > 0)
|
||||||
cout << "Received: " << radioBuffer << endl;
|
cout << "Received: " << radioBuffer << endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user