IP communication with APC 7920
Sentenced
Posts: 2
Hello people,
this is my first post so ....
The problem:
- i have a APC 7920 UPS and i need to connect to the device via telnet and restart some outputs (Sky1, Sky2, Apple TV, etc...)
- the problem is that when i login to APC with telnet the device has a menu; i have to navigate thru the menu in order to reboot some devices - i attached an image with the APC telnet session;
i have the code below for connecting and restarting devices (for the moment is a testing phase so i restart all)
#############
output from netlinx when a push button 1 from touch panel:
####
Line 44 (11:59:06):: Connected Successfully
Line 45 (11:59:06):: CIpEvent::OnLine 0:5:1
Line 46 (11:59:13):: CIpSocketMan::ProcessPLPacket - ClientOpen handle already in use
Line 47 (11:59:13):: Exiting TCP Read thread - closing this socket for local port 5
Line 48 (11:59:13):: CIpEvent::OnError 0:5:1
Line 49 (11:59:13):: Device 0:5:1:$0D$0A
Line 50 (11:59:13):: CIpEvent::OffLine 0:5:1
####
can you tell me where i'm wrong? the APC is not doing nothing ....
this is my first post so ....
The problem:
- i have a APC 7920 UPS and i need to connect to the device via telnet and restart some outputs (Sky1, Sky2, Apple TV, etc...)
- the problem is that when i login to APC with telnet the device has a menu; i have to navigate thru the menu in order to reboot some devices - i attached an image with the APC telnet session;
i have the code below for connecting and restarting devices (for the moment is a testing phase so i restart all)
DEFINE_DEVICE dvIPPower = 0:5:0 // IP Communication Device dvPANEL = 10001:1:0 //Touch Panel DEFINE_VARIABLE CHAR sIP_CLIENT_BUFFER[20000] // for receiving data sent from a server INTEGER CONNECTED // set if IP connection was established DEFINE_START CREATE_BUFFER dvIPPower,sIP_CLIENT_BUFFER IP_CLIENT_OPEN(dvIPPower.Port,'192.168.1.13',23,1) DEFINE_EVENT DATA_EVENT[dvIPPower] { ONLINE: // IP Device comes ONLINE, if connection was established on IP level { CONNECTED = 1 } OFFLINE: // IP Device goes OFFLINE, if connection was closed on IP level { CONNECTED = 0 } STRING: { // operate received data like data of a serial device } ONERROR: // if an error message comes from IP Connection { IF(DATA.Number <> 0) // DATA.Number=0 -> no error { SEND_STRING 0,"'Device ',DEV_TO_STRING(DATA.Device),':',GET_IP_ERROR(DATA.Number),13,10" } } } BUTTON_EVENT[dvPANEL,1] // Device 1 - reboot { PUSH: { IF ([dvPANEL,1]=1) { IP_CLIENT_OPEN(dvIPPower.Port,'192.168.1.13',23,1) //Go Online IF(CONNECTED) { SEND_STRING dvIPPower, "'apc',$0D" // username SEND_STRING dvIPPower, "'apc',$0D" // password SEND_STRING dvIPPower, "'1',$0D" // SEND_STRING dvIPPower, "'2',$0D" // SEND_STRING dvIPPower, "'1',$0D" // SEND_STRING dvIPPower, "'9',$0D" // SEND_STRING dvIPPower, "'1',$0D" // SEND_STRING dvIPPower, "'6',$0D" // SEND_STRING dvIPPower, "'yes',$0D" // SEND_STRING dvIPPower, "'$0D'" // IP_CLIENT_CLOSE(dvIPPower.Port) //Go Offline } [dvPANEL,1]=0 } ELSE { IP_CLIENT_OPEN(dvIPPower.Port,'192.168.1.13',23,1) //Go Offline IF(CONNECTED) { SEND_STRING dvIPPower, "'apc',$0D" // username SEND_STRING dvIPPower, "'apc',$0D" // password SEND_STRING dvIPPower, "'1',$0D" // SEND_STRING dvIPPower, "'2',$0D" // SEND_STRING dvIPPower, "'1',$0D" // SEND_STRING dvIPPower, "'9',$0D" // SEND_STRING dvIPPower, "'1',$0D" // SEND_STRING dvIPPower, "'6',$0D" // SEND_STRING dvIPPower, "'yes',$0D" // SEND_STRING dvIPPower, "'$0D'" // IP_CLIENT_CLOSE(dvIPPower.Port) //Go Offline } [dvPANEL,1]=1 } } }
#############
output from netlinx when a push button 1 from touch panel:
####
Line 44 (11:59:06):: Connected Successfully
Line 45 (11:59:06):: CIpEvent::OnLine 0:5:1
Line 46 (11:59:13):: CIpSocketMan::ProcessPLPacket - ClientOpen handle already in use
Line 47 (11:59:13):: Exiting TCP Read thread - closing this socket for local port 5
Line 48 (11:59:13):: CIpEvent::OnError 0:5:1
Line 49 (11:59:13):: Device 0:5:1:$0D$0A
Line 50 (11:59:13):: CIpEvent::OffLine 0:5:1
####
can you tell me where i'm wrong? the APC is not doing nothing ....
0
Comments
If you decide or need to change the open to a button push then you'll need to do the 'open' and store the command in a var and then send the stored command when you get your online event in your online data event handler. Use that to trigger sending your command. The way the button push is written now you're sending the command before the connection is even made.
Oh and welcome aboard!
and i press button 1 on the touch panel its doing nothing. But if i press the button again its sends the commands and restarts the output. Then is the same thing :
Any idea? Thank you for your time.
First connect using the IP OPEN, then check your in box (data event string handler) for a prompt from the device. It may send LOGIN: to which you have to reply. You may have to send it your username but you may be able to send both the user & password but you have to do what it wants and expects otherwise it will likely just close the door. Once logged in you can probably issue any command but that may depend on APC's protocol. Opening the port and then sending a much of crap at the device usually doesn't work unless it's Craptron. (that's a joke)
Take it one step at a time, first connect, then get logged in and then try commands. You might want to read and post the APC specs. Then when you have questions someone may have a better chance of giving help that actually matches the requirements of this device.