D dmtulsa Member Licensed User Longtime User Dec 10, 2012 #1 Well I've read and read but I can't figure out how to send a word (short int). If I enter 3456 in an editText and want to sent that value to a PIC mcu as a word (16bits) how do I send it? wrdData(1) = txtCycleSpeed.Text.GetBytes() ' Missing parameter wrdData(2) = txtrelayspeed.Text.GetBytes(UTF8) 'Undeclared variable 'utf8' AStream.Write(txtCycleSpeed.Text.GetBytes("UTF8")) 'sends a string AStream.Write(txtCycleSpeed.Text 'Cannot cast type: {Type=String,Rank=0} to: {Type=Byte,Rank=1}. I'm having a lot of trouble sending stuff between a PIC and android. Any tips? Thank you Doug
Well I've read and read but I can't figure out how to send a word (short int). If I enter 3456 in an editText and want to sent that value to a PIC mcu as a word (16bits) how do I send it? wrdData(1) = txtCycleSpeed.Text.GetBytes() ' Missing parameter wrdData(2) = txtrelayspeed.Text.GetBytes(UTF8) 'Undeclared variable 'utf8' AStream.Write(txtCycleSpeed.Text.GetBytes("UTF8")) 'sends a string AStream.Write(txtCycleSpeed.Text 'Cannot cast type: {Type=String,Rank=0} to: {Type=Byte,Rank=1}. I'm having a lot of trouble sending stuff between a PIC and android. Any tips? Thank you Doug
Erel B4X founder Staff member Licensed User Longtime User Dec 11, 2012 #2 Code: Copy Dim bc As ByteConverter Dim i As Short = txtCycleSpeed.Text 'convert the string to short Dim bytes() As Byte = bc.ShortsToBytes(Array As Short(i)) AStream.Write(bytes) Upvote 0
Code: Copy Dim bc As ByteConverter Dim i As Short = txtCycleSpeed.Text 'convert the string to short Dim bytes() As Byte = bc.ShortsToBytes(Array As Short(i)) AStream.Write(bytes)
D dmtulsa Member Licensed User Longtime User Dec 11, 2012 #3 Thank you very much Erel. I'm still learning all the functions B4A has. Doug Upvote 0