feat(protocan): добавь JNI-разбор идентификатора
This commit is contained in:
@@ -18,6 +18,7 @@ object NativeProtoCan {
|
||||
messageType: Int,
|
||||
body: Int,
|
||||
): Long
|
||||
external fun nativeUnpackId(raw: Long): IntArray?
|
||||
external fun nativeCrc16(input: ByteArray): Int
|
||||
external fun nativeEncodeFrame(
|
||||
sequence: Int,
|
||||
|
||||
@@ -32,6 +32,24 @@ Java_ru_setcorp_setcore_NativeProtoCan_nativePackId(
|
||||
(uint8_t)message_type, (uint16_t)body);
|
||||
}
|
||||
|
||||
JNIEXPORT jintArray JNICALL
|
||||
Java_ru_setcorp_setcore_NativeProtoCan_nativeUnpackId(
|
||||
JNIEnv *env, jobject self, jlong raw)
|
||||
{
|
||||
(void)self;
|
||||
uint8_t priority, route, device_type, device_id, message_type;
|
||||
uint16_t body;
|
||||
pcan_abi_id_unpack((uint32_t)raw, &priority, &route, &device_type,
|
||||
&device_id, &message_type, &body);
|
||||
jint values[6] = { (jint)priority, (jint)route, (jint)device_type,
|
||||
(jint)device_id, (jint)message_type, (jint)body };
|
||||
jintArray result = (*env)->NewIntArray(env, 6);
|
||||
if (result != NULL) {
|
||||
(*env)->SetIntArrayRegion(env, result, 0, 6, values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_ru_setcorp_setcore_NativeProtoCan_nativeCrc16(
|
||||
JNIEnv *env, jobject self, jbyteArray input)
|
||||
|
||||
Reference in New Issue
Block a user