support for serialized frames
This commit is contained in:
1 parent
63b231975b
commit
be03163a96
11 files changed
+274
-14
No files matched your search
@@ -21,6 +21,16 @@ fun intToBytes(value: Int): ByteArray {
|
||||
return result
|
||||
}
|
||||
|
||||
fun uintToBytes(value: UInt): ByteArray {
|
||||
var l = value
|
||||
val result = ByteArray(4)
|
||||
for (i in 3 downTo 0) {
|
||||
result[i] = (l and 0xFFu).toByte()
|
||||
l = l shr 8
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 8 bytes to LE long
|
||||
*/
|
||||
@@ -42,6 +52,15 @@ fun bytesToInt(b: ByteArray): Int {
|
||||
return result
|
||||
}
|
||||
|
||||
fun bytesToUInt(b: ByteArray): UInt {
|
||||
var result = 0u
|
||||
for (i in 0 until 4) {
|
||||
result = result shl 8
|
||||
result = result or (b[i].toUInt() and 0xFFu)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
private val hexDigits = "0123456789ABCDEF"
|
||||
|
||||
|
||||
Reference in new issue
Block a user