File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -61,10 +61,10 @@ class ModbusReadCoilStatusResponse: ModbusPacket {
61
61
}
62
62
println (" min $minIndex max $maxIndex " )
63
63
val numberOfBytes = ((maxIndex.toInt() - minIndex.toInt() + 1 )/ 8 ) + extraByte((maxIndex.toInt() - minIndex.toInt() + 1 ))
64
- val length = max(numberOfBytes, 1 ).toByte ()
64
+ val length = max(numberOfBytes, 1 ).toUByte ()
65
65
println (" modbus length $length " )
66
- byteVector = ByteArray (LEN_BYTES_METADATA_SIZE + length )
67
- byteVector[0 ] = length
66
+ byteVector = ByteArray (LEN_BYTES_METADATA_SIZE + length.toInt() )
67
+ byteVector[0 ] = length.toByte()
68
68
for (element in listIndexToCoilValue){
69
69
if (element.second) {
70
70
println (" byte index ${((element.first - minIndex)/ 8 )+ 1 } bit index ${(element.first - minIndex) % 8 } " )
Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ class ModbusReadHoldingRegisterResponse: ModbusPacket{
39
39
}
40
40
41
41
val numberOfBytes = (maxIndex.toInt() - minIndex.toInt() + 1 ) * 2
42
- val length = max(numberOfBytes, 1 ).toByte ()
42
+ val length = max(numberOfBytes, 1 ).toUByte ()
43
43
println (" modbus length $length " )
44
- byteVector = ByteArray (LEN_BYTES_METADATA_SIZE + length )
45
- byteVector[0 ] = length
44
+ byteVector = ByteArray (LEN_BYTES_METADATA_SIZE + length.toInt() )
45
+ byteVector[0 ] = length.toByte()
46
46
var i = 1
47
47
for (element in listIndexToRegisterValue){
48
48
println (" byte[${i} ]=${DataConverter .toBytes(element.second)[1 ]} " )
You can’t perform that action at this time.
0 commit comments