Home AMX User Forum NetLinx Studio

IP_SendData????

2»

Comments

  • RajRaj Posts: 53
    the camera i'm using is 215- E PTZ axis. with firmware version 4.XX
  • viningvining Posts: 4,368
    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.
  • RajRaj Posts: 53
    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
  • RajRaj Posts: 53
    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...
  • viningvining Posts: 4,368
    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) &#37; 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) 
    
Sign In or Register to comment.