Home AMX User Forum NetLinx Studio

Stumped by Panasonic AW-HE40 IP Camera Control

OK, I'm stumped by a couple Panasonic AW-HE40 cameras I'm trying to control over IP. I can type the following directly into my browser:
http://10.200.133.114/cgi-bin/aw_ptz?cmd=%23P50&res=1
...and I get the expected "pS50" response. In fact when I send other malformed commands via the browser, I usually get a "BAD REQUEST" response at least. But when I connect to the camera in the AMX controller, the connection opens and I send a string, but I never get anything back from the camera as far as I can tell.

Here's snippets of my code:
DEFINE_DEVICE //IP Ports
dvcam_r = 0:11:0 //Rear (presenter cam)
dvcam_f = 0:12:0 //Front (audience Cam)


DEFINE_EVENT

data_event[d_all] { //All COMM Devices
online: { //All devices come online
if(data.device.port==11 || data.device.port == 12) { //Cameras, running on controller ports 0:11:0 and 0:12:0
call 'debug' ("'Camera Connection Open: RM:',itoa(this_rm),' DID:',itoa(this_did)")
rm[this_rm].d[this_did].ipconnect = 1
}
offline: {
if(data.device.port==11 || data.device.port == 12) { //Cameras, running on controller ports 0:11:0 and 0:12:0
call 'debug' ("'Camera Connection Closed: RM:',itoa(this_rm),' DID:',itoa(this_did)")
rm[this_rm].d[this_did].ipconnect = 0
}
string: {

call 'debug' ("'Raw DEV Port: ',itoa(data.device.port)")
call 'debug' ("'Managed DID Number: ',itoa(this_did)")

call 'debug' ("'Data From Device: RM:',itoa(this_rm),' DID:',itoa(this_did),' Port:',itoa(data.device.port),' - ',data.text")

call 'debug' ("'Adding Data to Buffer: RM:',itoa(this_rm),' DID:',itoa(this_did),' Data:',data.text")

call 'debug' ("'Buffer Before:',rm[this_rm].d[this_did].buffin")
rm[this_rm].d[this_did].buffin = "rm[this_rm].d[this_did].buffin,data.text"
call 'debug' ("'Buffer After:',rm[this_rm].d[this_did].buffin")

}



DEFINE_PROGRAM

// Cameras
while(find_string(rm[1].d[8].buffout,"'res=1'",1)&&!timeline_active(1083)) { //command in buffer
timeline_create(1083,cmd[rm[1].d[8].type].commtimeout,1,timeline_absolute,timeline_once) // response limit timer144
rm[1].d[8].ipdone = 0
rm[1].d[8].lastacmd = remove_string(rm[1].d[8].buffout,"'res=1'",1)
call 'debug' ("'Camera IP Port Open: RM:1 DID:8 IPADDR:',rm[1].d[8].ipcomm[1].ipaddr,' IPPORT:',itoa(rm[1].d[8].ipcomm[1].ipport)")
ip_client_open( rm[1].d[8].devid.port , rm[1].d[8].ipcomm[1].ipaddr , 80,1)//80=port,1=TCP
call 'debug' ("'Opening Campera IP Connection...'")
wait_until(rm[1].d[8].ipconnect==1) { //set to 1 in online data event, 0 in offline event
call 'debug' ("'Camera connection opened, Sending Control String: RM:1 DID:8 Request: GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[8].lastacmd,$0D,$0A")
send_string dvcam_r,"'GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[8].lastacmd,$0D,$0A"
// call 'debug' ("'Cam Command Submit: ','GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[26].lastacmd,$0D,$0A")
}
}
while( length_string( rm[1].d[8].buffin ) > 0 && rm[1].d[8].ipconnect == 0 ) {
// call 'debug' ("'Cam Response Processing, Original Command: ', rm[1].d[26].lastacmd ")
call 'camresponseparser' ( 1, 8, "rm[1].d[8].buffin" )
rm[1].d[8].buffin = "''"
rm[1].d[8].ipdone = 1
timeline_kill(1083) //
}


...I think that's about it anyway. Everything works up to the point where the camera connection is opened, and the code sends the GET string, at which point the camera just doesn't respond. Here's a debug trace of the process:

Line 1 (09:44:04):: Input Status:Pushed [10002:8:1] - Channel 3
Line 2 (09:44:04):: String To [33013:1:1]-[Camera Push Control: RM:1 DID:8 Btn:3]
Line 3 (09:44:04):: String From [33013:1:1]-[Camera Push Control: RM:1 DID:8 Btn:3]
Line 4 (09:44:04):: String To [33013:1:1]-[Pan Left (Push) RM:1 DID:8 Btn:3]
Line 5 (09:44:04):: String From [33013:1:1]-[Pan Left (Push) RM:1 DID:8 Btn:3]
Line 6 (09:44:04):: String To [33013:1:1]-[Current Buffer: RM:1 DID:8 CAM:3 Buffer:P40&res=1]
Line 7 (09:44:04):: String From [33013:1:1]-[Current Buffer: RM:1 DID:8 CAM:3 Buffer:P40&res=1]
Line 8 (09:44:04):: String To [33013:1:1]-[Camera IP Port Open: RM:1 DID:8 IPADDR:10.200.133.114 IPPORT:80]
Line 9 (09:44:04):: String From [33013:1:1]-[Camera IP Port Open: RM:1 DID:8 IPADDR:10.200.133.114 IPPORT:80]
Line 10 (09:44:04):: String To [33013:1:1]-[Opening Campera IP Connection...]
Line 11 (09:44:04):: String From [33013:1:1]-[Opening Campera IP Connection...]
Line 12 (09:44:04):: Input Status:Released [10002:8:1] - Channel 3
Line 13 (09:44:04):: String To [33013:1:1]-[Camera Release Control: RM:1 DID:8 Btn:3]
Line 14 (09:44:04):: String From [33013:1:1]-[Camera Release Control: RM:1 DID:8 Btn:3]
Line 15 (09:44:04):: String To [33013:1:1]-[STOP Pan RM:1 CAM:8 Btn:3]
Line 16 (09:44:04):: String From [33013:1:1]-[STOP Pan RM:1 CAM:8 Btn:3]
Line 17 (09:44:04):: String To [33013:1:1]-[DEV Number: 0]
Line 18 (09:44:04):: String From [33013:1:1]-[DEV Number: 0]
Line 19 (09:44:04):: String To [33013:1:1]-[DEV Port: 11]
Line 20 (09:44:04):: String From [33013:1:1]-[DEV Port: 11]
Line 21 (09:44:04):: String To [33013:1:1]-[Error Count: 0]
Line 22 (09:44:04):: String From [33013:1:1]-[Error Count: 0]
Line 23 (09:44:04):: String To [33013:1:1]-[DEVICE ONLINE: RM:1 DID:8]
Line 24 (09:44:04):: String From [33013:1:1]-[DEVICE ONLINE: RM:1 DID:8]
Line 25 (09:44:04):: String To [33013:1:1]-[Standard Device Online: RM:1 DID:8]
Line 26 (09:44:04):: String From [33013:1:1]-[Standard Device Online: RM:1 DID:8]
Line 27 (09:44:04):: String To [33013:1:1]-[Camera Connection Open: RM:1 DID:8]
Line 28 (09:44:04):: String From [33013:1:1]-[Camera Connection Open: RM:1 DID:8]
Line 29 (09:44:04):: String To [33013:1:1]-[Camera connection opened, Sending Control String: RM:1 DID:8 Request: GET /cgi-bin/aw_ptz?cmd=#P40&res=1$0D$0A]
Line 30 (09:44:04):: String From [33013:1:1]-[Camera connection opened, Sending Control String: RM:1 DID:8 Request: GET /cgi-bin/aw_ptz?cmd=#P40&res=1$0D$0A]
Line 31 (09:44:06):: String To [33013:1:1]-[Cam Comm Timeout limit: Rear/Presenter RM:1 DID:8]
Line 32 (09:44:06):: String From [33013:1:1]-[Cam Comm Timeout limit: Rear/Presenter RM:1 DID:8]
Line 33 (09:44:06):: String To [33013:1:1]-[Camera IP Port Open: RM:1 DID:8 IPADDR:10.200.133.114 IPPORT:80]
Line 34 (09:44:06):: String From [33013:1:1]-[Camera IP Port Open: RM:1 DID:8 IPADDR:10.200.133.114 IPPORT:80]
Line 35 (09:44:06):: String To [33013:1:1]-[Opening Campera IP Connection...]
Line 36 (09:44:06):: String From [33013:1:1]-[Opening Campera IP Connection...]
Line 37 (09:44:06):: String To [33013:1:1]-[Camera connection opened, Sending Control String: RM:1 DID:8 Request: GET /cgi-bin/aw_ptz?cmd=##P50&res=1$0D$0A]
Line 38 (09:44:06):: String From [33013:1:1]-[Camera connection opened, Sending Control String: RM:1 DID:8 Request: GET /cgi-bin/aw_ptz?cmd=##P50&res=1$0D$0A]
Line 39 (09:44:06):: String To [33013:1:1]-[DEV Number: 0]
Line 40 (09:44:06):: String From [33013:1:1]-[DEV Number: 0]
Line 41 (09:44:06):: String To [33013:1:1]-[DEV Port: 11]
Line 42 (09:44:06):: String From [33013:1:1]-[DEV Port: 11]
Line 43 (09:44:06):: String To [33013:1:1]-[Port error: RM:1 DID:8 ERROR=14]
Line 44 (09:44:06):: String From [33013:1:1]-[Port error: RM:1 DID:8 ERROR=14]
Line 45 (09:44:06):: String To [33013:1:1]-[Error Count: 1]
Line 46 (09:44:06):: String From [33013:1:1]-[Error Count: 1]
Line 47 (09:44:08):: String To [33013:1:1]-[Cam Comm Timeout limit: Rear/Presenter RM:1 DID:8]
Line 48 (09:44:08):: String From [33013:1:1]-[Cam Comm Timeout limit: Rear/Presenter RM:1 DID:8]
Line 49 (09:44:11):: String To [33013:1:1]-[DEV Number: 0]
Line 50 (09:44:11):: String From [33013:1:1]-[DEV Number: 0]
Line 51 (09:44:11):: String To [33013:1:1]-[DEV Port: 11]
Line 52 (09:44:11):: String From [33013:1:1]-[DEV Port: 11]
Line 53 (09:44:11):: String To [33013:1:1]-[Port error: RM:1 DID:8 ERROR=0]
Line 54 (09:44:11):: String From [33013:1:1]-[Port error: RM:1 DID:8 ERROR=0]
Line 55 (09:44:11):: String To [33013:1:1]-[Error Count: 2]
Line 56 (09:44:11):: String From [33013:1:1]-[Error Count: 2]
Line 57 (09:44:11):: String To [33013:1:1]-[Starting Delayed Port Re-Open Sequence. ErrorCount:2]
Line 58 (09:44:11):: String From [33013:1:1]-[Starting Delayed Port Re-Open Sequence. ErrorCount:2]
Line 59 (09:44:11):: String To [33013:1:1]-[Camera Connection Closed: RM:1 DID:8]
Line 60 (09:44:11):: String From [33013:1:1]-[Camera Connection Closed: RM:1 DID:8]


The craziest thing seems to be, that I've copied this code from another installation where I'm successfully controlling a total of 10 Panasonic AW-HE60 cameras. I can't figure out what's different between the two installations, why the one controller talks to the HE60's fine, but this controller won't talk to these HE40's correctly.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    Line 37 (09:44:06):: String To [33013:1:1]-[Camera connection opened, Sending Control String: RM:1 DID:8 Request: GET /cgi-bin/aw_ptz?cmd=##P50&res=1$0D$0A]
    

    Don't know about your code or the contents of the GET but the GET should terminate with 2 - CRLFs not just one.

    "$0D, $0A, $0D, $0A"
  • fogled@mizzoufogled@mizzou Posts: 549
    Joe Hebert wrote: »

    Don't know about your code or the contents of the GET but the GET should terminate with 2 - CRLFs not just one.

    "$0D, $0A, $0D, $0A"


    Good point, I haven't tried that specific variation yet, even though I thought about it. The HE-60's I've got are working with the single CR/LF. The bizarre thing is, the other cameras apparently also work with a double pound-sign in the URL: "...cmd=##P50&res=1" because... I've got that bug in the other system and the cameras still work. Maybe these HE40's are a little pickier about their GET command responses.

  • fogled@mizzoufogled@mizzou Posts: 549
    Joe Hebert wrote: »

    Don't know about your code or the contents of the GET but the GET should terminate with 2 - CRLFs not just one.

    "$0D, $0A, $0D, $0A"


    YOU NAILED IT. Not sure why the HE60's seem to work with just a single CR/LF, but adding the 2nd set worked in this install for the HE40's.

    Thanks!
  • Joe HebertJoe Hebert Posts: 2,159
    You're welcome. Glad you got things working.
  • fogled@mizzoufogled@mizzou Posts: 549
    Wait, not so fast... now I'm getting a response from the cameras, but all I can seem to get is "Bad Request". Doesn't seem to matter whether I use the #, an actual %23, or a hex $23 in the command string, it doesn't like it.
  • Yeah sorry guys still stumped. I get a response from the camera now, but I can't figure out how to send it a GET string it likes.

    I've tried the "'#'", "$23", "'%23'"
    I've tried adding more CR/LF's at the end
    I've tried combinations of parts or all of the entire URL (http://blahblah)
    I've copied and pasted from the browser URL that worked, to the AMX code, that doesn't.

    If I use the URL string in the browser with the %23 to represent the # in the command string, it works. But, I can't seem to duplicate the browser's GET functionality in AMX code.
    I've got 10 AW-HE60's working with ## and a single CR/LF being sent to the camera

    I need to swap cameras between the systems to see if it's really the camera or the code. I think these HE40's are just pickier about the URL format.
  • GregGGregG Posts: 251
    I usually send a bit more detail in a get request, something more like this:
    Send_String dvPort,"'GET /cgi-bin/aw_ptz?cmd=%23blahblah HTTP/1.1',13,10,
                        'Host: ',rm[1].d[8].ipcomm[1].ipaddr,13,10,
                        'User-Agent: HTTPPuller/0.01 (+http://www.example.com/myagentinfo.html; NetLinx)',13,10,
                        'Connection: close',13,10,13,10"
    

    You may or may not want the connection close option in your version, but I don't normally "keep-alive" the http connections. The user agent is made up. The Host should be either the IP or hostname of the thing you are connecting with. Having the correct hostname is usually more important for name based web servers, but it shouldn't hurt to add anyway.
  • Joe HebertJoe Hebert Posts: 2,159
    GregG wrote: »
    I usually send a bit more detail in a get request, something more like this:
    Send_String dvPort,"'GET /cgi-bin/aw_ptz?cmd=%23blahblah HTTP/1.1',13,10,
    'Host: ',rm[1].d[8].ipcomm[1].ipaddr,13,10,
    'User-Agent: HTTPPuller/0.01 (+http://www.example.com/myagentinfo.html; NetLinx)',13,10,
    'Connection: close',13,10,13,10"
    

    Same here except for the User-Agent. Never found a need for that before.
  • GregGGregG Posts: 251
    I added the user agent part in mine so that I could judge how many AMX systems vs other systems were hitting our company in-house services.
  • Thanks Greg! The way these cameras are acting, I suspect you're right; I have to give all that info to other devices, just not my older HE60s. I will give that a try this afternoon on the HE40s and report back.
  • Sorry it took a few days to actually get back to this issue, but I do have the IP control working on these cameras now. The winning code:
    send_string dvcam_f,"'GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[8].lastacmd,
     ' HTTP/1.0',$0D,$0A,
     'Host: ',rm[1].d[8].ipcomm[1].ipaddr,$0D,$0A,
     'Connection: close',$0D,$0A,
     $0D,$0A"
    
    I had to remove the first $0D,$0A directly after the command string to get the camera to accept the command as valid.

    Thanks for everyone's help!
Sign In or Register to comment.