From 080b6900f5e69fdfbfdff7408ea1060883cec590 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 31 Aug 2026 20:50:40 +0300 Subject: [PATCH] =?UTF-8?q?feat(protocan):=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D1=8C=20JNI-=D1=80=D0=B0=D0=B7=D0=B1=D0=BE=D1=80=20?= =?UTF-8?q?=D0=B8=D0=B4=D0=B5=D0=BD=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/setcorp/setcore/NativeProtoCan.kt | 1 + .../ports/android/setcore_jni.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt b/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt index 3fba9a8..5dfa233 100644 --- a/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt +++ b/c/protocan-transport/ports/android/kotlin/ru/setcorp/setcore/NativeProtoCan.kt @@ -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, diff --git a/c/protocan-transport/ports/android/setcore_jni.c b/c/protocan-transport/ports/android/setcore_jni.c index 0ae05de..d28fe9c 100644 --- a/c/protocan-transport/ports/android/setcore_jni.c +++ b/c/protocan-transport/ports/android/setcore_jni.c @@ -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)