java: fix Java types for ZFM20

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Petre Eftime 2015-09-01 14:45:46 +03:00 committed by Mihai Tudor Panu
parent 3d74ea9820
commit ebdb4f10d1
3 changed files with 22 additions and 7 deletions

View File

@ -4,16 +4,30 @@
%include "typemaps.i"
%include "arrays_java.i";
%apply unsigned char[] { unsigned char *pkt };
%apply signed char[] { char *buffer };
%apply uint16_t *OUTPUT { uint16_t *id, uint16_t *score };
%{
#include "zfm20.h"
speed_t int_B57600 = B57600;
%}
%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

@ -229,7 +229,7 @@ uint32_t ZFM20::getMillis()
return elapse;
}
bool ZFM20::verifyPacket(unsigned char *pkt)
bool ZFM20::verifyPacket(unsigned char *pkt, int len)
{
// verify packet header
if (pkt[0] != ZFM20_START1 || pkt[1] != ZFM20_START2)
@ -291,7 +291,7 @@ bool ZFM20::getResponse(unsigned char *pkt, int len)
}
// now verify it.
return verifyPacket(pkt);
return verifyPacket(pkt, len);
}
bool ZFM20::verifyPassword()

View File

@ -212,9 +212,10 @@ namespace upm {
* Verifies the packet header and indicates its validity
*
* @param pkt Packet to check
* @param len Length of packet
* @return True if the checksum is valid, false otherwise
*/
bool verifyPacket(unsigned char *pkt);
bool verifyPacket(unsigned char *pkt, int len);
/**
* Returns the number of milliseconds elapsed since initClock()