2222 *
2323 * @param Address The address of the camera
2424 * @param baud baud of the cameras
25- * @param txPin the TX pin of the module (Arduino to Cam)
2625 * @param rxPin the RX pin of the module (Cam to Arduino)
26+ * @param txPin the TX pin of the module (Arduino to Cam)
2727 * @param log_messages Print log messages of this camera
2828 * @param readEnPin Pin for RS485 modules that require toggle between rx and
2929 * tx (RE and \DE pin of the module)
3030 *
3131 */
3232
33- PelcoCam::PelcoCam (uint8_t address, uint32_t config, uint8_t txPin , uint8_t rxPin , bool log_messages,
33+ PelcoCam::PelcoCam (uint8_t address, uint32_t config, uint8_t rxPin , uint8_t txPin , bool log_messages,
3434 uint8_t readEnPin) {
3535 address_ = address;
3636 config_ = config;
@@ -168,7 +168,7 @@ bool PelcoCam::send_command(uint8_t command, uint16_t data1, uint8_t data2, bool
168168 if (log_messages_) {
169169 sprintf (
170170 log_buffer,
171- " Cam %i: ERROR Could not verify camera reponse : timeout reached (is camera well plugged in?)\n " ,
171+ " Cam %i: ERROR Could not verify camera ACK : timeout reached (is camera well plugged in?)\n " ,
172172 address_);
173173 Serial.print (log_buffer);
174174 }
@@ -179,16 +179,37 @@ bool PelcoCam::send_command(uint8_t command, uint16_t data1, uint8_t data2, bool
179179 timeout--;
180180 delayMicroseconds (10 );
181181 }
182+ if (log_messages_){
183+ sprintf (
184+ log_buffer,
185+ " Cam %i: Reading Acknoledge from camera\n " ,
186+ address_);
187+ Serial.print (log_buffer);
188+ }
182189
183190 (*SerialCam).readBytes (ACKmessFromCamera, 4 ); // General response is 4 byte
184191
185192 if (!autoModule_)
186193 digitalWrite (rePin_, HIGH); // set back at TX mode
187194
195+ if (log_messages_) {
196+ sprintf (log_buffer, " Cam %i: Received ACK data (may be wrong): " , address_);
197+ Serial.print (log_buffer);
198+
199+ for (int i = 0 ; i < 7 ; i++) {
200+ sprintf (log_buffer, " %02X " , messFromcamera[i]);
201+ Serial.print (log_buffer);
202+ }
203+ Serial.println ();
204+
205+ }
206+
207+
208+
188209 if (ACKmessFromCamera[0 ] != 0xFF ) { // Check sync byte and checksum of the previous comand
189210 if (log_messages_) {
190211 sprintf (log_buffer,
191- " Cam %i: ERROR Could not verify camera reponse : bad sync byte (is camera well plugged in?)\n " ,
212+ " Cam %i: ERROR Could not verify camera ACK : bad sync byte (is camera well plugged in?)\n " ,
192213 address_);
193214 Serial.print (log_buffer);
194215 }
@@ -198,7 +219,7 @@ bool PelcoCam::send_command(uint8_t command, uint16_t data1, uint8_t data2, bool
198219 if (ACKmessFromCamera[1 ] != address_) { // Check adress byte
199220 if (log_messages_) {
200221 sprintf (log_buffer,
201- " Cam %i: ERROR Could not verify camera reponse : bad address (is camera well plugged in?)\n " ,
222+ " Cam %i: ERROR Could not verify camera ACK : bad address (is camera well plugged in?)\n " ,
202223 address_);
203224 Serial.print (log_buffer);
204225 }
@@ -208,7 +229,7 @@ bool PelcoCam::send_command(uint8_t command, uint16_t data1, uint8_t data2, bool
208229 if (ACKmessFromCamera[2 ] != 0x00 ) { // check the always 0 byte (alarm byte)
209230 if (log_messages_) {
210231 sprintf (log_buffer,
211- " Cam %i: ERROR Could not verify camera reponse : bad null ???? (is camera well plugged in?)\n " ,
232+ " Cam %i: ERROR Could not verify camera ACK : bad null ???? (is camera well plugged in?)\n " ,
212233 address_);
213234 Serial.print (log_buffer);
214235 }
@@ -218,7 +239,7 @@ bool PelcoCam::send_command(uint8_t command, uint16_t data1, uint8_t data2, bool
218239 if (ACKmessFromCamera[3 ] != messToCamera[6 ]) { // Check the checksum
219240 if (log_messages_) {
220241 sprintf (log_buffer,
221- " Cam %i: ERROR Could not verify camera reponse : bad checksum (is camera well plugged in?)\n " ,
242+ " Cam %i: ERROR Could not verify camera ACK : bad checksum (is camera well plugged in?)\n " ,
222243 address_);
223244 Serial.print (log_buffer);
224245 }
0 commit comments