T TMEA New Member Apr 21, 2015 #1 Hello. I'm Thomas and I'm new user this forum. I have problem with transmision data via bluetooth. I have connect bluetooth module with MSP430 and tablet. I use : Dim Strumien As AsyncStreams Strumien.Initialize(Adapter.InputStream, Adapter.OutputStream, "Strumien") MyReceiveData=BytesToString(Buffer, 0, Buffer.Length, "UTF8") x=EditText1.Text ' adr1 device Strumien.Write(x.GetBytes("UTF8")) my msp430 have instruction if(buffer=80) then instructions} so if i write in TextEdit value 80 MSP don't work if I write in TextEdit value P (ASCIO 80) MSP430 working. I want write toTextEdit value 80 because i must sending dex values not strings. best regards
Hello. I'm Thomas and I'm new user this forum. I have problem with transmision data via bluetooth. I have connect bluetooth module with MSP430 and tablet. I use : Dim Strumien As AsyncStreams Strumien.Initialize(Adapter.InputStream, Adapter.OutputStream, "Strumien") MyReceiveData=BytesToString(Buffer, 0, Buffer.Length, "UTF8") x=EditText1.Text ' adr1 device Strumien.Write(x.GetBytes("UTF8")) my msp430 have instruction if(buffer=80) then instructions} so if i write in TextEdit value 80 MSP don't work if I write in TextEdit value P (ASCIO 80) MSP430 working. I want write toTextEdit value 80 because i must sending dex values not strings. best regards
Erel B4X founder Staff member Licensed User Longtime User Apr 21, 2015 #2 Please use [code]code here...[/code] tags when posting code. Write 80 in the EditText and then send it with: Code: Strumien.Write (Array As Byte(EditText.Text)) Upvote 0
Please use [code]code here...[/code] tags when posting code. Write 80 in the EditText and then send it with: Code: Strumien.Write (Array As Byte(EditText.Text))
Straker Active Member Licensed User Longtime User Apr 21, 2015 #3 Probably you need to send bytes Try this: Code: EditText.Text="80" dim b(1) as byte b(0)= EditText.text 'vba should convert "80" in the number 80 (aka ASCII P) 'now b(0) contains the number 80, as a single byte strumien.Write2(b,0,1) 'write a single byte I think the Erel's solution is not working. If you convert "80" in in a byte array I suppose that it will create a 2 bytes array with ascii 56 and 48 ("8" + "0") Upvote 0
Probably you need to send bytes Try this: Code: EditText.Text="80" dim b(1) as byte b(0)= EditText.text 'vba should convert "80" in the number 80 (aka ASCII P) 'now b(0) contains the number 80, as a single byte strumien.Write2(b,0,1) 'write a single byte I think the Erel's solution is not working. If you convert "80" in in a byte array I suppose that it will create a 2 bytes array with ascii 56 and 48 ("8" + "0")
Erel B4X founder Staff member Licensed User Longtime User Apr 22, 2015 #4 My solution is correct. Array As Byte(x) creates an array of bytes with a single element. As x expected to be a byte, the compiler will automatically add code that parse EditText.Text as number. Upvote 0
My solution is correct. Array As Byte(x) creates an array of bytes with a single element. As x expected to be a byte, the compiler will automatically add code that parse EditText.Text as number.
Straker Active Member Licensed User Longtime User Apr 22, 2015 #5 Thank you Erel, you are correct (as always). I didn't thought that there was an implicit conversion. Upvote 0