how to start and close telnet sessions
MorgoZ
Junior Member
Hello,
how can i close a telnet session from Netlinx?
I know that just sending a "send_string" to a serial port with a device with a telnet session on it will send the data to that device (if the serial parameters are well configured).
But i need to start a telnet session, send something, and the close it to be able to later start a new session with a different user, for example. How could i implement that? Something like "ip_client_open" and "ip_client_close".
Thank you!
how can i close a telnet session from Netlinx?
I know that just sending a "send_string" to a serial port with a device with a telnet session on it will send the data to that device (if the serial parameters are well configured).
But i need to start a telnet session, send something, and the close it to be able to later start a new session with a different user, for example. How could i implement that? Something like "ip_client_open" and "ip_client_close".
Thank you!
Comments
-
Pretty much. Use IP open and in the online handler for that dev you'll get an online event. Depending on your device you may get a string in the string event handler sayin' howdy, please log in user:. Most likely you'll get nothing at all so once you get that online event notification you send your 1st string/command in queue and wait for a response. When you receive the response and you have nothing else to send then issue the IP close until the next need to send a command and you start all over again. It should all happen in a blink of an eye.
-
I recently create a system where the client need to control IS-XPT-2100 to turn on/off display and the way to do it it's thru telnet session.
define_function fnPlayerSerial(char ccmd[100], integer ndevice) // Send Command to Serial port of Player { if(TPlayer[ndevice].nonline) { if(!ndvplayerSerialOnline[ndevice])IP_CLIENT_OPEN(dvplayerserial[ndevice].PORT,TPlayer[ndevice].cSourceIP,lPlayerControlPort,IP_TCP) timed_wait_until(ndvPlayerSerialOnline[ndevice])100 { send_string dvplayerserial[ndevice],"'GET /command?',ccmd,' HTTP/1.0',$0D,$0A,'Host: ',TPlayer[ndevice].cSourceIP,':',itoa(lPlayerControlPort),$0D,$0A,$0D,$0A" if (nDebug) send_string 0,"'GET /command?',ccmd,' HTTP/1.0',$0D,$0A,'Host: ',TPlayer[ndevice].cSourceIP,':',itoa(lPlayerControlPort),$0D,$0A,$0D,$0A" wait 100 ip_client_close(dvplayerserial[ndevice].PORT) } } }
They way i done it, i open a telnet socket, send my command wait a time then i close it. it's very basic and it working great. -
Shouldn't be any need for http headers or GET, POST, etc in a telnet connection, maybe some telnet negotiations that looks like gobble-di-goop (hex strings) but not HTTP type requirements. I think the only time I even came across the gobble-di-goop was when writing code to connect to a Cisco switch and that did confuse the F out of me and made me read up on telnet sessions but most devices that connect via "telnet" aren't really telnet per se' but raw TCP connections made on port 23 but typically on some other obscure port.I recently create a system where the client need to control IS-XPT-2100 to turn on/off display and the way to do it it's thru telnet session.define_function fnPlayerSerial(char ccmd[100], integer ndevice) // Send Command to Serial port of Player { if(TPlayer[ndevice].nonline) { if(!ndvplayerSerialOnline[ndevice])IP_CLIENT_OPEN(dvplayerserial[ndevice].PORT,TPlayer[ndevice].cSourceIP,lPlayerControlPort,IP_TCP) timed_wait_until(ndvPlayerSerialOnline[ndevice])100 { send_string dvplayerserial[ndevice],"'GET /command?',ccmd,' HTTP/1.0',$0D,$0A,'Host: ',TPlayer[ndevice].cSourceIP,':',itoa(lPlayerControlPort),$0D,$0A,$0D,$0A" if (nDebug) send_string 0,"'GET /command?',ccmd,' HTTP/1.0',$0D,$0A,'Host: ',TPlayer[ndevice].cSourceIP,':',itoa(lPlayerControlPort),$0D,$0A,$0D,$0A" wait 100 ip_client_close(dvplayerserial[ndevice].PORT) } } }
They way i done it, i open a telnet socket, send my command wait a time then i close it. it's very basic and it working great. -
I recently create a system where the client need to control IS-XPT-2100 to turn on/off display and the way to do it it's thru telnet session.
Yeah, I think Raphayo is confusing "telnet" with a TCP connection. His example is actually implementing HTTP. Telnet is different animal. -
Shouldn't be any need for http headers or GET, POST, etc in a telnet connection, maybe some telnet negotiations that looks like gobble-di-goop (hex strings) but not HTTP type requirements. I think the only time I even came across the gobble-di-goop was when writing code to connect to a Cisco switch and that did confuse the F out of me and made me read up on telnet sessions but most devices that connect via "telnet" aren't really telnet per se' but raw TCP connections made on port 23 but typically on some other obscure port.
Yes your right it was not a telnet connection it was an http get command on a specific port. But using that kind of logic will give you the abilities to control your device thru telnet. -
Hello,
thanks for the answers, but in my post i was refering to a "serail port" connection, so no TCP socket connection is available (can't use ip_client_open / close).
-
Hello,
thanks for the answers, but in my post i was refering to a "serail port" connection, so no TCP socket connection is available (can't use ip_client_open / close).
Well, if it's just an rs232 connection, it's just simply mimicking whatever you do with a terminal session with a computer. Most times you have to send a CR/LF to wake the connection up. Then build a call/response routine to get through the login phase. You'll also have to figure out what character the terminal uses for a cursor and watch for that as well. A lot depends upon the behavior of the device.. -
Also make sure you do all you do your set baud stuff in or triggered by the devs online handler:Hello,
thanks for the answers, but in my post i was refering to a "serail port" connection, so no TCP socket connection is available (can't use ip_client_open / close).DEFINE_FUNCTION fnDevMod_Online() ///clean { ////fnDevMod_DeBug("'ONLINE :DEBUG <',ITOA(__LINE__),'>'"); CANCEL_WAIT 'WAITING_TO_CONNECT'; sJAP.nConnectState = IP_CLIENT_CONNECTED; sJAP.nConnectAttempts = 0; ON[vdvDev,254]; if(!sJAP.nDev_Is_IP) { SEND_COMMAND dvDev,'SET BAUD 9600,N,8,1 485 DISABLE' SEND_COMMAND dvDev,"'HSOFF'" SEND_COMMAND dvDev,"'XOFF'" //fnDevMod_DeBug("'RS232 connection [',fnDEV_TO_STRING(dvDev),'] * DEVICE ONLINE :DEBUG <',ITOA(__LINE__),'>'"); //fnDevMod_DeBug("'Initialized Serial Port! :DEBUG <',ITOA(__LINE__),'>'"); } else { //fnDevMod_DeBug("'IP connection [',fnDEV_TO_STRING(dvDev),'] * DEVICE ONLINE :DEBUG <',ITOA(__LINE__),'>'"); if(sJAP.nErrCode == ERR_FORCE_RECON) { fnSend_Main_LVL(nNumSWPorts,ERR_RECON_OK); } } sJAP.nAccessLevel = LEVEL_ZERO; fnCTS(); fnQueue_Process_Q(); RETURN; }Your params may vary. Some devices also require login so that may come up and require an exchange to gain access and that access may time out so you may have to login again but most devices are simple and should only require to proper serial comm parameters be sent to the port.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
