Bluethoot string

ilmancio

New Member
Licensed User
Longtime User
Hallo

I am sending a bluetooth string to a device (Lego NXT) using ByteToString, for example:
Dim text As String
Dim Byt(10) As Byte
Dim conv As ByteConverter
Byt(0)=6
Byt(1)=0
Byt(2)=0
Byt(3)=3
Byt(4)=232
Byt(5)=3
Byt(6)=244
Byt(7)=1
Byt(8)=0
text = BytesToString(Byt,0,9,"ISO-8859-1")

Looking at the string with hexa reader (after sent to file) it seems that the Byt(4) and Byt(6) are written in the string with two Byte instead of one (for example 232 should be E8 but I find C3 and A8).

It is strange (for me) that if I check for the "text" string lenght the results is 9 but the string sent via bluetooth or to a file is 11 byte long.

I read some post with similar issue, but I did not find a solution that works for me. May be that this is for my small experience but I can't find a solution :BangHead: (I tried also with chr() function but the result is the same).

Thank you
 

ilmancio

New Member
Licensed User
Longtime User
Hallo

Because I am using the following code to send the command

Dim Serial1 As Serial
...
TextWriter1.Initialize(Serial1.OutputStream)
...
TextWriter1.WriteLine(text)
TextWriter1.Flush

taken from examples/tutorial. This works well for other commands (Byt values less than 127).

Which may be the alternative?

Thank you
 

ilmancio

New Member
Licensed User
Longtime User
In the example I put here no, but for some other commands that can have parts with not predefined lenght (for example if I have to send a file name) the specifications requires a Null terminator at the end.
 
Top