News:

  • August 27, 2026, 10:36:18 PM

Login with username, password and session length

Author Topic: telnet  (Read 10121 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
telnet
« on: February 28, 2014, 03:51:25 PM »
Would it be possible to write a program for the DOmore to talk telnet? If so, best guess difficulty on a scale from 1-10?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: telnet
« Reply #1 on: February 28, 2014, 04:19:35 PM »
I've done a TelNet Server.  BobO's done a TelNet Server.  It's not that hard if you already understand TCPLISTEN.

TelNet Client, even easier.

I've attached the Server I did.  It's a little dated - the STRING handling could be cleaned up a little.

As with all examples, this is for educational purposes only and the user assumes all responsibility for its use.

It accepts the following commands:
HELP - dumps these commands
READIO - dumps the first 32 X's and 32 Y's in hexadecimal
STATS - dumps IP Address, firmware rev, scan time
TIME - dumps current time in the PLC
DATE - dumps current date in the PLC
EXIT - terminate the session

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: telnet
« Reply #2 on: February 28, 2014, 05:37:42 PM »
I guess i need a Client app.  Trying to pull data streaming from a device. I think once you give it the command, it just continuously spews data via telnet. 

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: telnet
« Reply #3 on: February 28, 2014, 09:23:13 PM »
Easy peasy...

Keys to success:
1. Create a TCPClient device.
2. Connect to your Telnet server by calling OPENTCP passing the IP and Port.
3. The .InQueue member of the structure associated with the TCPClient device will show pending data.
4. Call STREAMIN to read data. I generally prefer to wait for data in the queue prior to calling STREAMIN, so STREAMIN can expected to succeed without delay.
5. The .Connected member will remain true as long as your connection is good. Call OPENTCP again if the connection gets dropped.
6. A dedicated program block using stages to sequence the protocol is your friend.
7. Pat yourself on the back for how cool you were to do a custom protocol in a PLC.

"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: telnet
« Reply #4 on: March 01, 2014, 06:40:14 AM »
Thanks!