Android Question int transfer to byte ?

Discussion in 'Android Questions' started by jinyistudio, Mar 31, 2015.

  1. jinyistudio

    jinyistudio Active Member Licensed User

    Code:
    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 ??
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    How is TxPkt declared?
     
  3. jinyistudio

    jinyistudio Active Member Licensed User

    Sorry !

    Private TxPkt(128) As Byte
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Bytes hold values between -128 to 127 (8 bits). They cannot hold 16 bits.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice