Skip to content

Commit 4181d4d

Browse files
committed
Some patches over GetImage() method. This is completely broken. Check the comments in the code.
1 parent b653dbd commit 4181d4d

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

src/FPS_GT511C3.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -728,19 +728,42 @@ bool FPS_GT511C3::CaptureFinger(bool highquality)
728728
// Slower speeds and the FPS will shutdown. Higher speeds and the serial buffer will overflow.
729729
// Make sure you are allocating enough CPU time for this task or you will overflow nonetheless.
730730
// Also, avoid using UseSerialDebug for this task, since it's easier to overflow.
731-
bool FPS_GT511C3::GetImage()
731+
// WARNING: This method is completely broken, but you can give it a try.
732+
// Patched method will return a 232x139 bitmap 8-bit image, 32248 bytes.
733+
// Parameter: true to ignore the documentation and get valid image data.
734+
bool FPS_GT511C3::GetImage(bool patched)
732735
{
733736
if (UseSerialDebug) Serial.println("FPS - GetImage");
734-
Command_Packet* cp = new Command_Packet();
735-
cp->Command = Command_Packet::Commands::GetImage;
736-
uint8_t* packetbytes = cp->GetPacketBytes();
737-
delete cp;
738-
SendCommand(packetbytes, 12);
737+
Command_Packet* cp = new Command_Packet();
738+
cp->Command = Command_Packet::Commands::GetImage;
739+
uint8_t* packetbytes = cp->GetPacketBytes();
740+
delete cp;
741+
SendCommand(packetbytes, 12);
739742
delete packetbytes;
740-
Response_Packet* rp = GetResponse();
741-
bool retval = rp->ACK;
742-
delete rp;
743-
GetData(52116+6);
743+
Response_Packet* rp = GetResponse();
744+
bool retval = rp->ACK;
745+
delete rp;
746+
747+
if (!patched) GetData(52116+6);
748+
else
749+
{
750+
// Alright, for some reason, in my GT-511C3, there are around 15000 trash bytes being sent
751+
// before the actual image is sent. The actual number is random, but the image will come
752+
// after a long block of empty bytes. Not only that, the resolution of the image is actually
753+
// 232x139 (maybe taller) and not whatever the documentation says. This wasn't fun to debug.
754+
for (uint16_t i = 0; i<10000; i++) // This goes past the initial non-zero trash block
755+
{
756+
while(!_serial.available()) delay(10);
757+
_serial.read();
758+
}
759+
while(_serial.peek() <= 0) _serial.read(); // This looks for the actual first byte of image data
760+
761+
for(uint16_t i = 0; i<32248; i++) // Bytes for a 232x139 bitmap 8-bit image
762+
{
763+
while(!_serial.available()) delay(10);
764+
Serial.write((uint8_t)_serial.read());
765+
}
766+
}
744767
return retval;
745768
}
746769

src/FPS_GT511C3.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,10 @@ class FPS_GT511C3
301301
bool CaptureFinger(bool highquality);
302302

303303
// Gets an image that is 258x202 (52116 bytes + 2 bytes checksum) and sends it over serial
304+
// WARNING: The documentation is totally wrong (at least in GT-511C3). Check implementation comments.
304305
// Returns: True (device confirming download)
305-
bool GetImage();
306+
// Parameter: true to ignore the documentation and get valid image data.
307+
bool GetImage(bool patched = false);
306308

307309
// Gets an image that is qvga 160x120 (19200 bytes + 2 bytes checksum) and sends it over serial
308310
// Returns: True (device confirming download)

0 commit comments

Comments
 (0)