News:

  • August 17, 2026, 10:59:32 PM

Login with username, password and session length

Author Topic: TCP Protocol  (Read 17071 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
TCP Protocol
« 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?

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: TCP Protocol
« Reply #1 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 section of the forum, and there is also a client example that BobO wrote over there as well. There is another example posted HERE as well.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: TCP Protocol
« Reply #2 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?
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: TCP Protocol
« Reply #3 on: January 27, 2018, 10:58:23 AM »
Its German, an Otto inspection module. I am requesting more information.  Thanks for your help.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: TCP Protocol
« Reply #4 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.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: TCP Protocol
« Reply #5 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.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: TCP Protocol
« Reply #6 on: January 27, 2018, 12:06:00 PM »
NetBIOS. I think it is trying to convert TS.ESET.COM to an IP address.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: TCP Protocol
« Reply #7 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.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: TCP Protocol
« Reply #8 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.

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: TCP Protocol
« Reply #9 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.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: TCP Protocol
« Reply #10 on: January 27, 2018, 02:53:07 PM »
My thoughts exactly! But its not happening. There are kingdoms within kingdoms.  :(