Network Communications

Hello All,

I am trying to communicate via the network port from a BL4S160 controller to a laptop computer (running windows). I simple need to report the status of various analog and digital inputs to the laptop.

I’m not sure what the best way is to go about establishing communications. I have telnet session established now between the controller and the laptop via a cross-over cable. I am able to pass data back and forth between the two, so that is good. The problem is that once the connection between the controller and the laptop is broken, I am cannot reconnect without restarting the micro-controller.

What’s the best way to do this?

  1. Should I use a website type connection (port 80) instead of telnet session (port 23)?
  2. Should I use Point-to-Point over ethernet?
  3. Should the controller be the client or the server?
  4. Which functions calls should I be using to establish the connection?

I need a robust system that can tolerate interruptions in the network connection and reconnect without user intervention.

Any input you can provide will be much appreciated.

Craig

Hi, i think you need something like tcp keepalive option. Every second or so your device sends a keepalive message to your pc and closes the tcp port if no response is detected. That way your pc can connect again.

#define KEEPALIVE_NUMRETRYS 2
#define KEEPALIVE_WAITTIME 20

I think the functionality is defined in the tcp.lib but i am not sure. You should be able find it. Hope this helps.

Hi Craig,

You might consider looking at BACnet as an option as it is designed as a syatem for dealing with just that type of data. I maintain a free BACnet stack for Rabbit syatems (including the BL4S160) at https://sourceforge.net/projects/bacrabbit/ and it can be used in conjunction with the PC based stack at https://sourceforge.net/projects/bacnet/ to provide a standard method of communicating between a device and a Pc.

There are certain advantages to using a protocol like BACnet for they type of work you are doing including:

  1. it uses UDP for all coms so there is no connection to keep alive.
  2. It has discovery and binding facilities which make it easier to find and connect to your devices.
  3. There are freely available tools to help you work with the protocol (and many commercial ones as well). VTS is good for interactive testing and the example programs with the stack provide support for tasks such as reading and writing point values which can be done from batch files or incorporated into other apps.
  4. Wireshark understands the protocol which makes debugging comms problems easier.

Regards,
Peter