Communication with a device with ASCII commands / TCP/IP

CT74540

New Member
Licensed User
Longtime User
Hello,
I have a network with a dataconcentrator (slave) and a PC or Android tablet(master).
The master send an ASCII string to the slave $RVA[CR] in this case.
The slave answers then an ASCII string value1[TAB]value2[TAB]....[CR][LF]
then the string is divided to display the values.
in VB6: I use winsock1.senddata( "$RVA" & Chr$(13)) for asking and a sub
private sub winsock1_data-arrival for receiving loop.
I tested in b4a:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Socket1 As Socket
Dim timer1 As Timer
Dim outputstring As String
Dim inputstring As String
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
Socket1.Initialize("Socket1")
Socket1.Connect( "192.168.1.3",500,2000)'address of the device i want to be connected with
outputstring="$RVA" & Chr(13)'string for asking an answer the device
timer1.Initialize("timer1",1000)
timer1.Enabled=True

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub timer1_tick
Socket1.OutputStream(outputstring)'like winsock 1.write in VB
Socket1.InputStream(inputstring)'i want to become the answer string from device
EditText1.Text=inputstring'i display the string
End Sub

but it doesn't work: please, has somebody an idea?
regards
 
Top