Android Question Receiving Bytes of data between 0 and 255

Danki_87

New Member
Licensed User
Longtime User
Hi everyone!

I'm having some problems receiving bytes of data over bluetooth.
The project I'm trying to make is a bluetooth oscilloscope. I have a microcontroller that samples the signal, and then it sends it as a single byte to my android device using a TTL to bluetooth adapter. Then I want to display the signal on the screen.

I'm sucked now in the communications. The android device receives the data as a character, then I tried to use the ByteConverter library to interpret the character:

Dim bc As ByteConverter
Dim Data(1) As Char
Dim Number(1) As Byte

Data(0) = TextReader1.ReadLine
Number = bc.CharsToBytes(Data)

When I receive a number between 0 and 127, this code works just fine. However, when I receive a larger number it just returns -3.

I'd appreciate any help in other ways to change from chars to bytes.
 
Last edited:

Danki_87

New Member
Licensed User
Longtime User
Thanks, It's good to know I'm on the right way. I supose I can sacrifice a little bit of resolution and work with data from 0 to 127.

However, Is there any other way to obtain the numerical information of a character sent oover the serial port? (other than using the byte converter library)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Maybe I am not following.. but as far as I understand from what you wrote I was expecting to define the data array as string, not char.. or even just use one string variable to hold the incoming data. this way you end up with a string-represented byte, 7F for example.. then convert this value to a true Hex byte.
 
Upvote 0
Top