Topic: Telnet into Nion with AMX
I'm trying to telnet into a Nion from AMX to perform an unattended reboot if it goes into fault, but having no luck. Seems like it would be more graceful than resetting the power. AMX diagnostics tells me the port(23) is open, but the Nion does not respond to the "root" or "reboot" command like a DOS telnet session does. Attached is a piece of AMX code I used for testing. Anyone have any ideas on what I might be doing wrong?
AMX Code
DEFINE_DEVICE
dvNION1_TN_PORT = 0:4:0
dvTP = 10001:1:0
DEFINE_VARIABLE
VOLATILE CHAR cNION1IP[15] = '10.42.51.39' //IP ADDRESSES OF NION
LONG TELNET_PORT = 23
DEFINE_EVENT
BUTTON_EVENT[dvTP,1]
{
Push:
{
IP_CLIENT_OPEN(dvNION1_TN_PORT.Port, cNION1IP, TELNET_PORT ,1)
}
}
BUTTON_EVENT[dvTP,2]
{
Push:
{
SEND_STRING dvNION1_TN_PORT,"'root',$0D,$0A"
}
}
BUTTON_EVENT[dvTP,3]
{
Push:
{
SEND_STRING dvNION1_TN_PORT,"'reboot',$0D,$0A"
}
}
DATA_EVENT[dvNION1_TN_PORT]
{
STRING:
{
SEND_STRING 0, "'NION1: ',DATA.TEXT"
}
ONERROR:
{
Send_String 0, "'NION1 TN PORT ERROR IS ', ITOA(DATA.NUMBER)" //Send the error number to Diagnostics
Switch (DATA.NUMBER)//Send error message to diagnostics
{
CASE 2: Send_String 0,'Onerror 2: General failure (out of memory)'
CASE 4: Send_String 0,'Onerror 4: Unknown host'
CASE 6: Send_String 0,'Onerror 6: Connection refused'
CASE 7: Send_String 0,'Onerror 7: Connection timed out'
CASE 8: Send_String 0,'Onerror 8: Unknown connection error'
CASE 14: Send_String 0,'Onerror 14: Local port already used'
CASE 16: Send_String 0,'Onerror 16: Too many open sockets'
CASE 17: Send_String 0,'Onerror 17: Local Port Not Open'
}
}
}