Android Question How to send a 0xXX byte

dmtulsa

Member
Licensed User
Longtime User
I've read so many posts I'm confused. Every answer is different in some way. I just want to send a 0xa4 and a (0xa7 & 0x00) Using Astream.write I guess I'm to used to other compilers but 0x?? is normally understood as a hex word. 16 bits, two bytes.

I'm new to B4A so please excuse me but as I said I've searched for a long time and found many ways to do this. None work as I expect. I can send o-scope image if needed. I'm really missing something.

Dim b As String
B = "0XA4"
AStream.Write(BConv.HexToBytes (b))

I've tried every byets to hex, hex to bytes ect....none actually send the correct value.

I know I've made an error so ples point me in the right direction

Thank you
 

DonManfred

Expert
Licensed User
Longtime User
A hex string usually looks like A5FFC0 and so on... 0X is not a valid HEX
Try it with
B4X:
Dim B As String = "A4"
 
Upvote 0

dmtulsa

Member
Licensed User
Longtime User
It looks like its sending the string "0xA4" not the value 0xa4 so it may be correct in a since but not what I was asking. In the attached file is a screen shot of 0xa4 from b4a as described above and one of 0xa4 sent from a terminal program. As you can see what b4a sent is incorrect and the terminal program is right.
So what I'm looking for is how to send the VALUE 0xXX not the string. I've tried byte converter but got same result. I must be doing something very wrong.
Thank you
 

Attachments

  • Scope.zip
    5.9 KB · Views: 237
Upvote 0

dmtulsa

Member
Licensed User
Longtime User
Have you seen my previous post?
Yes I have. When I send
AStream.Write(ArrayAs Byte(0xa4)) or
AStream.Write(ArrayAs Byte( 0xa7, 0x00))

I get what I sent you, The o-scope screen capture which is not an hex A4. It looks like the first byte may be a4 but the more than just one byte sent using AStream.Write(ArrayAs Byte(0xa4)). Does it append anything like a line feed or anything? I'm really confused

I've attached the code. I must be really missing something.
Thank you
 

Attachments

  • Servo.zip
    953 bytes · Views: 242
Upvote 0

dmtulsa

Member
Licensed User
Longtime User
I got it working . Still don't know why it looks so different on the scope sending the same value from two different programs.
 
Upvote 0
Top