t6713: Static analysis fixes
Updated t6713 to use class instances vs class pointers. Creating these on the stack clears up some memory leaks where items created in the heap are not deleted for a handful of the throw conditions. Removed all news/deletes. Also reformatted to remove tabs and some spaces. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include "interfaces/iCO2Sensor.hpp"
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @brief Amphenol Telaire 6713 Series CO2 Module
|
||||
* @defgroup t6713 libupm-t6713
|
||||
@@ -54,97 +53,93 @@ namespace upm {
|
||||
* @snippet t6713.cxx Interesting
|
||||
* @snippet co2-sensor.cxx Interesting
|
||||
*/
|
||||
|
||||
namespace t6713_co2
|
||||
{
|
||||
/* COMMAND VALUES */
|
||||
typedef enum
|
||||
{
|
||||
T6713_COMMAND_RESET,
|
||||
T6713_COMMAND_STATUS,
|
||||
T6713_COMMAND_GET_FIRMWARE_REVISION,
|
||||
T6713_COMMAND_GET_GAS_PPM
|
||||
}MODBUS_COMMANDS;
|
||||
/* COMMAND VALUES */
|
||||
typedef enum
|
||||
{
|
||||
T6713_COMMAND_RESET,
|
||||
T6713_COMMAND_STATUS,
|
||||
T6713_COMMAND_GET_FIRMWARE_REVISION,
|
||||
T6713_COMMAND_GET_GAS_PPM
|
||||
}MODBUS_COMMANDS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_CONDITION,
|
||||
FLASH_ERROR,
|
||||
CALIBRATION_ERROR,
|
||||
WARMUP_MODE,
|
||||
SINGLE_POINT_CALIBRATION,
|
||||
RS232,
|
||||
I2C,
|
||||
RS485
|
||||
}STATUS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t function_code;
|
||||
uint8_t register_address_msb;
|
||||
uint8_t register_address_lsb;
|
||||
uint8_t input_registers_to_read_msb;
|
||||
uint8_t input_registers_to_read_lsb;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_CONDITION,
|
||||
FLASH_ERROR,
|
||||
CALIBRATION_ERROR,
|
||||
WARMUP_MODE,
|
||||
SINGLE_POINT_CALIBRATION,
|
||||
RS232,
|
||||
I2C,
|
||||
RS485
|
||||
}STATUS;
|
||||
}COMMAND;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t function_code;
|
||||
uint8_t register_address_msb;
|
||||
uint8_t register_address_lsb;
|
||||
uint8_t input_registers_to_read_msb;
|
||||
uint8_t input_registers_to_read_lsb;
|
||||
typedef struct
|
||||
{
|
||||
uint8_t function_code;
|
||||
uint8_t byte_count;
|
||||
uint8_t status_msb;
|
||||
uint8_t status_lsb;
|
||||
|
||||
}COMMAND;
|
||||
}RESPONSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t function_code;
|
||||
uint8_t byte_count;
|
||||
uint8_t status_msb;
|
||||
uint8_t status_lsb;
|
||||
|
||||
}RESPONSE;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
READ_INPUT_REGISTERS = 4,
|
||||
WRITE_SINGLE_COIL,
|
||||
WRITE_SINGLE_HOLDING_REGISTER
|
||||
}FUNCTION_CODES;
|
||||
typedef enum
|
||||
{
|
||||
READ_INPUT_REGISTERS = 4,
|
||||
WRITE_SINGLE_COIL,
|
||||
WRITE_SINGLE_HOLDING_REGISTER
|
||||
}FUNCTION_CODES;
|
||||
}//namespace t6713_co2
|
||||
|
||||
|
||||
class T6713 : public ICO2Sensor {
|
||||
public:
|
||||
/**
|
||||
* Instantiates a T6713 object
|
||||
*
|
||||
* @param bus number of used bus
|
||||
*/
|
||||
* Instantiates a T6713 object
|
||||
*
|
||||
* @param bus number of used bus
|
||||
*/
|
||||
T6713 (int bus);
|
||||
|
||||
/**
|
||||
* SI7005 object destructor.
|
||||
*/
|
||||
~T6713 ();
|
||||
* T6713 object destructor.
|
||||
*/
|
||||
virtual ~T6713 () {};
|
||||
|
||||
/**
|
||||
* Returns sensor module name
|
||||
*/
|
||||
* Returns sensor module name
|
||||
*/
|
||||
virtual const char* getModuleName() { return "t6713"; }
|
||||
|
||||
/**
|
||||
* Get relative humidity measurement.
|
||||
*/
|
||||
* Get relative humidity measurement.
|
||||
*/
|
||||
uint16_t getPpm ();
|
||||
/**
|
||||
* Get the firmware version
|
||||
*/
|
||||
* Get the firmware version
|
||||
*/
|
||||
uint16_t getFirmwareRevision();
|
||||
|
||||
|
||||
private:
|
||||
mraa::Result runCommand(t6713_co2::MODBUS_COMMANDS command);
|
||||
uint16_t getSensorData (t6713_co2::MODBUS_COMMANDS cmd);
|
||||
uint16_t getSensorData(t6713_co2::MODBUS_COMMANDS cmd);
|
||||
t6713_co2::STATUS getStatus();
|
||||
|
||||
mraa::I2c* i2c;
|
||||
mraa::I2c i2c;
|
||||
mraa::Result status;
|
||||
};
|
||||
|
||||
|
||||
}//namespace upm
|
||||
|
||||
Reference in New Issue
Block a user