saunwin Active Member Licensed User Longtime User Dec 16, 2011 #1 Hi All, :sign0104: I have a seekbar, which needs to send it's value over bluetooth. I'm paired up and using the serial tutorial I think I'm nearly there. But the serial tutorial sends text both ways, I just need to send a hex byte (seekbar.Value in Hexdecimal)) from tablet to PC. Can anyone point me in the right direction ? Thanks in advance Steve
Hi All, :sign0104: I have a seekbar, which needs to send it's value over bluetooth. I'm paired up and using the serial tutorial I think I'm nearly there. But the serial tutorial sends text both ways, I just need to send a hex byte (seekbar.Value in Hexdecimal)) from tablet to PC. Can anyone point me in the right direction ? Thanks in advance Steve
Erel B4X founder Staff member Licensed User Longtime User Dec 17, 2011 #2 Instead of using TextWriter you should use OutputStream.WriteBytes: Basic4android - Files (Core) Code: Dim buffer(1) as Byte Buffer(0) = 123 'The value out.WriteBytes(Buffer, 0, 1) Upvote 0
Instead of using TextWriter you should use OutputStream.WriteBytes: Basic4android - Files (Core) Code: Dim buffer(1) as Byte Buffer(0) = 123 'The value out.WriteBytes(Buffer, 0, 1)
saunwin Active Member Licensed User Longtime User Dec 17, 2011 #3 That's the help I needed Thanks Erel, :sign0104: Upvote 0
D DrWave Member Licensed User Longtime User Mar 9, 2012 #4 how does this work? I found this post thinking this would be exactly what I needed but I cannot get it to work : Like the text example I use serial1 as the connection So if I initialize textwriter with TextWriter1.Initialize(Serial1.OutputStream) then writing text is easy with TextWriter1.WriteLine(txtSend.Text&CRLF) but to send bytes ... serial1.outputstream.writebytes(Buf,0,1) does not compile with unknown element error. What am I missing ? Upvote 0
how does this work? I found this post thinking this would be exactly what I needed but I cannot get it to work : Like the text example I use serial1 as the connection So if I initialize textwriter with TextWriter1.Initialize(Serial1.OutputStream) then writing text is easy with TextWriter1.WriteLine(txtSend.Text&CRLF) but to send bytes ... serial1.outputstream.writebytes(Buf,0,1) does not compile with unknown element error. What am I missing ?
Erel B4X founder Staff member Licensed User Longtime User Mar 9, 2012 #5 Serial.OutputStream returns the native Outputstream object. You can see that the autocomplete doesn't recognize it. You should write: Code: Dim out As OutputStream out = Serial1.OutputStream out.WriteBytes(...) Upvote 0
Serial.OutputStream returns the native Outputstream object. You can see that the autocomplete doesn't recognize it. You should write: Code: Dim out As OutputStream out = Serial1.OutputStream out.WriteBytes(...)
Erel B4X founder Staff member Licensed User Longtime User Oct 18, 2012 #6 It is better to start a new thread for this question. I recommend you to use AsyncStreams (see the tutorial). Upvote 0
It is better to start a new thread for this question. I recommend you to use AsyncStreams (see the tutorial).
Beja Expert Licensed User Longtime User Apr 23, 2013 #7 Code: Dim buffer(1) as ByteBuffer(0) = 123 'The valueout.WriteBytes(Buffer, 0, 1) Hi Erel. is the decimal value "123" above converted to byte on the fly? if so that means one should first convert his hex vlues to decimal. Upvote 0
Code: Dim buffer(1) as ByteBuffer(0) = 123 'The valueout.WriteBytes(Buffer, 0, 1) Hi Erel. is the decimal value "123" above converted to byte on the fly? if so that means one should first convert his hex vlues to decimal.
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2013 #8 Your code is not valid. You probably meant: Code: Dim buffer() As Byte = Array As Byte(123) 'creates an array of bytes with one byte. The byte decimal value is 123. Upvote 0
Your code is not valid. You probably meant: Code: Dim buffer() As Byte = Array As Byte(123) 'creates an array of bytes with one byte. The byte decimal value is 123.
Beja Expert Licensed User Longtime User Jun 15, 2013 #9 Hi Erel, Code: Dim buffer() As Byte = Array As Byte(123) 'creates an array of bytes with one byte. The byte decimal value is 123. It will be very difficult to use decimal to represent hex.. it will need high level of imagination or additional conversion code. Is it possible to do something like: Code: Dim buffer() As Byte = Array As Byte(7F, 2D, D3, 01) 'INSTEAD OF THE ABOVE CODE? Thanks Upvote 0
Hi Erel, Code: Dim buffer() As Byte = Array As Byte(123) 'creates an array of bytes with one byte. The byte decimal value is 123. It will be very difficult to use decimal to represent hex.. it will need high level of imagination or additional conversion code. Is it possible to do something like: Code: Dim buffer() As Byte = Array As Byte(7F, 2D, D3, 01) 'INSTEAD OF THE ABOVE CODE? Thanks
Erel B4X founder Staff member Licensed User Longtime User Jun 15, 2013 #10 Yes: Code: Dim buffer() As Byte = Array As Byte(0x7F, 0x2D, 0xD3, 0x01) Upvote 0