@@ -103,7 +103,7 @@ void PelcoCam::send_command(uint8_t command, uint8_t params, uint8_t params2){
103103 * @return true if succeded, false if an error occured
104104 */
105105
106- bool PelcoCam::send_request (uint8_t request, uint timeout, uint maxbuffer){
106+ int PelcoCam::send_request (uint8_t request, uint timeout, uint maxbuffer){
107107 byte response_command;
108108
109109 if (request == QUERY_PAN){response_command == RESP_PAN;}
@@ -112,15 +112,15 @@ bool PelcoCam::send_request(uint8_t request, uint timeout, uint maxbuffer){
112112 else if (request == QUERY_FOCUS){response_command = RESP_FOCUS;}
113113 else {
114114 if (log_messages_) Serial.println (" No valid request provided" );
115- return false ;
115+ return - 1 ;
116116 }
117117
118118 send_command (request); // Send the query
119119
120120 while (!SerialCam.available ()){// Wait for the first bit
121121 if (timeout==0 ){ // If timeout is reached
122122 if (log_messages_) Serial.print (" ERROR timout reached" );
123- return false ;
123+ return - 1 ;
124124 }
125125 timeout--;
126126 delayMicroseconds (10 );
@@ -148,7 +148,7 @@ bool PelcoCam::send_request(uint8_t request, uint timeout, uint maxbuffer){
148148 || command_index < 3 // Checks if the reponse byte is in the right place
149149 ){
150150 if (log_messages_)Serial.println (" Warn: no reponse from camera" );
151- return false ;
151+ return - 1 ;
152152 }
153153
154154 // Checksum is sum of everything except sync modulo 0x100
@@ -158,7 +158,7 @@ bool PelcoCam::send_request(uint8_t request, uint timeout, uint maxbuffer){
158158 if (buffer[command_index-3 ] != 0xFF &&
159159 buffer[command_index-2 != 00 ] &&
160160 !checksum){
161- return false ;
161+ return - 1 ;
162162 }
163163
164164 for (int i=0 ; i<7 ; i++){
@@ -173,7 +173,20 @@ bool PelcoCam::send_request(uint8_t request, uint timeout, uint maxbuffer){
173173 Serial.println ();
174174 }
175175
176- return true ;
176+ return messFromcamera[4 ]; // Returns MSB
177+ }
178+
179+ void PelcoCam::send_raw (uint8_t raw_command[]){
180+ if (raw_command[0 ]!=0xFF ) return ;
181+
182+ uint8_t checksum = (raw_command[1 ] + raw_command[2 ] + raw_command[3 ] + raw_command[4 ] + raw_command[5 ])%0x100 ;
183+ if (checksum != raw_command[6 ]){
184+ if (log_messages_) Serial.println (" Wrong chacksum, updating to right checksum" );
185+
186+ raw_command[6 ] = checksum;
187+ }
188+
189+ SerialCam.write (messToCamera, sizeof (messToCamera));
177190}
178191
179192/* !
0 commit comments