Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: piscis on November 06, 2013, 11:00:06 AM
-
I'm using a Do-More H2-DM1E and will like to know how to open a TCP connection, receive the expected data and close the connection once done.
I will like to be able to received a four digit number and store it in an empty PLC variable.
For testing purposes I will be using this Android App:
https://play.google.com/store/apps/details?id=com.aviramido.udpserver
I will appreciate if anyone is able to help.
-
Check the DoMore example program section on this forum. There is an example web server I posted there. If you want the DoMore to be the client, then let me know, and I will try to post a sample for you.
-
If the Do-more is the one initiating the connection:
1. Create a TCP Client device.
2. Use OPENTCP instruction to open TCP connection to your partner.
3. Use STREAMOUT to send data; use STREAMIN to get data.
4. Use CLOSE to close the TCP Client device (which will close the TCP connection).
If the Do-more is the one receiving the connection:
1. Create TCP Server device.
2. Use TCPLISTEN instruction to listen and respond to the partner's TCP connection request.
3. Use STREAMIN to receive data; use STREAMOUT to send data.
4. If the Do-more is to terminate the connection, then, again, use CLOSE. If the partner is going to close the connection, then there is nothing to do except go back up and use TCPLISTEN for the next time he wants to connect.
Use the Help file for these instructions to understand their use and their parameters.
-
plcnut:
The answer is YES the Android App will always be the one initiating the communication. The Do-More will just sit still and wait for the App to send a 4 digits value like for example(3499) once this is received and store into a variable the connection can be closed.
This connection section will repeat approximately once every two minutes with the 4 digits value constantly changing.
I will appreciated if you could provide me with an example program including the suggested port number to use?
Do-More PLC IP Address: 192.168.10.75
Android Tablet IP Address: 192.168.10.33
Router IP Address: 192.168.10.1
-
plcnut:
Were you able to work on the example you mentioned?
-
No I have not. I am happy to help but am covered up right now.
There is also another TCP sample located here: http://forum.hosteng.com/index.php/board,20.0.html
Look them over and do some experimenting. You might surprise yourself with what you can learn :)
I will post another sample for you when I get a chance...
-
Were you able to work on the example you mentioned?
Plcnut is just another user like yourself. He took the time to study the instruction set and developed the webserver posted in the examples section. I suggest you get that code and look over it. Between that example and the information Greg posted to this thread, you should have everything you need to develop it yourself. It is quite simple.
Generally, folks around here are very willing to help others that are willing to help themselves, but they probably won't do it for you.