B4X:
Private Sub GenRtu(buff() As Byte,len As Int) As Int
Dim crc,n1,retn As Int
crc=GenCRC(buff,len)
retn=0
For n1=0 To len-1
TxPkt(retn)=buff(n1)
retn=retn+1
Next
TxPkt(retn+0)=Bit.AND(Bit.ShiftRight(crc,8),0x0000ff) ' crc high
TxPkt(retn+1)=Bit.AND(crc,0xff) ' crc low
Return retn+2
End Sub
crc is int, Txpkt is a array of byte, Why Txpkt(retn+0) is 16bits not 8btes ??