feat(protocan): добавь JNI-разбор идентификатора

This commit is contained in:
2026-08-31 20:50:40 +03:00
parent 68040a2803
commit 080b6900f5
2 changed files with 19 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ object NativeProtoCan {
messageType: Int, messageType: Int,
body: Int, body: Int,
): Long ): Long
external fun nativeUnpackId(raw: Long): IntArray?
external fun nativeCrc16(input: ByteArray): Int external fun nativeCrc16(input: ByteArray): Int
external fun nativeEncodeFrame( external fun nativeEncodeFrame(
sequence: Int, sequence: Int,

View File

@@ -32,6 +32,24 @@ Java_ru_setcorp_setcore_NativeProtoCan_nativePackId(
(uint8_t)message_type, (uint16_t)body); (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 JNIEXPORT jint JNICALL
Java_ru_setcorp_setcore_NativeProtoCan_nativeCrc16( Java_ru_setcorp_setcore_NativeProtoCan_nativeCrc16(
JNIEnv *env, jobject self, jbyteArray input) JNIEnv *env, jobject self, jbyteArray input)