From 7f7fdb844155cdab54fe0b75d157c26b5065e769 Mon Sep 17 00:00:00 2001 From: Stefan Andritoiu Date: Tue, 10 Nov 2015 13:44:42 +0200 Subject: [PATCH] mhz16: Split the getData(int* gas, int *temp) function into two separate functions and updated the C++ an Java examples Signed-off-by: Stefan Andritoiu Signed-off-by: Mihai Tudor Panu --- examples/c++/mhz16.cxx | 13 +++++++------ examples/java/MHZ16Sample.java | 12 ++++++------ src/mhz16/mhz16.cxx | 16 +++++++++++++--- src/mhz16/mhz16.h | 23 +++++++++++++++++++---- 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/examples/c++/mhz16.cxx b/examples/c++/mhz16.cxx index bb46ae26..542dc5fd 100644 --- a/examples/c++/mhz16.cxx +++ b/examples/c++/mhz16.cxx @@ -62,14 +62,15 @@ int main (int argc, char **argv) sleep(1); - int gas; - int temp; - while (shouldRun) { - co2->getData(&gas, &temp); - cout << "CO2 concentration: " << gas << " PPM, " - << "Temperature (in C): " << temp <getData()){ + cerr << "Failed to retrieve data" << endl; + continue; + } + + cout << "CO2 concentration: " << co2->getGas() << " PPM, " + << "Temperature (in C): " << co2->getTemperature() <