more support for ubytearrays
This commit is contained in:
1 parent
b5db8bb8cc
commit
30bf5fefe9
7 files changed
+42
-3
No files matched your search
@@ -27,6 +27,9 @@ interface CRC<T> {
|
||||
fun crc8(data: ByteArray, polynomial: UByte = 0xA7.toUByte()): UByte =
|
||||
CRC8(polynomial).also { it.update(data) }.value
|
||||
|
||||
fun crc8(data: UByteArray, polynomial: UByte = 0xA7.toUByte()): UByte =
|
||||
CRC8(polynomial).also { it.update(data) }.value
|
||||
|
||||
/**
|
||||
* Calculate CRC16 for a data array using a given polynomial (CRC16-CCITT polynomial (0x1021) by default)
|
||||
*/
|
||||
@@ -45,6 +48,7 @@ infix fun UShort.shl(bitCount: Int): UShort = (this.toUInt() shl bitCount).toUSh
|
||||
infix fun UShort.shr(bitCount: Int): UShort = (this.toUInt() shr bitCount).toUShort()
|
||||
|
||||
infix fun UByte.shl(bitCount: Int): UByte = (this.toUInt() shl bitCount).toUByte()
|
||||
@Suppress("unused")
|
||||
infix fun UByte.shr(bitCount: Int): UByte = (this.toUInt() shr bitCount).toUByte()
|
||||
|
||||
fun UByte.toBigEndianUShort(): UShort = this.toUShort() shl 8
|
||||
|
||||
Reference in new issue
Block a user