I am developing a small communications protocol over bluetooth for an arduino to transfer data to Android. Part of the protocol sends a header that contains a line count. I have successfully read the MSB and LSB of the count and must now re-assemble that from the Int to a Short value. My declarations follow:
var iLineCountMSB: Int = 0
var iLineCountLSB: Int = 0
var sLineCountMSB: Short = 0
var sLineCount: Short = 0
I have already read the MSB and LSB from the bluetooth socket. Please note that the values are in Int, not Byte. My attempt to re-assemble the two Ints to a Short is as follows:
sLineCount = iLineCountMSB.toShort() shl 8 + iLineCountLSB.toShort()
I also copied the MSB Int value to a Short (sLineCountMSB):
sLineCountMSB = iLineCountMSB.toShort()
sLineCount = sLineCountMSB shl 8
I continue to get the same error:
-- results in:: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public inline infix fun BigInteger.shl(n: Int): BigInteger defined in kotlin
The Kotlin documentation defines the function as:
infix fun shl(bitCount: Int): Long
Am I wrong? Does this specifiy that 'Long' is the returned type? The only 'shl' that I seem to get to compile successfully is Int = Int shl 8.