@@ -151,7 +151,7 @@ bool PelcoCam::send_command(uint8_t command, uint8_t data1, uint8_t data2, bool
151151
152152 SerialCam.write (messToCamera, sizeof (messToCamera)); // Write to the camera
153153
154- if (!request) { // Check the response of the camera
154+ if (!request) {// Check the response of the camera only if it isn't a request
155155 int timeout = 10000 ; // 10 millissecond wait
156156
157157 if (!autoModule_)
@@ -171,7 +171,7 @@ bool PelcoCam::send_command(uint8_t command, uint8_t data1, uint8_t data2, bool
171171 delayMicroseconds (10 );
172172 }
173173
174- SerialCam.readBytes (ACKmessFromCamera, 4 );
174+ SerialCam.readBytes (ACKmessFromCamera, 4 ); // General response is 4 byte
175175
176176 if (!autoModule_)
177177 digitalWrite (rePin_, HIGH); // set back at TX mode
@@ -193,7 +193,7 @@ bool PelcoCam::send_command(uint8_t command, uint8_t data1, uint8_t data2, bool
193193 return false ;
194194 }
195195
196- if (ACKmessFromCamera[2 ] != 0x00 ) {// check the always 0 byte
196+ if (ACKmessFromCamera[2 ] != 0x00 ) {// check the always 0 byte (alarm byte)
197197 if (log_messages_)
198198 Serial.printf (
199199 " Cam %i: ERROR Could not verify camera reponse: bad null ???? (is camera well plugged in?)\n " ,
@@ -225,7 +225,7 @@ bool PelcoCam::send_command(uint8_t command, uint8_t data1, uint8_t data2, bool
225225 * @return true if succeded, false if an error occured
226226 */
227227
228- int PelcoCam::send_request (uint8_t request, uint timeout, uint maxbuffer) {
228+ uint16_t PelcoCam::send_request (uint8_t request, uint timeout, uint maxbuffer) {
229229 byte response_command;
230230
231231 if (searchIndex (QUERY_CMND, request)!=-1 ) {
@@ -268,14 +268,6 @@ int PelcoCam::send_request(uint8_t request, uint timeout, uint maxbuffer) {
268268
269269 int command_index = searchIndex (buffer, 0x59 ); // Looks up where is the index of the response command
270270
271- /* A theorical response:
272- FF 00 59 4A 13 B7
273- sync null command msb lsb checksum
274-
275- A practical response (what does the arduino reads):
276- FF 00 FF 00 59 4A 13 B7 FF 01 48
277- */
278-
279271 if (command_index == -1 ) { // Checks if found
280272
281273 if (log_messages_)
@@ -304,10 +296,12 @@ int PelcoCam::send_request(uint8_t request, uint timeout, uint maxbuffer) {
304296 Serial.println ();
305297 }
306298
307- return messFromcamera[5 ] ; // Return LSB data
299+ return ( uint16_t ) ( messFromcamera[4 ] << 8 | messFromcamera[ 5 ]) ; // Return LSB data
308300}
309301
310- void PelcoCam::send_raw (String hex_string) {
302+
303+ // //////todo get the response if it is a query or extended one!!
304+ bool PelcoCam::send_raw (String hex_string) {
311305 hex_string.replace (" " , " " ); // Replace spaces
312306
313307 int size = hex_string.length () / 2 ; // Size of the string without space
@@ -343,6 +337,8 @@ void PelcoCam::send_raw(String hex_string) {
343337 }
344338 // write the command to the camera
345339 SerialCam.write (raw_command, sizeof (raw_command));
340+
341+ return true ;
346342}
347343
348344/* !
0 commit comments