java: Changed size_t and unsigned int to int in array declarations. Renamed buf to buffer where necesarry. Moved most Java array typemaps to java_buffer.i. Fixed some String buffers.

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/upm.i
This commit is contained in:
Petre Eftime 2015-09-07 19:00:30 +03:00 committed by Mihai Tudor Panu
parent ab730038fd
commit 2cab79b4c2
50 changed files with 237 additions and 326 deletions

View File

@ -50,10 +50,10 @@ DS1307::~DS1307()
mraa_i2c_stop(m_i2c);
}
mraa_result_t DS1307::writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
mraa::Result DS1307::writeBytes(uint8_t reg, uint8_t *buffer, int len)
{
if (!len || !buffer)
return MRAA_ERROR_INVALID_PARAMETER;
return mraa::ERROR_INVALID_PARAMETER;
// create a buffer 1 byte larger than the supplied buffer,
// store the register in the first byte
@ -67,10 +67,10 @@ mraa_result_t DS1307::writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
mraa_i2c_address(m_i2c, DS1307_I2C_ADDR);
return mraa_i2c_write(m_i2c, buf2, len + 1);
return (mraa::Result) mraa_i2c_write(m_i2c, buf2, len + 1);
}
uint8_t DS1307::readBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
int DS1307::readBytes(uint8_t reg, uint8_t *buffer, int len)
{
if (!len || !buffer)
return 0;
@ -166,7 +166,7 @@ bool DS1307::setTime()
return writeBytes(0, buffer, 7);
}
mraa_result_t DS1307::enableClock()
mraa::Result DS1307::enableClock()
{
// the oscillator enable bit is the high bit of reg 0
// so read it, clear it, and write it back.
@ -179,7 +179,7 @@ mraa_result_t DS1307::enableClock()
return writeBytes(0, &buf, 1);
}
mraa_result_t DS1307::disableClock()
mraa::Result DS1307::disableClock()
{
// the oscillator enable bit is the high bit of reg 0
// so read it, set it, and write it back.

View File

@ -27,7 +27,7 @@
#pragma once
#include <string>
#include <mraa/i2c.h>
#include <mraa/i2c.hpp>
#define DS1307_I2C_BUS 0
#define DS1307_I2C_ADDR 0x68
@ -102,7 +102,7 @@ namespace upm {
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t enableClock();
mraa::Result enableClock();
/**
* Disables the oscillator on the clock. This prevents the clock
@ -110,7 +110,7 @@ namespace upm {
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t disableClock();
mraa::Result disableClock();
/**
* Writes value(s) into registers
@ -120,7 +120,7 @@ namespace upm {
* @param len Number of bytes to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, int len);
/**
* Reads value(s) from registers
@ -130,7 +130,7 @@ namespace upm {
* @param len Number of bytes to read
* @return Number of bytes read
*/
uint8_t readBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
int readBytes(uint8_t reg, uint8_t *buffer, int len);
/**
* Converts a BCD value into decimal

View File

@ -1,24 +1,10 @@
%module javaupm_ds1307
%include "../upm.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%{
#include "ds1307.h"
%}
%typemap(jni) (uint8_t *buffer, unsigned int len) "jbyteArray";
%typemap(jtype) (uint8_t *buffer, unsigned int len) "byte[]";
%typemap(jstype) (uint8_t *buffer, unsigned int len) "byte[]";
%typemap(javain) (uint8_t *buffer, unsigned int len) "$javainput";
%typemap(in) (uint8_t *buffer, unsigned int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buffer, unsigned int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "ds1307.h"

View File

@ -46,7 +46,7 @@ Gas::~Gas() {
}
int
Gas::getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples,
Gas::getSampledWindow (unsigned int freqMS, int numberOfSamples,
uint16_t * buffer) {
int sampleIdx = 0;
@ -70,7 +70,7 @@ Gas::getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples,
int
Gas::findThreshold (thresholdContext* ctx, unsigned int threshold,
uint16_t * buffer, unsigned int len) {
uint16_t * buffer, int len) {
long sum = 0;
for (unsigned int i = 0; i < len; i++) {
sum += buffer[i];

View File

@ -65,7 +65,7 @@ class Gas {
* @param numberOfSamples Number of sample to sample for this window
* @param buffer Buffer with sampled data
*/
virtual int getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples, uint16_t * buffer);
virtual int getSampledWindow (unsigned int freqMS, int numberOfSamples, uint16_t * buffer);
/**
* Given the sampled buffer, this method returns TRUE/FALSE if the threshold
@ -76,7 +76,7 @@ class Gas {
* @param buffer Buffer with samples
* @param len Buffer length
*/
virtual int findThreshold (thresholdContext* ctx, unsigned int threshold, uint16_t * buffer, unsigned int len);
virtual int findThreshold (thresholdContext* ctx, unsigned int threshold, uint16_t * buffer, int len);
/**
* Returns average data for the sampled window

View File

@ -11,33 +11,33 @@
#include "tp401.h"
%}
%typemap(jni) (uint16_t *buffer, unsigned int len) "jshortArray";
%typemap(jtype) (uint16_t *buffer, unsigned int len) "short[]";
%typemap(jstype) (uint16_t *buffer, unsigned int len) "short[]";
%typemap(jni) (uint16_t *buffer, int len) "jshortArray";
%typemap(jtype) (uint16_t *buffer, int len) "short[]";
%typemap(jstype) (uint16_t *buffer, int len) "short[]";
%typemap(javain) (uint16_t *buffer, unsigned int len) "$javainput";
%typemap(javain) (uint16_t *buffer, int len) "$javainput";
%typemap(in) (uint16_t *buffer, unsigned int len) {
%typemap(in) (uint16_t *buffer, int len) {
$1 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint16_t *buffer, unsigned int len) {
%typemap(freearg) (uint16_t *buffer, int len) {
JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$1, 0);
}
%typemap(jni) (unsigned int numberOfSamples, uint16_t *buffer) "jshortArray";
%typemap(jtype) (unsigned int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(jstype) (unsigned int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(jni) (int numberOfSamples, uint16_t *buffer) "jshortArray";
%typemap(jtype) (int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(jstype) (int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(javain) (unsigned int numberOfSamples, uint16_t *buffer) "$javainput";
%typemap(javain) (int numberOfSamples, uint16_t *buffer) "$javainput";
%typemap(in) (unsigned int numberOfSamples, uint16_t *buffer) {
%typemap(in) (int numberOfSamples, uint16_t *buffer) {
$2 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL);
$1 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (unsigned int numberOfSamples, uint16_t *buffer) {
%typemap(freearg) (int numberOfSamples, uint16_t *buffer) {
JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0);
}

View File

@ -45,12 +45,12 @@ GroveMD::GroveMD(int bus, uint8_t address)
// this board *requires* 100Khz i2c bus only
mraa_result_t rv;
if ( (rv = mraa_i2c_frequency(m_i2c, MRAA_I2C_STD)) != MRAA_SUCCESS )
{
cerr << "GroveMD: Could not set i2c frequency (MRAA_I2C_STD). " << endl;
mraa_result_print(rv);
return;
}
//if ( (rv = mraa_i2c_frequency(m_i2c, MRAA_I2C_STD)) != MRAA_SUCCESS )
//{
//cerr << "GroveMD: Could not set i2c frequency (MRAA_I2C_STD). " << endl;
//mraa_result_print(rv);
//return;
//}
if (mraa_i2c_address(m_i2c, m_addr))
{

View File

@ -105,7 +105,7 @@ bool GROVESCAM::dataAvailable(unsigned int millis)
return false;
}
int GROVESCAM::readData(uint8_t *buffer, size_t len)
int GROVESCAM::readData(uint8_t *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -118,7 +118,7 @@ int GROVESCAM::readData(uint8_t *buffer, size_t len)
return rv;
}
int GROVESCAM::writeData(uint8_t *buffer, size_t len)
int GROVESCAM::writeData(uint8_t *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);

View File

@ -117,7 +117,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(uint8_t *buffer, size_t len);
int readData(uint8_t *buffer, int len);
/**
* Writes the data in the buffer to the device
@ -126,7 +126,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(uint8_t *buffer, size_t len);
int writeData(uint8_t *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. For this device, the default

View File

@ -1,23 +1,9 @@
%module javaupm_grovescam
%include "../upm.i"
%include "../java_buffer.i"
%{
#include "grovescam.h"
%}
%typemap(jni) (uint8_t *buffer, size_t len) "jbyteArray";
%typemap(jtype) (uint8_t *buffer, size_t len) "byte[]";
%typemap(jstype) (uint8_t *buffer, size_t len) "byte[]";
%typemap(javain) (uint8_t *buffer, size_t len) "$javainput";
%typemap(in) (uint8_t *buffer, size_t len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buffer, size_t len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "grovescam.h"

View File

@ -89,7 +89,7 @@ bool HM11::dataAvailable(unsigned int millis)
return false;
}
int HM11::readData(char *buffer, size_t len)
int HM11::readData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -102,7 +102,7 @@ int HM11::readData(char *buffer, size_t len)
return rv;
}
int HM11::writeData(char *buffer, size_t len)
int HM11::writeData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);

View File

@ -111,7 +111,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(char *buffer, size_t len);
int readData(char *buffer, int len);
/**
* Writes the data in the buffer to the device
@ -120,7 +120,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, size_t len);
int writeData(char *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. For this device, the default

View File

@ -1,6 +1,7 @@
%module javaupm_hm11
%include "../upm.i"
%include "carrays.i"
%include "../java_buffer.i"
%{
#include "hm11.h"

View File

@ -94,7 +94,7 @@ bool HMTRP::dataAvailable(unsigned int millis)
return false;
}
int HMTRP::readData(char *buffer, size_t len, int millis)
int HMTRP::readData(char *buffer, int len, int millis)
{
if (m_ttyFd == -1)
return(-1);
@ -114,7 +114,7 @@ int HMTRP::readData(char *buffer, size_t len, int millis)
return rv;
}
int HMTRP::writeData(char *buffer, size_t len)
int HMTRP::writeData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);

View File

@ -124,7 +124,7 @@ namespace upm {
* waiting forever (default).
* @return Number of bytes read; 0 if timed out and millis is >= 0
*/
int readData(char *buffer, size_t len, int millis=-1);
int readData(char *buffer, int len, int millis=-1);
/**
* Writes the data in the buffer to the device
@ -133,7 +133,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, size_t len);
int writeData(char *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. The default

View File

@ -2,6 +2,7 @@
%include "../upm.i"
%include "stdint.i"
%include "typemaps.i"
%include "../java_buffer.i"
%apply uint32_t *OUTPUT { uint32_t *freq, uint32_t *dataRate };
%apply uint16_t *OUTPUT { uint16_t *rxBandwidth };

45
src/java_buffer.i Normal file
View File

@ -0,0 +1,45 @@
%typemap(jni) (uint8_t *buffer, int len) "jbyteArray";
%typemap(jtype) (uint8_t *buffer, int len) "byte[]";
%typemap(jstype) (uint8_t *buffer, int len) "byte[]";
%typemap(javain) (uint8_t *buffer, int len) "$javainput";
%typemap(in) (uint8_t *buffer, int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buffer, int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%typemap(jni) (uint8_t *pkt, int len) "jbyteArray";
%typemap(jtype) (uint8_t *pkt, int len) "byte[]";
%typemap(jstype) (uint8_t *pkt, int len) "byte[]";
%typemap(javain) (uint8_t *pkt, int len) "$javainput";
%typemap(in) (uint8_t *pkt, int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *pkt, int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%typemap(jni) (char *buffer, int len) "jbyteArray";
%typemap(jtype) (char *buffer, int len) "byte[]";
%typemap(jstype) (char *buffer, int len) "byte[]";
%typemap(javain) (char *buffer, int len) "$javainput";
%typemap(in) (char *buffer, int len) {
$1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (char *buffer, int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}

View File

@ -6,18 +6,6 @@
%apply signed char[] {uint8_t []};
%{
#include "lcd.h"
#include "ssd.h"
#include "ssd1327.h"
#include "ssd1308.h"
#include "eboled.h"
#include "lcm1602.h"
#include "jhd1313m1.h"
#include "sainsmartks.h"
%}
%typemap(jni) (uint8_t *data, int bytes) "jbyteArray";
%typemap(jtype) (uint8_t *data, int bytes) "byte[]";
%typemap(jstype) (uint8_t *data, int bytes) "byte[]";
@ -33,6 +21,17 @@
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%{
#include "lcd.h"
#include "ssd.h"
#include "ssd1327.h"
#include "ssd1308.h"
#include "eboled.h"
#include "lcm1602.h"
#include "jhd1313m1.h"
#include "sainsmartks.h"
%}
%include "lcd.h"
%include "ssd.h"
%include "ssd1327.h"

View File

@ -3,6 +3,7 @@
%include "cpointer.i"
%include "typemaps.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%feature("director") IsrCallback;
@ -12,10 +13,6 @@
%apply int {mraa::Edge};
%apply float *INOUT { float *x, float *y, float *z };
%{
#include "lsm9ds0.h"
%}
%typemap(jni) float* "jfloatArray"
%typemap(jstype) float* "float[]"
%typemap(jtype) float* "float[]"
@ -46,19 +43,8 @@
%ignore getGyroscope(float *, float *, float *);
%ignore getMagnetometer(float *, float *, float *);
%typemap(jni) (uint8_t *buf, int len) "jbyteArray";
%typemap(jtype) (uint8_t *buf, int len) "byte[]";
%typemap(jstype) (uint8_t *buf, int len) "byte[]";
%typemap(javain) (uint8_t *buf, int len) "$javainput";
%typemap(in) (uint8_t *buf, int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buf, int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%{
#include "lsm9ds0.h"
%}
%include "lsm9ds0.h"

View File

@ -287,7 +287,7 @@ uint8_t LSM9DS0::readReg(DEVICE_T dev, uint8_t reg)
return device->readReg(reg);
}
void LSM9DS0::readRegs(DEVICE_T dev, uint8_t reg, uint8_t *buf, int len)
void LSM9DS0::readRegs(DEVICE_T dev, uint8_t reg, uint8_t *buffer, int len)
{
mraa::I2c *device;
@ -302,7 +302,7 @@ void LSM9DS0::readRegs(DEVICE_T dev, uint8_t reg, uint8_t *buf, int len)
// We need to set the high bit of the register to enable
// auto-increment mode for reading multiple registers in one go.
device->readBytesReg(reg | m_autoIncrementMode, buf, len);
device->readBytesReg(reg | m_autoIncrementMode, buffer, len);
}
bool LSM9DS0::writeReg(DEVICE_T dev, uint8_t reg, uint8_t val)

View File

@ -1126,7 +1126,7 @@ namespace upm {
* @param len the number of registers to read
* @return the value of the register
*/
void readRegs(DEVICE_T dev, uint8_t reg, uint8_t *buf, int len);
void readRegs(DEVICE_T dev, uint8_t reg, uint8_t *buffer, int len);
/**
* write to a register

View File

@ -2,24 +2,10 @@
%include "../upm.i"
%include "stdint.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%{
#include "m24lr64e.h"
%}
%typemap(jni) (uint8_t *buf, unsigned int len) "jbyteArray";
%typemap(jtype) (uint8_t *buf, unsigned int len) "byte[]";
%typemap(jstype) (uint8_t *buf, unsigned int len) "byte[]";
%typemap(javain) (uint8_t *buf, unsigned int len) "$javainput";
%typemap(in) (uint8_t *buf, unsigned int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buf, unsigned int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "m24lr64e.h"

View File

@ -163,9 +163,9 @@ uint8_t M24LR64E::getAFI()
return EEPROM_Read_Byte(AFI_ADDR);
}
void M24LR64E::getUID(uint8_t* buf)
void M24LR64E::getUID(uint8_t* buffer)
{
EEPROM_Read_Bytes(UID_ADDR,buf,UID_LENGTH);
EEPROM_Read_Bytes(UID_ADDR, buffer, UID_LENGTH);
}
uint32_t M24LR64E::getMemorySize()
@ -184,14 +184,14 @@ void M24LR64E::clearMemory()
}
}
void M24LR64E::writeByte(unsigned int address, uint8_t data)
mraa::Result M24LR64E::writeByte(unsigned int address, uint8_t data)
{
EEPROM_Write_Byte(address, data);
return EEPROM_Write_Byte(address, data);
}
void M24LR64E::writeBytes(unsigned int address, uint8_t* buf, unsigned int len)
mraa::Result M24LR64E::writeBytes(unsigned int address, uint8_t* buffer, int len)
{
EEPROM_Write_Bytes(address, buf, len);
return EEPROM_Write_Bytes(address, buffer, len);
}
uint8_t M24LR64E::readByte(unsigned int address)
@ -199,31 +199,34 @@ uint8_t M24LR64E::readByte(unsigned int address)
return EEPROM_Read_Byte(address);
}
void M24LR64E::readBytes(unsigned int address, uint8_t* buf, unsigned int len)
int M24LR64E::readBytes(unsigned int address, uint8_t* buffer, int len)
{
EEPROM_Read_Bytes(address, buf, len);
return EEPROM_Read_Bytes(address, buffer, len);
}
void M24LR64E::EEPROM_Write_Byte(unsigned int address, uint8_t data)
mraa::Result M24LR64E::EEPROM_Write_Byte(unsigned int address, uint8_t data)
{
const int pktLen = 3;
uint8_t buf[pktLen];
mraa::Result rv;
buf[0] = ((address >> 8) & 0xff);
buf[1] = (address & 0xff);
buf[2] = data;
if (m_i2c.write(buf, pktLen))
if ((rv = m_i2c.write(buf, pktLen)))
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
usleep(I2C_WRITE_TIME * 1000);
return rv;
}
void M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
unsigned int len)
mraa::Result M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
int len)
{
const int pktLen = 2 + len;
uint8_t buf[pktLen];
mraa::Result rv;
buf[0] = ((address >> 8) & 0xff);
buf[1] = (address & 0xff);
@ -231,10 +234,12 @@ void M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
for (int i=0; i<len; i++)
buf[2+i] = data[i];
if (m_i2c.write(buf, pktLen))
if ((rv = m_i2c.write(buf, pktLen)))
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
usleep(I2C_WRITE_TIME * 1000);
return rv;
}
uint8_t M24LR64E::EEPROM_Read_Byte(unsigned int address)
@ -265,8 +270,8 @@ uint8_t M24LR64E::EEPROM_Read_Byte(unsigned int address)
return buf[0];
}
unsigned int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
uint8_t* buf, unsigned int len)
int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
uint8_t* buffer, int len)
{
const int apktLen = 2;
uint8_t abuf[apktLen];
@ -280,7 +285,7 @@ unsigned int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
return false;
}
int rv = m_i2c.read(buf, len);
int rv = m_i2c.read(buffer, len);
if (rv != len)
{
cerr << __FUNCTION__ << "@" << __LINE__ << ": read failed" << endl;

View File

@ -218,7 +218,7 @@ namespace upm {
*
* @param buf Buffer to hold the returned UID. Must be UID_LENGTH bytes.
*/
void getUID(uint8_t* buf);
void getUID(uint8_t* buffer);
/**
* Returns the memory size
@ -239,7 +239,7 @@ namespace upm {
* @param address Address to write to
* @param data Data to write
*/
void writeByte(unsigned int address, uint8_t data);
mraa::Result writeByte(unsigned int address, uint8_t data);
/**
* Writes bytes to the EEPROM
@ -248,7 +248,7 @@ namespace upm {
* @param data Data to write
* @param data Length of the data buffer
*/
void writeBytes(unsigned int address, uint8_t* buf, unsigned int len);
mraa::Result writeBytes(unsigned int address, uint8_t* buffer, int len);
/**
* Reads a byte from the EEPROM
@ -265,16 +265,16 @@ namespace upm {
* @param buffer Buffer to store data
* @param len Number of bytes to read
*/
void readBytes(unsigned int address, uint8_t* buf, unsigned int len);
int readBytes(unsigned int address, uint8_t* buffer, int len);
protected:
mraa::I2c m_i2c;
void EEPROM_Write_Byte(unsigned int address, uint8_t data);
void EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
unsigned int len);
mraa::Result EEPROM_Write_Byte(unsigned int address, uint8_t data);
mraa::Result EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
int len);
uint8_t EEPROM_Read_Byte(unsigned int address);
unsigned int EEPROM_Read_Bytes(unsigned int address,
uint8_t* buf, unsigned int len);
int EEPROM_Read_Bytes(unsigned int address,
uint8_t* buffer, int len);
private:
uint8_t m_addr;

View File

@ -3,8 +3,7 @@
%include "cpointer.i"
%include "typemaps.i"
%include "arrays_java.i";
%apply signed char[] {unsigned char *};
%include "../java_buffer.i"
%apply int *OUTPUT { int *gas, int *temp };

View File

@ -91,7 +91,7 @@ bool MHZ16::dataAvailable(unsigned int millis)
return false;
}
int MHZ16::readData(char *buffer, size_t len)
int MHZ16::readData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -107,7 +107,7 @@ int MHZ16::readData(char *buffer, size_t len)
return rv;
}
int MHZ16::writeData(char *buffer, size_t len)
int MHZ16::writeData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -156,7 +156,7 @@ bool MHZ16::setupTty(speed_t baud)
return true;
}
bool MHZ16::verifyPacket(unsigned char *pkt)
bool MHZ16::verifyPacket(uint8_t *pkt, int len)
{
if (pkt[0] != 0xff || pkt[1] != 0x86)
{
@ -193,7 +193,7 @@ bool MHZ16::getData(int *gas, int *temp)
return false;
}
if (!verifyPacket(packet))
if (!verifyPacket(packet, 9))
{
cerr << __FUNCTION__ << ": Packet verify failed." << endl;
return false;

View File

@ -106,7 +106,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(char *buffer, size_t len);
int readData(char *buffer, int len);
/**
* Writes the data in the buffer to the device
@ -115,7 +115,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, size_t len);
int writeData(char *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. The default
@ -132,7 +132,7 @@ namespace upm {
* @param pkt Packet to check
* @return True if the checksum is valid, false otherwise
*/
bool verifyPacket(unsigned char *pkt);
bool verifyPacket(uint8_t *pkt, int len);
/**
* Queries the sensor and returns gas (CO2) concentration and

View File

@ -7,33 +7,33 @@
#include "mic.h"
%}
%typemap(jni) (uint16_t *buffer, unsigned int len) "jshortArray";
%typemap(jtype) (uint16_t *buffer, unsigned int len) "short[]";
%typemap(jstype) (uint16_t *buffer, unsigned int len) "short[]";
%typemap(jni) (uint16_t *buffer, int len) "jshortArray";
%typemap(jtype) (uint16_t *buffer, int len) "short[]";
%typemap(jstype) (uint16_t *buffer, int len) "short[]";
%typemap(javain) (uint16_t *buffer, unsigned int len) "$javainput";
%typemap(javain) (uint16_t *buffer, int len) "$javainput";
%typemap(in) (uint16_t *buffer, unsigned int len) {
%typemap(in) (uint16_t *buffer, int len) {
$1 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint16_t *buffer, unsigned int len) {
%typemap(freearg) (uint16_t *buffer, int len) {
JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$1, 0);
}
%typemap(jni) (unsigned int numberOfSamples, uint16_t *buffer) "jshortArray";
%typemap(jtype) (unsigned int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(jstype) (unsigned int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(jni) (int numberOfSamples, uint16_t *buffer) "jshortArray";
%typemap(jtype) (int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(jstype) (int numberOfSamples, uint16_t *buffer) "short[]";
%typemap(javain) (unsigned int numberOfSamples, uint16_t *buffer) "$javainput";
%typemap(javain) (int numberOfSamples, uint16_t *buffer) "$javainput";
%typemap(in) (unsigned int numberOfSamples, uint16_t *buffer) {
%typemap(in) (int numberOfSamples, uint16_t *buffer) {
$2 = (uint16_t *) JCALL2(GetShortArrayElements, jenv, $input, NULL);
$1 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (unsigned int numberOfSamples, uint16_t *buffer) {
%typemap(freearg) (int numberOfSamples, uint16_t *buffer) {
JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0);
}

View File

@ -48,7 +48,7 @@ Microphone::~Microphone() {
}
int
Microphone::getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples,
Microphone::getSampledWindow (unsigned int freqMS, int numberOfSamples,
uint16_t * buffer) {
int sampleIdx = 0;
@ -72,7 +72,7 @@ Microphone::getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples,
int
Microphone::findThreshold (thresholdContext* ctx, unsigned int threshold,
uint16_t * buffer, unsigned int len) {
uint16_t * buffer, int len) {
long sum = 0;
for (unsigned int i = 0; i < len; i++) {
sum += buffer[i];

View File

@ -80,7 +80,7 @@ class Microphone {
* @param numberOfSamples Number of sample to sample for this window
* @param buffer Buffer with sampled data
*/
int getSampledWindow (unsigned int freqMS, unsigned int numberOfSamples, uint16_t * buffer);
int getSampledWindow (unsigned int freqMS, int numberOfSamples, uint16_t * buffer);
/**
* Given the sampled buffer, this method returns TRUE/FALSE if threshold
@ -91,7 +91,7 @@ class Microphone {
* @param buffer Buffer with samples
* @param len Buffer length
*/
int findThreshold (thresholdContext* ctx, unsigned int threshold, uint16_t * buffer, unsigned int len);
int findThreshold (thresholdContext* ctx, unsigned int threshold, uint16_t * buffer, int len);
/**
*

View File

@ -2,13 +2,10 @@
%include "../upm.i"
%include "typemaps.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%apply short *OUTPUT { short * ptrX, short * ptrY, short * ptrZ };
%{
#include "mma7455.h"
%}
%typemap(jni) short* "jshortArray"
%typemap(jstype) short* "short[]"
%typemap(jtype) short* "short[]"
@ -25,19 +22,8 @@
%ignore readData(short *, short *, short *);
%typemap(jni) (unsigned char *buf, unsigned char size) "jbyteArray";
%typemap(jtype) (unsigned char *buf, unsigned char size) "byte[]";
%typemap(jstype) (unsigned char *buf, unsigned char size) "byte[]";
%typemap(javain) (unsigned char *buf, unsigned char size) "$javainput";
%typemap(in) (unsigned char *buf, unsigned char size) {
$1 = (unsigned char *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (unsigned char *buf, unsigned char size) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%{
#include "mma7455.h"
%}
%include "mma7455.h"

View File

@ -50,7 +50,7 @@ MMA7455::MMA7455 (int bus, int devAddr) : m_i2ControlCtx(bus) {
// setting GLVL 0x1 (64LSB/g) and MODE 0x1 (Measurement Mode)
data = (BIT (MMA7455_GLVL0) | BIT (MMA7455_MODE0));
error = ic2WriteReg (MMA7455_MCTL, &data, 0x1);
error = i2cWriteReg (MMA7455_MCTL, &data, 0x1);
if (error != mraa::SUCCESS) {
std::cout << "ERROR :: MMA7455 instance wan not created (Mode)" << std::endl;
return;
@ -80,7 +80,7 @@ MMA7455::calibrate () {
xyz.value.y += 2 * -xyz.value.y;
xyz.value.z += 2 * -(xyz.value.z - 64);
error = ic2WriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
error = i2cWriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
if (error != mraa::SUCCESS) {
return error;
}
@ -97,7 +97,7 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
int nBytes = 0;
/*do {
nBytes = ic2ReadReg (MMA7455_STATUS, &data, 0x1);
nBytes = i2cReadReg (MMA7455_STATUS, &data, 0x1);
} while ( !(data & MMA7455_DRDY) && nBytes == mraa::SUCCESS);
if (nBytes == mraa::SUCCESS) {
@ -105,7 +105,7 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
return mraa::SUCCESS;
}*/
nBytes = ic2ReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
nBytes = i2cReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
if (nBytes == 0) {
std::cout << "NO_GDB :: 2" << std::endl;
return mraa::ERROR_UNSPECIFIED;
@ -140,7 +140,7 @@ short *MMA7455::readData() {
#endif
int
MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
MMA7455::i2cReadReg (unsigned char reg, uint8_t *buffer, int len) {
if (mraa::SUCCESS != m_i2ControlCtx.address(m_controlAddr)) {
return 0;
}
@ -153,22 +153,22 @@ MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size)
return 0;
}
return (int) m_i2ControlCtx.read(buf, size);
return (int) m_i2ControlCtx.read(buffer, len);
}
mraa::Result
MMA7455::ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size) {
MMA7455::i2cWriteReg (unsigned char reg, uint8_t *buffer, int len) {
mraa::Result error = mraa::SUCCESS;
uint8_t data[size + 1];
uint8_t data[len + 1];
data[0] = reg;
memcpy(&data[1], buf, size);
memcpy(&data[1], buffer, len);
error = m_i2ControlCtx.address (m_controlAddr);
if (error != mraa::SUCCESS) {
return error;
}
error = m_i2ControlCtx.write (data, size + 1);
error = m_i2ControlCtx.write (data, len + 1);
if (error != mraa::SUCCESS) {
return error;
}

View File

@ -214,19 +214,19 @@ class MMA7455 {
*
*
* @param reg Register address
* @param buf Register data buffer
* @param buffer Register data buffer
* @param size Buffer size
*/
int ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size);
int i2cReadReg (unsigned char reg, uint8_t *buffer, int len);
/**
*
*
* @param reg Register address
* @param buf Register data buffer
* @param buffer Register data buffer
* @param size Buffer size
*/
mraa::Result ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size);
mraa::Result i2cWriteReg (unsigned char reg, uint8_t *buffer, int len);
private:
std::string m_name;

View File

@ -1,24 +1,10 @@
%module javaupm_mpr121
%include "../upm.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%{
#include "mpr121.h"
%}
%typemap(jni) (uint8_t *buffer, unsigned int len) "jbyteArray";
%typemap(jtype) (uint8_t *buffer, unsigned int len) "byte[]";
%typemap(jstype) (uint8_t *buffer, unsigned int len) "byte[]";
%typemap(javain) (uint8_t *buffer, unsigned int len) "$javainput";
%typemap(in) (uint8_t *buffer, unsigned int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buffer, unsigned int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "mpr121.h"

View File

@ -44,7 +44,7 @@ MPR121::MPR121(int bus, uint8_t address) : m_i2c(bus)
m_overCurrentFault = false;
}
mraa::Result MPR121::writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
mraa::Result MPR121::writeBytes(uint8_t reg, uint8_t *buffer, int len)
{
if (!len || !buffer)
return mraa::SUCCESS;
@ -64,17 +64,17 @@ mraa::Result MPR121::writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
return m_i2c.write(buf2, len + 1);
}
void MPR121::readBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
int MPR121::readBytes(uint8_t reg, uint8_t *buffer, int len)
{
if (!len || !buffer)
return;
return 0;
// The usual m_i2c.read() does not work here, so we need to
// read each byte individually.
for (int i=0; i<len; i++)
buffer[i] = m_i2c.readReg(reg + i);
return;
return len;
}
bool MPR121::configAN3944()

View File

@ -93,7 +93,7 @@ namespace upm {
* @param len Number of bytes to write
* @return mraa::Result
*/
mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, int len);
/**
* Reads value(s) from registers
@ -102,7 +102,7 @@ namespace upm {
* @param buffer Buffer for data storage
* @param len Number of bytes to read
*/
void readBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
int readBytes(uint8_t reg, uint8_t *buffer, int len);
/**
* Button states

View File

@ -2,6 +2,7 @@
%include "../upm.i"
%include "typemaps.i"
%include "arrays_java.i"
%include "../java_buffer.i"
%feature("director") IsrCallback;
@ -34,20 +35,5 @@
%ignore getGyroscope(float *, float *, float *);
%ignore getMagnetometer(float *, float *, float *);
%typemap(jni) (uint8_t *buf, int len) "jbyteArray";
%typemap(jtype) (uint8_t *buf, int len) "byte[]";
%typemap(jstype) (uint8_t *buf, int len) "byte[]";
%typemap(javain) (uint8_t *buf, int len) "$javainput";
%typemap(in) (uint8_t *buf, int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buf, int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "mpu60x0.h"
%include "mpu9150.h"

View File

@ -139,9 +139,9 @@ uint8_t MPU60X0::readReg(uint8_t reg)
return m_i2c.readReg(reg);
}
void MPU60X0::readRegs(uint8_t reg, uint8_t *buf, int len)
void MPU60X0::readRegs(uint8_t reg, uint8_t *buffer, int len)
{
m_i2c.readBytesReg(reg, buf, len);
m_i2c.readBytesReg(reg, buffer, len);
}
bool MPU60X0::writeReg(uint8_t reg, uint8_t val)

View File

@ -706,11 +706,11 @@ namespace upm {
* read contiguous refister into a buffer
*
* @param reg the register to start reading at
* @param buf the buffer to store the results
* @param buffer the buffer to store the results
* @param len the number of registers to read
* @return the value of the register
*/
void readRegs(uint8_t reg, uint8_t *buf, int len);
void readRegs(uint8_t reg, uint8_t *buffer, int len);
/**
* write to a register

View File

@ -1,23 +1,9 @@
%module javaupm_nunchuck
%include "../upm.i"
%include "../java_buffer.i"
%{
#include "nunchuck.h"
%}
%typemap(jni) (uint8_t *buffer, int len) "jbyteArray";
%typemap(jtype) (uint8_t *buffer, int len) "byte[]";
%typemap(jstype) (uint8_t *buffer, int len) "byte[]";
%typemap(javain) (uint8_t *buffer, int len) "$javainput";
%typemap(in) (uint8_t *buffer, int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buffer, int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "nunchuck.h"

View File

@ -1,25 +1,11 @@
%module javaupm_ublox6
%include "../upm.i"
%include "../java_buffer.i"
%{
#include "ublox6.h"
speed_t int_B9600 = B9600;
%}
%typemap(jni) (char *buffer, size_t len) "jbyteArray";
%typemap(jtype) (char *buffer, size_t len) "byte[]";
%typemap(jstype) (char *buffer, size_t len) "byte[]";
%typemap(javain) (char *buffer, size_t len) "$javainput";
%typemap(in) (char *buffer, size_t len) {
$1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (char *buffer, size_t len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, 0);
}
%include "ublox6.h"
speed_t int_B9600 = B9600;

View File

@ -87,7 +87,7 @@ bool Ublox6::dataAvailable()
return false;
}
int Ublox6::readData(char *buffer, size_t len)
int Ublox6::readData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -100,7 +100,7 @@ int Ublox6::readData(char *buffer, size_t len)
return rv;
}
int Ublox6::writeData(char * buffer, size_t len)
int Ublox6::writeData(char * buffer, int len)
{
if (m_ttyFd == -1)
return(-1);

View File

@ -98,7 +98,7 @@ namespace upm {
* @param len Length of the buffer
* @return the Number of bytes read
*/
int readData(char *buffer, size_t len);
int readData(char *buffer, int len);
/**
* Writes the data in the buffer to the device
@ -107,7 +107,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, size_t len);
int writeData(char *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. The default

View File

@ -6,7 +6,6 @@
#if (SWIGJAVA)
/* %include "arrays_java.i"; */
/* %apply unsigned char[] {uint8_t *mama}; */
%apply int { speed_t };
%apply int { mraa_result_t };
%apply int { mraa::Result };
@ -32,3 +31,6 @@
%}
void cleanUp();
#endif
#if (SWIGJAVA)
#endif

View File

@ -2,6 +2,7 @@
%include "../upm.i"
%include "stdint.i"
%include "typemaps.i"
%include "../java_buffer.i"
%apply uint8_t *OUTPUT { uint8_t *vol };
%apply uint8_t *OUTPUT { uint8_t *ps };

View File

@ -91,7 +91,7 @@ bool WT5001::dataAvailable(unsigned int millis)
return false;
}
int WT5001::readData(char *buffer, size_t len)
int WT5001::readData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -107,7 +107,7 @@ int WT5001::readData(char *buffer, size_t len)
return rv;
}
int WT5001::writeData(char *buffer, size_t len)
int WT5001::writeData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);

View File

@ -149,7 +149,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(char *buffer, size_t len);
int readData(char *buffer, int len);
/**
* Writes the data in the buffer to the device
@ -158,7 +158,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, size_t len);
int writeData(char *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. The default

View File

@ -3,6 +3,7 @@
%include "stdint.i"
%include "typemaps.i"
%include "arrays_java.i";
%include "../java_buffer.i";
%apply uint16_t *OUTPUT { uint16_t *id, uint16_t *score };
@ -12,22 +13,5 @@
%}
%typemap(jni) (char *buffer, size_t len) "jbyteArray";
%typemap(jtype) (char *buffer, size_t len) "byte[]";
%typemap(jstype) (char *buffer, size_t len) "byte[]";
%typemap(javain) (char *buffer, size_t len) "$javainput";
%typemap(in) (char *buffer, size_t len) {
$1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (char *buffer, size_t len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%apply (char *buffer, size_t len) { (unsigned char *pkt, int len) };
%include "zfm20.h"
speed_t int_B57600 = B57600;

View File

@ -97,7 +97,7 @@ bool ZFM20::dataAvailable(unsigned int millis)
return false;
}
int ZFM20::readData(char *buffer, size_t len)
int ZFM20::readData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -113,7 +113,7 @@ int ZFM20::readData(char *buffer, size_t len)
return rv;
}
int ZFM20::writeData(char *buffer, size_t len)
int ZFM20::writeData(char *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
@ -162,9 +162,9 @@ bool ZFM20::setupTty(speed_t baud)
return true;
}
int ZFM20::writeCmdPacket(unsigned char *pkt, int len)
int ZFM20::writeCmdPacket(uint8_t *pkt, int len)
{
unsigned char rPkt[ZFM20_MAX_PKT_LEN];
uint8_t rPkt[ZFM20_MAX_PKT_LEN];
rPkt[0] = ZFM20_START1; // header bytes
rPkt[1] = ZFM20_START2;
@ -229,7 +229,7 @@ uint32_t ZFM20::getMillis()
return elapse;
}
bool ZFM20::verifyPacket(unsigned char *pkt, int len)
bool ZFM20::verifyPacket(uint8_t *pkt, int len)
{
// verify packet header
if (pkt[0] != ZFM20_START1 || pkt[1] != ZFM20_START2)
@ -249,7 +249,7 @@ bool ZFM20::verifyPacket(unsigned char *pkt, int len)
return true;
}
bool ZFM20::getResponse(unsigned char *pkt, int len)
bool ZFM20::getResponse(uint8_t *pkt, int len)
{
char buf[ZFM20_MAX_PKT_LEN];
@ -311,7 +311,7 @@ bool ZFM20::verifyPassword()
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -335,7 +335,7 @@ int ZFM20::getNumTemplates()
// now read a response
const int rPktLen = 14;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -371,7 +371,7 @@ bool ZFM20::setNewPassword(uint32_t pwd)
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -409,7 +409,7 @@ bool ZFM20::setNewAddress(uint32_t addr)
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -443,7 +443,7 @@ uint8_t ZFM20::generateImage()
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -474,7 +474,7 @@ uint8_t ZFM20::image2Tz(int slot)
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -498,7 +498,7 @@ uint8_t ZFM20::createModel()
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -531,7 +531,7 @@ uint8_t ZFM20::storeModel(int slot, uint16_t id)
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -559,7 +559,7 @@ uint8_t ZFM20::deleteModel(uint16_t id)
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -583,7 +583,7 @@ uint8_t ZFM20::deleteDB()
// now read a response
const int rPktLen = 12;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -622,7 +622,7 @@ uint8_t ZFM20::search(int slot, uint16_t *id, uint16_t *score)
// now read a response
const int rPktLen = 16;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{
@ -655,7 +655,7 @@ uint8_t ZFM20::match(uint16_t *score)
// now read a response
const int rPktLen = 14;
unsigned char rPkt[rPktLen];
uint8_t rPkt[rPktLen];
if (!getResponse(rPkt, rPktLen))
{

View File

@ -179,7 +179,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(char *buffer, size_t len);
int readData(char *buffer, int len);
/**
* Writes the data in the buffer to the device
@ -188,7 +188,7 @@ namespace upm {
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, size_t len);
int writeData(char *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. For this device,
@ -206,7 +206,7 @@ namespace upm {
* @param len Length of packet
* @return Number of bytes written
*/
int writeCmdPacket(unsigned char *pkt, int len);
int writeCmdPacket(uint8_t *pkt, int len);
/**
* Verifies the packet header and indicates its validity
@ -215,7 +215,7 @@ namespace upm {
* @param len Length of packet
* @return True if the packet is valid, false otherwise
*/
bool verifyPacket(unsigned char *pkt, int len);
bool verifyPacket(uint8_t *pkt, int len);
/**
* Returns the number of milliseconds elapsed since initClock()
@ -253,7 +253,7 @@ namespace upm {
* large
* @return True if successful
*/
bool getResponse(unsigned char *pkt, int len);
bool getResponse(uint8_t *pkt, int len);
/**
* Verifies and authenticates to the module. The password used is