iOS Question Sending commands via asyncstreams to a ip2sl/RS232 interface ...

MarkInAZ

Member
Licensed User
Longtime User
Hello,

I am trying to send commands to an RS232 device from iTach, a WiFi Model: ip2sl. I have connected with their test application, iTest, that allows for sending text to the ip2sl with commands like; *Z6ON, *Z6OFF and *Z6STATUS?. These commands will turn on/off an audio device that is connected to the ip2sl/RS232 interface.

I have downloaded and modified the b4x-network-asyncstreams-b4xserializator example. I have setup the astream.Initialize for non prefix and can see commands coming from the audio system, when commands are sent for the keypads connected to the audio system. So I have a connection on my iphone to the RS232 connected to the audio system.

My issue is with sending the commands to the ip2sl. I am not sure that I have this correctly coded for sending "text" or a string to the ip2sl.

I thought that the code below would do this:

B4X:
    Dim conv As ByteConverter
    Dim data() As Byte = conv.StringToBytes(edtName.Text, "UTF8")

edtName.Text contains the text; *Z6STATUS?\r

I never see any responses from the ip2sl/RS232 device in my B4i app, so something is not being sent correctly. I have also tried different text and code for also including a carriage return after the commend, which is required.

Is this the correct code to send a string/text to the ip2sl/RS232 interface?

Your help with this is greatly appreciated.

Thanks, Mark
 

Attachments

  • TCP_Network.b4i.zip
    5.5 KB · Views: 190

hatzisn

Expert
Licensed User
Longtime User
Have you tried removing \r and inserting after edtName.text + chr(13)?
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Remove \r inserted in the editbox and change the code into this:

B4X:
Dim conv As ByteConverter
Dim data() As Byte = conv.StringToBytes(edtName.Text & chr(13), "UTF8")

It may work...
 
Upvote 0

MarkInAZ

Member
Licensed User
Longtime User
Hello,

Spot on !! I forget that Unix cr, \r, is not a good idea to use in B4i.

B4X:
Dim data() As Byte = conv.StringToBytes(edtName.Text & chr(13), "UTF8")

Adding & chr(13), worked perfect, thank you so very much.
-- mark
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…