IP_SendData????
J.Y.
Posts: 34
Dear all,
I have a ip-cam , can I use Netlinx send_string like "http://192.168.0.100/ptzf.cgi?action=up" to let it up ?
Jason.
I have a ip-cam , can I use Netlinx send_string like "http://192.168.0.100/ptzf.cgi?action=up" to let it up ?
Jason.
0
Comments
Try opening a port on the camera using the ip_client_open command. Once this port is open then you should be able to send comands to the camera using the 'GET' command from the HTTP protocol. e.g.
send_string camera,"''GET ptzf.cgi?action=up HTTP/1.0',13,10,
'Host: localhost',13,10,
'Connection: Keep-Alive',13,10,
'Cache-Control: no-cache',13,10,13,10"
(where camera is the device no. i.e. 0:5:0)
Shane
I open a IP_Client(port:80) session,
and then
send_string IP_Client,"'GET ptzf.cgi?visca=8101060105060302FF HTTP/1.1',13,10,'Host:192.168.0.152',13,10,'Connection: Keep-Alive',13,10,
'Cache-Control: no-cache',13,10,13,10"
But it can't work well.
Am I type wrong?or .......
thanks your help.
result = ip_client_open(camera.port,'192.168.0.152',80,1)
where 80 is the port and 1 is the protocol, in this case TCP
Try something along the lines of this,
define_device
camera = 0:10:0
button_event[tp,upButton]
{
push:
{
sinteger result
result = ip_client_open(camera.Port,'192.168.0.152',80,1)//80=port,1=TCP
wait_until(camOnline) //set to 1 in online camera event, 0 in offline event
{
send_string camera,"''GET ptzf.cgi?action=up HTTP/1.0',13,10
'Host: localhost',13,10,
'Connection: Keep-Alive',13,10,
'Cache-Control: no-cache',13,10,13,10"
}
}
}
Make sure to set the 'camOnline' variable to 1 in an online event for the camera and camOnline to 0 in an offline event.
Also, the result variable will return an sinteger value. You should probably check to see this value returns 0 before sending the string to the camera. If it returns anything other than 0 that means there was an error opening the port.
The visca string sound like a Sony SNC-PZ30 IP cam...
Find attached an AWX ToGo workspace with a working example for pan and tilt functions. I also somewhere have an example for this cam with more functions, but I have to search for it.....
Good luck!
I am currently busy with an AXIS 212 IP cam and would like to control the zoom pan tilt functions. I do not have many experience with ip control.
Below my function to move the camera to the right,
// http://192.168.0.150/axis-cgi/com/ptz.cgi?camera=1&move=right // panning right
button_event[dvtp,1]
{
push:
{
if(!(cam_online))
{
ip_client_open(camera.Port,'192.168.0.150',80,1)//80=port,1=TCP
}
wait_until (cam_online)
{
send_string camera,"'GET ptz.cgi?camera=1&move=right http/1.1',13,10,13,10,'HOST: 192.168.0.202',13,10,13,10";
}
}
}
I found on the forums some information about opening and controlling ip clients but nothing
seems to work. Any ideas ??
Thanks
I have put in an online button to see wether camera is online or offline.
If I place in the define start section: ip client open...
He comes online, when I push the button to move camera right he goes offline and doesn't come online anymore ? When I remove ip client open in the define start section he doesn't come online at all ???
Is there something I could test with the ip client open function ?
Thanks
Standard HTML is that you send a request, and the server drops the connection ... so you may have to re-open the connection for every command.
'Cache-Control: no-cache' tells the browser not to cache this transfer (may not be required for NetLinx, but it was in the original string, so I left it )
I do know that many web server managers disable this feature. So, putting it in the string in no way ensures that the connection will stay alive. Keeping a connection alive past one transaction is a big security risk. I know I have it turned off on my web server. there is no error message sent, it just kills the connection.
Problem was I forgot the forward slash before axis.
Correct string:
send_string camera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=right HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
Thanks a lot for all the help and information.
- Chip
Has anyone had success with a Panasonic IP cam? I don't see anything here about getting passed the login to the cams web server.
You will have to send it the encoded username and password of the user unless you have it open for anyone to use. The encoding is base64 of which there are many examples on the web and I believe there is a AMX module that has implemented it as well.
Paul
You have to send user name and password regardless. The first time you access a Panasonic camera, if it has no login, it requires you to create one.
I have a full-blown module for controlling Panasonic cameras that works reasonably well (though not without one or two glitches). I don't, however, have it packaged for distribution, and it will be a few days before I can do so to share it.
Paul
I'm talking directly to the cameras. It's possible I missed something, but I don't recall that being an option in the IP cameras. You can do that with the portal in their router, but if you can do it with the cameras themselves, I haven't found that option .
After several hours of fiddling with it on site, I finally have it working. It's really rough, but a start.
I setup the "Guest" account to have pan/tilt permission in the cam.
I'm completely green here and I just starting throwing strings at it until it worked.
Any more feedback is appreciated.
Taken directly from my code...
"'GET nphControlCamera?Direction=TiltUp HTTP/1.0',13,10,
'HOST:10.0.0.201',13,10,'Connection:Keep-Alive',13,10,
'Cache-Control:no-cache',13,10,13,10"
The "Keep-Alive" part may leave this string today. I don't think it's working.
I'm not very good at AMX IP comm and I need to refine that end as well.
Is it typical to have tons of ONERROR activity?
http://www.w3.org/Protocols/HTTP/Issues/http-persist.html
A little something I found for "Connnection: Keep-Alive".
The proper way is to open it if its closed. You can keep track of the status of the port in the online/offline data_event. If its open, send the command, if it isn't, open it and wait for the online event to occur so you know its open and then send it. HTTP is a stateless protocol. You are asking for trouble if you try to code a workaround that relies on the port always being open. If you want to see what's going on write an ONERROR handler and print out what the error is, and if there is an error close the port.
Paul
I posted the code here it you want to take a look.
http://www.amxforums.com/showthread.php?p=25830#post25830
This is my practice as well. I don't close the port programmatically but check to see if it is closed and respond accordingly.
Paul
I can open the connection but it seems that this string just does nothing:
I'm getting no error, no string from the data_event for dvCam1 but I always get an OFFLINE after the second consecutive push on the TP...
Thanks for looking at this.
Paul-Eric
Thanks everyone!!
hello friends,
I really dont understand why i'm not able to tilt the camera on my first push itself. I'm using the following code.
As of now what happens is only aftr i push the button two times consecutivley I'm able to tilt the camera.
But i thot on the 1st push it might take sometime for the camera to come online so by the time of 2nd push the camera mite be ready to tkae the string.
But its not the case. you have to push twice everytime you have to tilt. Do you guys have any idea why it happens like that. Thankyou very much.
button_event[dvTP,200]
{
push:
{
ip_client_open(dvCamera.Port,'192.168.1.229',80,1)//80=port,1=TCP
send_string dvCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=right HTTP/1.1',13,10,'HOST: 192.168.1.299',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
}
This is assuming that the device closes the connection after sending a response. You should be able to verify this using the device notifications and/or diagnostic windows.
Jeff
I can control the camera now.
Hdello frenz,
I was jus tryin to control the PTZ axis camera using the format used in this forum.. but it doesnt seem to be working.. can yo please tll me y this aint wokring
PROGRAM_NAME='incPTZAxisCamera'
define_device
dvTP_FamLivPTZCam = 10015:5:2
dvAxisPTZCamera = 0:10:0
dvMasterNIController2 = 0:1:0
define_constant
nIPPort = 80
define_variable
IP_ADDRESS_STRUCT MyIPAddr
IP_ADDRESS_STRUCT ParkAreaPTZIPAddress
char cIPAddress[] = {'172.30.16.168'}
volatile dev dvTP_AxisPTZcontrolARRAY[]=
{
dvTP_FamLivPTZCam
}
integer nPTZParkingCameraBtn[]=
{
1, //UP dir
2, //DWN dir
3, //Left dir
4, //Right dir
5, //Zoom IN
6, //Zoom OUT
7, //Preset 1
8, //Preset 2
9 //Preset 3
}
integer nPTZParkingCameraONLINE //variable to check whther Camera is online
integer nzoomvariable //used to store the value for zoom
integer nzoomval
define_event
data_event[dvAxisPTZCamera]
{
ONLINE:
{
nPTZParkingCameraONLINE = 1
}
OFFLINE:
{
nPTZParkingCameraONLINE = 0
}
}
button_event[dvTP_AxisPTZcontrolARRAY,nPTZParkingCameraBtn]
{
push:
{
if(!(nPTZParkingCameraONLINE))
{
IP_CLIENT_OPEN(dvAxisPTZCamera.Port,cIPAddress,nIPPort,IP_TCP)
}
wait_until(nPTZParkingCameraONLINE)
{
switch(get_last(nPTZParkingCameraBtn))
{
case 1:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?move=up HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string 0,"'Checking'"
}
break
case 2:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=down HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 3:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=left HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 4:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=right HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 5:
{
if(nzoomvariable>9999)
{
nzoomvariable = 9999
}
else
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&zoom=',nzoomvariable+1,' HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
}
break
case 6:
{
if(nzoomvariable<1)
{
nzoomvariable = 1
}
else
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&zoom=',nzoomvariable-1,' HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
}
(*break
case 7:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 'cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 8:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 'cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}*)
}
}
}
hold[1,repeat]:
{
if(!(nPTZParkingCameraONLINE))
{
IP_CLIENT_OPEN(dvAxisPTZCamera.Port,cIPAddress,nIPPort,IP_TCP)
}
wait_until(nPTZParkingCameraONLINE)
{
switch(get_last(nPTZParkingCameraBtn))
{
case 1:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?move=up HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 2:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 3:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=down HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 4:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=left HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 5:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=right HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 6:
{
if(nzoomvariable>9999)
{
nzoomvariable = 9999
}
else
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&zoom=',nzoomvariable+1,' HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
}
break
case 7:
{
if(nzoomvariable<1)
{
nzoomvariable = 1
}
else
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&zoom=',nzoomvariable-1,' HTTP/1.1',13,10,'HOST: ',cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
}
(*break
case 8:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 'cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}
break
case 9:
{
//use the below string only by changing the IP adrr
//send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 192.168.0.202',13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
send_string dvAxisPTZCamera,"'GET /axis-cgi/com/ptz.cgi?camera=1&move=up HTTP/1.1',13,10,'HOST: 'cIPAddress,13,10,'Connection: Keep-Alive',13,10,'Cache-Control: no-cache',13,10,13,10"
}*)
}
}
}
}
define_start
GET_IP_ADDRESS(dvMasterNIController2, MyIPAddr)
//GET_IP_ADDRESS(dvAxisPTZCamera,ParkAreaPTZIPAddress)
(* Open The Client *)//dont use this , if without this oush button works.chek!
IP_CLIENT_OPEN(dvAxisPTZCamera.Port,cIPAddress,nIPPort,IP_TCP)