IP_SendData????
Comments
-
the camera i'm using is 215- E PTZ axis. with firmware version 4.XX
-
I would do as SpireJeff suggested and create a queue to hold your string commands from button pushes. After the button push & string is added to queue connect to the camera. The camera will connect & you'll recieve an online event which you can use to check your queue for content & if content exists remove the 1st command in queue & send it. The camera will close the connection iniate an offline event & you can check the queus for further commands. If there are any reconnenct & repeat the process until the queue is empty.
I would scrap the wait_until method.
Here's the string I send for basic PTZ commands:DEFINE_FUNCTION fnAxisSendPTZConfig_CMD(CHAR iCmnd[]) { SEND_STRING dvAXISCAM,"'GET /axis-cgi/com/ptzconfig.cgi?camera=1&',iCmnd,' HTTP/1.1',CRLF" ; //SEND_STRING dvAXISCAM,"'Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash,', // ' application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml,', // ' application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*',CRLF" ; SEND_STRING dvAXISCAM,"'Referer: http://',cAXISCAM_IP_ADDRESS,'/view/status.html',CRLF" ; //SEND_STRING dvAXISCAM,"'Accept-Language: en-us',CRLF" ; // SEND_STRING dvAXISCAM,"'User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB5;', // ' .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 1.0.3705; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)',CRLF" ; // SEND_STRING dvAXISCAM,"'UA-CPU: x86',CRLF" ; //SEND_STRING dvAXISCAM,"'Accept-Encoding: gzip, deflate',CRLF" ; //SEND_STRING dvAXISCAM_Arry[nAxisCurCamIndx],"'If-Modified-Since: Fri, 13 Mar 1970 22:49:57 GMT; length=492',CRLF" ; SEND_STRING dvAXISCAM,"'Host: ',cAXISCAM_IP_ADDRESS,CRLF" ; SEND_STRING dvAXISCAM,"'Connection: Keep-Alive',CRLF" ; SEND_STRING dvAXISCAM,"'Authorization: Basic ',fnAxisEncryptUserPass(),CRLF" ; SEND_STRING dvAXISCAM,"CRLF" ; fnAxis_DeBug("'Sent: GET /axis-cgi/com/ptzconfig.cgi?camera=1&',iCmnd,'CRnLF. >-line-<',ITOA(__LINE__),'>'") ; fnAxis_DeBug("'Sent: Authorization Sent: ',fnAxisEncryptUserPass(),'. >-line-<',ITOA(__LINE__),'>'") ; RETURN ; }
Note: I use a username & password for camera access which requires base64 encryption. -
ooops..... i was not using the authentication in my code and the camera needed authentication.
but how do i include the camera authentication. in my code -
posting another silly question which i cant figure it out....
if you look at my code case 5 & 6. is it the rite way to zoom in and out..
i tried bu nothiin is happening... i tried storing it in another variable. the datatype i used was integer.. caould someone tell me wat the oprob is... -
This may be hard to follow since I pass the user : pass (no spaces) into the module as a variable & it would be simpler to leave as a constant. Basically paste the base64 function into your code and call the function w/ 'user : pass' (no spcaes) as the parameter. The function call is in the "GET" string being sent to the camera posted earlier. I've included the relavent parts & pieces so you can try yo follow how I'm doing it.
DEFINE_CONSTANT //USER NAME & PASSWORD FOR EACH CAMERA !!<-NEED TO CUSTOMIZE THIS TO PROJECT->!! (*(VAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV)*) (*(VAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV)*) (*>) (<*) (*>) !! USE THE SAME USERNAME & PASSWORD FOR ALL CAMERAS !! (<*) (*>) --> BUT IN CASE YOU CAN'T HERE'S AN ARRAY TO USE <-- (<*) (*>) (<*) (*>) If all cameras use the same username & password just put that in position 1 and it (<*) (*>) will get used for all cameras. If you have even 1 camera with a different user name (<*) (*>) & passowrd then you must fill out each username & password entry for each camera that (<*) (*>) is going to be controlled by this module. (<*) (*>) (<*) (**)VOLATILE CHAR AXISCAM_USERNAME_PASSWORD[AXIS_NUM_CAMERAS][20] = (**) (**) {//1234567890123456789012345 username:password (**) (*1 *)'user:pass' (*,, (**) (*2 *)'Camera_2', (**) (*3 *)'Camera_3', (**) (*4 *)'Camera_4', (**) (*5 *)'Camera_5', (**) (*6 *)'Camera_6', (**) (*7 *)'Camera_7', (**) (*8 *)'Camera_8', (**) (*9 *)'Camera_9', (**) (*10*)'Camera_10', (**) (*11*)'Camera_11', (**) (*12*)'Camera_12', (**) (*13*)'Camera_13', (**) (*14*)'Camera_14', (**) (*15*)'Camera_15', (**) (*16*)'Camera_16', (**) (*17*)'Camera_17', (**) (*18*)'Camera_18' , (**) (*19*)'Camera_19', (**) (*20*)'Camera_20' *) (**) } ; (**) (*^) YOU CAN LEAVE UN USED INPUTS AS '' OR LEAVE NAMES (^*) (*^) OR YOU CAN SHORTEN THE ARRAY TO SAVE MEMORY (^*) (*^) (^*) (*(VAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV)*) (*(VAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV)*) DEFINE_VARIABLE // VOLATILE CHAR cAxisCam_UserPass[AXIS_NUM_CAMERAS][20] ; //ip address for each axis camera DEFINE_FUNCTION CHAR[ENCR_MAX_ENC_LEN] fnEncrBase64Encode(CHAR cDecStr[]) { STACK_VAR CHAR cDecodeStr[ENCR_MAX_DEC_LEN] ; CHAR cEncodeStr[ENCR_MAX_ENC_LEN] ; INTEGER nLoop ; INTEGER nTemp ; CHAR cIdx1 ; CHAR cIdx2 ; CHAR cIdx3 ; CHAR cIdx4 ; CHAR cByte1 ; CHAR cByte2 ; CHAR cByte3 ; CHAR cChar1 ; CHAR cChar2 ; CHAR cChar3 ; CHAR cChar4 ; // Copy string and pad cDecodeStr = cDecStr nTemp = LENGTH_STRING(cDecodeStr) % 3 If (nTemp <> 0) { cDecodeStr[LENGTH_STRING(cDecodeStr)+1] = 0 ; cDecodeStr[LENGTH_STRING(cDecodeStr)+2] = 0 ; cDecodeStr[LENGTH_STRING(cDecodeStr)+3] = 0 ; } // Encode FOR (cEncodeStr = "", nLoop = 1; nLoop <= LENGTH_STRING(cDecodeStr); nLoop = nLoop + 3) {// Get bytes cByte1 = cDecodeStr[nLoop] ; cByte2 = cDecodeStr[nLoop+1] ; cByte3 = cDecodeStr[nLoop+2] ; // Get index cIdx1 = TYPE_CAST(((cByte1 & $FC) >> 2) + 1) ; cIdx2 = TYPE_CAST((((cByte2 & $F0) >> 4) | ((cByte1 & $03) << 4)) + 1) ; cIdx3 = TYPE_CAST((((cByte3 & $C0) >> 6) | ((cByte2 & $0F) << 2)) + 1) ; cIdx4 = TYPE_CAST( (cByte3 & $3F) + 1) ; // Get chars cChar1 = cEncrBase64[cIdx1] ; cChar2 = cEncrBase64[cIdx2] ; cChar3 = cEncrBase64[cIdx3] ; cChar4 = cEncrBase64[cIdx4] ; // Pad? If (LENGTH_STRING(cDecodeStr) < (nLoop+1)) { cChar3 = $3D ;// '=' } If (LENGTH_STRING(cDecodeStr) < (nLoop+2)) { cChar4 = $3D ;// '=' } // Build string cEncodeStr = "cEncodeStr, cChar1, cChar2, cChar3, cChar4" ; } RETURN cEncodeStr ; } DEFINE_FUNCTION CHAR[ENCR_MAX_ENC_LEN] fnAxisEncryptUserPass() { RETURN fnEncrBase64Encode(cAXISCAM_USER_PASS) ; } DEFINE_START //INITIALIZE/LOAD cAxisCam_IP_Address[], cAxisCam_UserPass[] & nAxisCam[] ARRAYS WITH VALUES { STACK_VAR INTEGER i ; STACK_VAR INTEGER x ; STACK_VAR INTEGER nArryLen ; nArryLen = length_array(AXISCAM_USERNAME_PASSWORD) ; for(i = 1 ; i <= AXIS_NUM_CAMERAS ; i ++) { cAxisCam_IP_Address[i] = AXISCAM_IP_ADDRESS[i] ; cAxisCam_PresetTXT[i] = 'Enter Preset Name' ; nAxisCam_Online[i] = 0 ; nAxisCam[i] = i ; if(nArryLen == AXIS_NUM_CAMERAS) { cAxisCam_UserPass[i] = AXISCAM_USERNAME_PASSWORD[i] ; } else { cAxisCam_UserPass[i] = AXISCAM_USERNAME_PASSWORD[1] ; } for(x = 1 ; x <= AXIS_NUM_PRESETS ; x ++) { //persistent but not really needed?? hmmm. maybe remove completely since names are stored on camera if(!length_string(cAxisPrestNamesArry[i][x])) { cAxisPrestNamesArry[i][x] = "'Preset ',itoa(x)" ; } } SET_LENGTH_ARRAY(cAxisPrestNamesArry[i],AXIS_NUM_PRESETS) ; } SET_LENGTH_ARRAY(cAxisCam_IP_Address,AXIS_NUM_CAMERAS) ; SET_LENGTH_ARRAY(cAxisCam_PresetTXT,AXIS_NUM_CAMERAS) ; SET_LENGTH_ARRAY(nAxisCam_Online,AXIS_NUM_CAMERAS) ; SET_LENGTH_ARRAY(nAxisCam,AXIS_NUM_CAMERAS) ; SET_LENGTH_ARRAY(cAxisCam_UserPass,AXIS_NUM_CAMERAS) ; DEFINE_MODULE 'VAV_AxisCam_PTZ_Mod,Rev 1' AXISCAM_1(vdvAxisCamTP_Arry[AXISCAM_1],dvAxisCam_Arry[AXISCAM_1],cAxisCam_IP_Address[AXISCAM_1], cAxisCam_UserPass[AXISCAM_1],cAxisPrestNamesArry[AXISCAM_1],cAxisCam_PresetTXT[AXISCAM_1],nAxisCam[AXISCAM_1],nAxisCam_DeBug)
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
