Hi,
I am sending a ASCII string to a device however it's not sending correctly.
The message I am sending is 06as0066\n\r
When sending this message the bytes of the message should look like:
48 54 97 115 48 48 54 54 13 10
However when I send the message the bytes of the message is looking like this:
48 54 97 115 48 48 54 54 92 110 92 114
The code I am using is as follows..
I was told the Unicode to UTF-8 is translating CR and LF each into 2 byte sequences, so I then played around with GetBytes and changed it to:
msg.GetBytes("ASCII")
But still had the same issue.
I then changed the msg to:
Now it seems to log the bytes of the message as:
48 54 97 115 48 48 54 54 13 10
This is what it should log it as.
However for some reason it is splitting the first digit of the message that is being sent.
I have been told it's something to do with my end as it seems to work with Telnet and another program (this other program wasn't written by me and the source code is not available for this other program).
The software engineer is pretty certain it's the way I am sending it and it's not at the receiving end.
Any ideas what could be wrong ?
I like to be able to send the message as msg = "06as0066\n\r" without having to use Chr(13) & Chr(10).
I am sending a ASCII string to a device however it's not sending correctly.
The message I am sending is 06as0066\n\r
When sending this message the bytes of the message should look like:
48 54 97 115 48 48 54 54 13 10
However when I send the message the bytes of the message is looking like this:
48 54 97 115 48 48 54 54 92 110 92 114
The code I am using is as follows..
B4X:
msg = "06as0066\n\r"
Dim msg1 As String
Dim msg2() As Byte = msg.GetBytes("UTF-8")
For i = 0 To msg2.Length - 1
msg1 = msg1 & " " & msg2(i)
Next
Log("Bytes:" & msg1)
astream.Write(msg.GetBytes("UTF-8"))
I was told the Unicode to UTF-8 is translating CR and LF each into 2 byte sequences, so I then played around with GetBytes and changed it to:
msg.GetBytes("ASCII")
But still had the same issue.
I then changed the msg to:
B4X:
msg = "06as0066" & Chr(13) & Chr(10)
Now it seems to log the bytes of the message as:
48 54 97 115 48 48 54 54 13 10
This is what it should log it as.
However for some reason it is splitting the first digit of the message that is being sent.
I have been told it's something to do with my end as it seems to work with Telnet and another program (this other program wasn't written by me and the source code is not available for this other program).
The software engineer is pretty certain it's the way I am sending it and it's not at the receiving end.
Any ideas what could be wrong ?
I like to be able to send the message as msg = "06as0066\n\r" without having to use Chr(13) & Chr(10).