@@ -217,32 +217,36 @@ uint8_t Response_Packet::GetLowByte(uint16_t w)
217217#endif // __GNUC__
218218Data_Packet::Data_Packet (uint8_t * buffer, bool UseSerialDebug)
219219{
220- // The checksum here is arguably useless and may make the serial buffer overflow
221- /* CheckParsing(buffer[0], DATA_START_CODE_1, DATA_START_CODE_1, "DATA_START_CODE_1", UseSerialDebug);
222- CheckParsing(buffer[1], DATA_START_CODE_2, DATA_START_CODE_2, "DATA_START_CODE_2", UseSerialDebug);
223- CheckParsing(buffer[2], DATA_DEVICE_ID_1, DATA_DEVICE_ID_1, "DATA_DEVICE_ID_1", UseSerialDebug);
224- CheckParsing(buffer[3], DATA_DEVICE_ID_2, DATA_DEVICE_ID_2, "DATA_DEVICE_ID_2", UseSerialDebug);
220+ if (UseSerialDebug)
221+ {
222+ CheckParsing (buffer[0 ], DATA_START_CODE_1, DATA_START_CODE_1, " DATA_START_CODE_1" , UseSerialDebug);
223+ CheckParsing (buffer[1 ], DATA_START_CODE_2, DATA_START_CODE_2, " DATA_START_CODE_2" , UseSerialDebug);
224+ CheckParsing (buffer[2 ], DATA_DEVICE_ID_1, DATA_DEVICE_ID_1, " DATA_DEVICE_ID_1" , UseSerialDebug);
225+ CheckParsing (buffer[3 ], DATA_DEVICE_ID_2, DATA_DEVICE_ID_2, " DATA_DEVICE_ID_2" , UseSerialDebug);
225226
226- this->checksum = CalculateChecksum(buffer, 4);*/
227+ this ->checksum = CalculateChecksum (buffer, 4 );
228+ }
227229}
228230
229231// Get a data packet (128 bytes), calculate checksum and send it to serial
230- void Data_Packet::GetData (uint8_t buffer[], uint16_t length)
232+ void Data_Packet::GetData (uint8_t buffer[], uint16_t length, bool UseSerialDebug )
231233{
232234 for (uint16_t i = 0 ; i<length; i++) Serial.write (buffer[i]);
233- // this->checksum = CalculateChecksum(buffer, 128); // Checksum slowdown
235+ if (UseSerialDebug) this ->checksum = CalculateChecksum (buffer, 128 );
234236}
235237
236238// Get the last data packet (<=128 bytes), calculate checksum, validate checksum received and send it to serial
237239void Data_Packet::GetLastData (uint8_t buffer[], uint16_t length, bool UseSerialDebug)
238240{
239- for (uint16_t i = 0 ; i<(length-2 ); i++) Serial.write (buffer[i]);
240- // The checksum here is arguably useless and may make the serial buffer overflow
241- /* this->checksum = CalculateChecksum(buffer, length);
242- uint8_t checksum_low = GetLowByte(this->checksum);
243- uint8_t checksum_high = GetHighByte(this->checksum);
244- CheckParsing(buffer[length-2], checksum_low, checksum_low, "Checksum_LOW", UseSerialDebug);
245- CheckParsing(buffer[length-1], checksum_high, checksum_high, "Checksum_HIGH", UseSerialDebug);*/
241+ for (uint16_t i = 0 ; i<length; i++) Serial.write (buffer[i]);
242+ if (UseSerialDebug)
243+ {
244+ this ->checksum = CalculateChecksum (buffer, length-2 );
245+ uint8_t checksum_low = GetLowByte (this ->checksum );
246+ uint8_t checksum_high = GetHighByte (this ->checksum );
247+ CheckParsing (buffer[length-2 ], checksum_low, checksum_low, " Checksum_LOW" , UseSerialDebug);
248+ CheckParsing (buffer[length-1 ], checksum_high, checksum_high, " Checksum_HIGH" , UseSerialDebug);
249+ }
246250}
247251
248252// checks to see if the byte is the proper value, and logs it to the serial channel if not
@@ -251,7 +255,7 @@ bool Data_Packet::CheckParsing(uint8_t b, uint8_t propervalue, uint8_t alternate
251255 bool retval = (b != propervalue) && (b != alternatevalue);
252256 if ((UseSerialDebug) && (retval))
253257 {
254- Serial.print (" Data_Packet parsing error " );
258+ Serial.print (" \n Data_Packet parsing error " );
255259 Serial.print (varname);
256260 Serial.print (" " );
257261 Serial.print (propervalue, HEX);
@@ -718,7 +722,7 @@ bool FPS_GT511C3::CaptureFinger(bool highquality)
718722 return retval;
719723}
720724
721- // Gets an image that is 258x202 (52116 bytes) and sends it over serial
725+ // Gets an image that is 258x202 (52116 bytes + 2 bytes checksum ) and sends it over serial
722726// Returns: True (device confirming download)
723727 // It only worked with baud rate at 38400-57600 in GT-511C3.
724728 // Slower speeds and the FPS will shutdown. Higher speeds and the serial buffer will overflow.
@@ -740,7 +744,7 @@ bool FPS_GT511C3::GetImage()
740744 return retval;
741745}
742746
743- // Gets an image that is qvga 160x120 (19200 bytes) and sends it over serial
747+ // Gets an image that is qvga 160x120 (19200 bytes + 2 bytes checksum ) and sends it over serial
744748// Returns: True (device confirming download)
745749 // It only worked with baud rate at 38400-57600 in GT-511C3.
746750 // Slower speeds and the FPS will shutdown. Higher speeds and the serial buffer will overflow.
@@ -762,7 +766,7 @@ bool FPS_GT511C3::GetRawImage()
762766 return retval;
763767}
764768
765- // Gets a template from the fps (498 bytes)
769+ // Gets a template from the fps (498 bytes + 2 bvtes checksum )
766770// Parameter: 0-199 ID number
767771// Returns:
768772// 0 - ACK Download starting
@@ -1093,7 +1097,7 @@ void FPS_GT511C3::GetData(uint16_t length)
10931097 }
10941098 data[i]= (uint8_t ) _serial.read ();
10951099 }
1096- dp.GetData (data, 128 );
1100+ dp.GetData (data, 128 , UseSerialDebug );
10971101 }
10981102
10991103 uint8_t lastdata[lastPacketSize];
0 commit comments