@@ -217,32 +217,36 @@ uint8_t Response_Packet::GetLowByte(uint16_t w)
217
217
#endif // __GNUC__
218
218
Data_Packet::Data_Packet (uint8_t * buffer, bool UseSerialDebug)
219
219
{
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);
225
226
226
- this->checksum = CalculateChecksum(buffer, 4);*/
227
+ this ->checksum = CalculateChecksum (buffer, 4 );
228
+ }
227
229
}
228
230
229
231
// 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 )
231
233
{
232
234
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 );
234
236
}
235
237
236
238
// Get the last data packet (<=128 bytes), calculate checksum, validate checksum received and send it to serial
237
239
void Data_Packet::GetLastData (uint8_t buffer[], uint16_t length, bool UseSerialDebug)
238
240
{
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
+ }
246
250
}
247
251
248
252
// 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
251
255
bool retval = (b != propervalue) && (b != alternatevalue);
252
256
if ((UseSerialDebug) && (retval))
253
257
{
254
- Serial.print (" Data_Packet parsing error " );
258
+ Serial.print (" \n Data_Packet parsing error " );
255
259
Serial.print (varname);
256
260
Serial.print (" " );
257
261
Serial.print (propervalue, HEX);
@@ -718,7 +722,7 @@ bool FPS_GT511C3::CaptureFinger(bool highquality)
718
722
return retval;
719
723
}
720
724
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
722
726
// Returns: True (device confirming download)
723
727
// It only worked with baud rate at 38400-57600 in GT-511C3.
724
728
// Slower speeds and the FPS will shutdown. Higher speeds and the serial buffer will overflow.
@@ -740,7 +744,7 @@ bool FPS_GT511C3::GetImage()
740
744
return retval;
741
745
}
742
746
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
744
748
// Returns: True (device confirming download)
745
749
// It only worked with baud rate at 38400-57600 in GT-511C3.
746
750
// Slower speeds and the FPS will shutdown. Higher speeds and the serial buffer will overflow.
@@ -762,7 +766,7 @@ bool FPS_GT511C3::GetRawImage()
762
766
return retval;
763
767
}
764
768
765
- // Gets a template from the fps (498 bytes)
769
+ // Gets a template from the fps (498 bytes + 2 bvtes checksum )
766
770
// Parameter: 0-199 ID number
767
771
// Returns:
768
772
// 0 - ACK Download starting
@@ -1093,7 +1097,7 @@ void FPS_GT511C3::GetData(uint16_t length)
1093
1097
}
1094
1098
data[i]= (uint8_t ) _serial.read ();
1095
1099
}
1096
- dp.GetData (data, 128 );
1100
+ dp.GetData (data, 128 , UseSerialDebug );
1097
1101
}
1098
1102
1099
1103
uint8_t lastdata[lastPacketSize];
0 commit comments