I'm sending data over astream and on the other end any number values past 9 are getting truncated, for example 11 comes across as 1.  Here is my class:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Here is how I'm using this to send data:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
The byte stuff is over my head, can anyone assist with why this may not be working?
Thanks!
			
			
			
				Class:
			
		
		
		Sub Class_Globals
    'List of char/int16 that make up the command
    Private data As List
End Sub
Public Sub Initialize(command As Char)
    data.Initialize 'Can't use Initialize2 here because then we won't be able to add new items
    data.Add(command)
End Sub
Public Sub AddNumberArgument(arg As Char)
    data.Add(arg)
End Sub
Public Sub AddStringArgument(arg As String)
    For i = 0 To arg.Length - 1
        data.Add(Asc(arg.CharAt(i)))
    Next
End Sub
Public Sub ToByteArray As Byte()
    data.InsertAt(0, data.Size) 'Add number of chars of command
    Dim byteArray(data.Size * 2) As Byte '1 char = 2 bytes
    For i = 0 To data.Size - 1
        'Split char into its two bytes
        byteArray(i * 2) = Bit.ShiftRight(Bit.And(data.Get(i), 0xFF00), 8)
        byteArray(i * 2 + 1) = Bit.And(data.Get(i), 0xFF)
    Next
    Return byteArray
End SubHere is how I'm using this to send data:
			
				B4X:
			
		
		
		Private Sub SendCursorUpdate(x As Int, y As Int) 'new code
    Dim c3 As Packet2
    c3.Initialize(3)
    c3.AddNumberArgument(x) 'example x=5
    c3.AddNumberArgument(y) 'example x=11 - but it comes across the other side as 1
    c3.AddNumberArgument(2)
    astream.Write(c3.ToByteArray)
End SubThanks!
 
				 
 
		 
 
		 
 
		 
 
		 
 
		