Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: ATU on January 27, 2018, 09:48:59 AM

Title: TCP Protocol
Post by: ATU on January 27, 2018, 09:48:59 AM
Working on a project to create a custom TCP protocol to receive data from a device. Looking at the custom protocol functions. I think I get the OPENTCP function. This is where the BRX is a TCP Server?  It asks for a connection to a Client, establishes the connection  and then you would call StreamIN or Out? Is that correct?  The TCPListen is where I am a little confused. BRX is the CLIENT?  You listen for a connection and then jump to a code block. What happens next?  You check the heap for data in the queue, but where is the Queue? Do you use Streamin?   Still trying to figure out the communicating device, it has multiple ways to set it up. Do you have any complete examples other than what is in the help?
Title: Re: TCP Protocol
Post by: plcnut on January 27, 2018, 10:23:45 AM
Working on a project to create a custom TCP protocol to receive data from a device. Looking at the custom protocol functions. I think I get the OPENTCP function. This is where the BRX is a TCP Server? 
This is where the BRX is the Client, and is opening a connection to a server.
Quote
It asks for a connection to a Client, establishes the connection  and then you would call StreamIN or Out? Is that correct?
Yes, except the BRX is the Client, and it is talking to a Server.
Quote
  The TCPListen is where I am a little confused. BRX is the CLIENT? 
This TCPLISTEN is for the the BRX to be a Server. The BRX sits and listens on the specified port waiting for a Client to call so that it can Serve the requested information.
Quote
You listen for a connection and then jump to a code block. What happens next?  You check the heap for data in the queue, but where is the Queue? Do you use Streamin?   Still trying to figure out the communicating device, it has multiple ways to set it up. Do you have any complete examples other than what is in the help?
There is a full webserver example in the Examples (http://forum.hosteng.com/index.php/board,20.0.html) section of the forum, and there is also a client example that BobO wrote over there as well. There is another example posted HERE (http://forum.hosteng.com/index.php/topic,993.msg18641.html#msg18641) as well.
Title: Re: TCP Protocol
Post by: plcnut on January 27, 2018, 10:24:54 AM
What is the device that you are trying to talk to? Do you have a link to the specs?
Title: Re: TCP Protocol
Post by: ATU on January 27, 2018, 10:58:23 AM
Its German, an Otto inspection module. I am requesting more information.  Thanks for your help.
Title: Re: TCP Protocol
Post by: BobO on January 27, 2018, 11:09:32 AM
Just reiterating what plcnut already said but:
   TCPClient is a master and initiates the connection through OPENTCP.
   TCPServer is a slave and waits for a connection from a client device by listening through TCPLISTEN.

For both client and server, once the connection exists, you use STREAMIN to read data the other side has sent and STREAMOUT to send data to the other side.

I would expect that your device is a server and the PLC would be the client, but that could easily be the other way.
Title: Re: TCP Protocol
Post by: ATU on January 27, 2018, 12:02:22 PM
Here is a wire shark file capture, IP 105 is the device.  It constantly puts this out. Can you tell what it is doing? IP 75 is my laptop. Nothing else was connected.
Title: Re: TCP Protocol
Post by: BobO on January 27, 2018, 12:06:00 PM
NetBIOS. I think it is trying to convert TS.ESET.COM to an IP address.
Title: Re: TCP Protocol
Post by: BobO on January 27, 2018, 12:09:25 PM
Which actually suggests that it might be trying to establish a connection to something. That isn't really typical for devices, but I know nothing about the device you are trying to talk to.
Title: Re: TCP Protocol
Post by: ATU on January 27, 2018, 01:19:24 PM
Its PC based, so there might be something running in the background. Only had a few hours with it. Hopefully, I will get more information next week from the company. The interface for setting up the TCP link is very confusing, probably because the developers were not native English speakers. They have multiple port settings for different functions that have similar names.Lots of check boxes. Other developers were able to get a Raspberry Pi to communicate with it.With the flexibility in the BRX and a little help, I should be able to get this to work.
Title: Re: TCP Protocol
Post by: plcnut on January 27, 2018, 02:19:51 PM
Do you have access to the Raspberry Pi code? It may be helpful in getting the correct code for the BRX.
Title: Re: TCP Protocol
Post by: ATU on January 27, 2018, 02:53:07 PM
My thoughts exactly! But its not happening. There are kingdoms within kingdoms.  :(