#include <stdlib.h>
+#include <inttypes.h>
// library header file's path
-#include "orte.h"
+#include "orte_all.h"
// pregenerated header
#include "jorte/org_ocera_orte_Subscription.h"
// enable TEST_STAGE run level
JNIEnv *env = 0;
jclass cls = 0; // local reference!
jclass cls_msg = 0;
- jobject obj = 0;
jobject rinfo = 0;
jobject obj_msg;
+ jobject obj_bo = 0;
+ jfieldID fid = 0;
jmethodID mid = 0;
jmethodID mid_callback = 0;
//
}
jvm = callback_cont->jvm;
// get env
- (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
+ (*jvm)->AttachCurrentThread(jvm,
+ #ifdef __ANDROID__
+ &env,
+ #else
+ (void **)&env,
+ #endif
+ NULL);
if(env == 0)
{
#ifdef TEST_STAGE
break;
}
//
+ // set byte order only if it differs from that currently set
+ if(info->data_endian != callback_cont->cur_endian) {
+ //prepare ByteOrder
+ cls = (*env)->FindClass(env, "java/nio/ByteOrder");
+ if (cls == 0) {
+ #ifdef TEST_STAGE
+ printf(":!c: cls = NULL \n");
+ #endif
+ }
+ if(info->data_endian == BigEndian) {
+ fid = (*env)->GetStaticFieldID(env,
+ cls,
+ "BIG_ENDIAN",
+ "Ljava/nio/ByteOrder;");
+ callback_cont->cur_endian = BigEndian;
+ }
+ else {
+ fid = (*env)->GetStaticFieldID(env,
+ cls,
+ "LITTLE_ENDIAN",
+ "Ljava/nio/ByteOrder;");
+ callback_cont->cur_endian = LittleEndian;
+ }
+ if(fid == 0) {
+ #ifdef TEST_STAGE
+ printf(":!c: fid = NULL \n");
+ #endif
+ }
+ obj_bo = (*env)->GetStaticObjectField(env, cls, fid);
+ if(obj_bo == 0) {
+ #ifdef TEST_STAGE
+ printf(":!c: cls = NULL \n");
+ #endif
+ }
+
+ // set byte order to ByteBuffer
+ // get BB class
+ cls = (*env)->GetObjectClass(env, callback_cont->obj_buf);
+ if(cls == 0)
+ {
+ #ifdef TEST_STAGE
+ printf(":!c: cls = NULL \n");
+ #endif
+ }
+ // get methodID - order(ByteOrder)
+ mid = (*env)->GetMethodID(env,
+ cls,
+ "order",
+ "(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;");
+ if(mid == 0)
+ {
+ #ifdef TEST_STAGE
+ printf(":!c: mid = NULL \n");
+ #endif
+ }
+
+ // set ByteOrder
+ if((*env)->CallObjectMethod(env,callback_cont->obj_buf,mid,obj_bo) == 0)
+ {
+ #ifdef TEST_STAGE
+ printf(":!c: set byte order failed.. \n");
+ #endif
+ }
+ }
+ //
if(callback_cont->obj == 0)
{
#ifdef TEST_STAGE
break;
}
// set local vars
- obj = callback_cont->obj;
rinfo = callback_cont->rinfo;
obj_msg = callback_cont->msg;
#ifdef TEST_STAGE
printf(":c: #0 \n");
- printf(":c: env = %p, obj_msg = %p \n", env, obj_msg);
+ printf(":c: env = %#"PRIxPTR", obj_msg = %#"PRIxPTR" \n", (intptr_t)env, (intptr_t)obj_msg);
#endif
#ifdef TEST_STAGE
printf(":c: rinfo created :] \n");
printf(":c:----- ORTERecvInfo members ------ \n");
- printf(":c: recvStatus: %d \n", info->status);
- printf(":c: senderGuid: hid = %d, aid = %d, oid = %d \n",
+ printf(":c: recvStatus: %#x \n", info->status);
+ printf(":c: senderGuid: hid = %#"PRIx32", aid = %#"PRIx32", oid = %#"PRIx32" \n",
info->senderGUID.hid,info->senderGUID.aid,info->senderGUID.oid);
printf(":c: topic: %s \n",info->topic);
printf(":c: type: %s \n",info->type);
- printf(":c: localTimeRecv: sec = %d, fract = %d \n",
+ printf(":c: localTimeRecv: sec = %"PRId32", fract = %"PRIu32" \n",
info->localTimeReceived.seconds,info->localTimeReceived.fraction);
- printf(":c: remoteTimePub: sec = %d, fract = %d \n",
+ printf(":c: remoteTimePub: sec = %"PRId32", fract = %"PRIu32" \n",
info->remoteTimePublished.seconds,info->remoteTimePublished.fraction);
- printf(":c: seqNr: high = %d, low = %d \n",info->sn.high,info->sn.low);
+ printf(":c: seqNr: high = %"PRId32", low = %"PRIu32" \n",info->sn.high,info->sn.low);
printf(":c:---------------------------------- \n");
#endif
////////////////////////////////////////////////////
jstring jtopic, // subs topic
jstring jtname, // subs typeName
jobject jinstance, // direct ByteBuffer
+ jint jbyteOrder,// byte order of ByteBuffer
jobject obj_msg, // messageData instance
jobject jdeadline,
jobject jminSeparation,
#endif
}
callback_cont->jvm = jvm;
+ callback_cont->cur_endian = (CDR_Endianness) jbyteOrder;
// create global references
callback_cont->obj = (*env)->NewGlobalRef(env, obj_callback);
//
break;
}
// create global references
+ callback_cont->obj_buf = (*env)->NewGlobalRef(env, jinstance);
+ //
+ if (callback_cont->obj_buf == 0)
+ {
+ #ifdef TEST_STAGE
+ printf(":c: global reference not created! \n");
+ #endif
+ break;
+ }
+ // create global references
callback_cont->msg = (*env)->NewGlobalRef(env, obj_msg);
//
if (callback_cont->msg == 0)