examples: misc static code analysis fixes
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
bb3584fcdb
commit
32340f6819
@@ -33,9 +33,6 @@ main()
|
|||||||
mraa::Aio* a0;
|
mraa::Aio* a0;
|
||||||
|
|
||||||
a0 = new mraa::Aio(0);
|
a0 = new mraa::Aio(0);
|
||||||
if (a0 == NULL) {
|
|
||||||
return MRAA_ERROR_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
adc_value = a0->read();
|
adc_value = a0->read();
|
||||||
|
|||||||
@@ -56,12 +56,10 @@ main(int argc, char** argv)
|
|||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
mraa::Gpio* gpio = new mraa::Gpio(iopin);
|
mraa::Gpio* gpio = new mraa::Gpio(iopin);
|
||||||
if (gpio == NULL) {
|
|
||||||
return mraa::ERROR_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
mraa::Result response = gpio->dir(mraa::DIR_OUT);
|
mraa::Result response = gpio->dir(mraa::DIR_OUT);
|
||||||
if (response != mraa::SUCCESS) {
|
if (response != mraa::SUCCESS) {
|
||||||
mraa::printError(response);
|
mraa::printError(response);
|
||||||
|
delete gpio;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,5 +53,6 @@ main()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete x;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ main()
|
|||||||
mraa::Pwm* pwm;
|
mraa::Pwm* pwm;
|
||||||
|
|
||||||
pwm = new mraa::Pwm(3);
|
pwm = new mraa::Pwm(3);
|
||||||
if (pwm == NULL) {
|
|
||||||
return MRAA_ERROR_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
|
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
|
||||||
pwm->enable(true);
|
pwm->enable(true);
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@
|
|||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
#include "uart_ow.hpp"
|
#include "uart_ow.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@@ -38,21 +36,23 @@ main(int argc, char** argv)
|
|||||||
mraa::Result rv;
|
mraa::Result rv;
|
||||||
|
|
||||||
if ((rv = uart->reset()) == mraa::SUCCESS) {
|
if ((rv = uart->reset()) == mraa::SUCCESS) {
|
||||||
cout << "Reset succeeded, device(s) detected!" << endl;
|
std::cout << "Reset succeeded, device(s) detected!" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl;
|
std::cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << std::endl;
|
||||||
|
delete uart;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Looking for devices..." << endl;
|
std::cout << "Looking for devices..." << std::endl;
|
||||||
;
|
;
|
||||||
|
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
// start the search from scratch
|
// start the search from scratch
|
||||||
string id = uart->search(true);
|
std::string id = uart->search(true);
|
||||||
|
|
||||||
if (id.empty()) {
|
if (id.empty()) {
|
||||||
cout << "No devices detected." << endl;
|
std::cout << "No devices detected." << std::endl;
|
||||||
|
delete uart;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ main(int argc, char** argv)
|
|||||||
id = uart->search(false);
|
id = uart->search(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Exiting..." << endl;
|
std::cout << "Exiting..." << std::endl;
|
||||||
|
|
||||||
delete uart;
|
delete uart;
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class GpioMmapped {
|
|||||||
String version = mraa.getVersion();
|
String version = mraa.getVersion();
|
||||||
System.out.println("hello mraa");
|
System.out.println("hello mraa");
|
||||||
System.out.println(String.format("Version: %s", version));
|
System.out.println(String.format("Version: %s", version));
|
||||||
|
System.out.println(String.format("Platform: %s", board));
|
||||||
|
|
||||||
Gpio gpio = new Gpio(1);
|
Gpio gpio = new Gpio(1);
|
||||||
|
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ public class I2cCompass {
|
|||||||
i2c.address(HMC5883L_I2C_ADDR);
|
i2c.address(HMC5883L_I2C_ADDR);
|
||||||
i2c.read(rx_tx_buf);
|
i2c.read(rx_tx_buf);
|
||||||
|
|
||||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_X_LSB_REG] & 0xFF);
|
||||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Z_LSB_REG] & 0xFF);
|
||||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
|
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Y_LSB_REG] & 0xFF);
|
||||||
|
|
||||||
direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user