Skip to content

Commit d831fcd

Browse files
committed
Switch to 64 bytes packets, since that's the default serial buffer size.
1 parent a02d648 commit d831fcd

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/FPS_GT511C3.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,16 @@ Data_Packet::Data_Packet(uint8_t* buffer)
229229
#endif
230230
}
231231

232-
// Get a data packet (128 bytes), calculate checksum and send it to serial
233-
void Data_Packet::GetData(uint8_t buffer[])
232+
// Get a data packet, calculate checksum and send it to serial
233+
void Data_Packet::GetData(uint8_t buffer[], uint16_t length)
234234
{
235-
for(uint16_t i = 0; i<128; i++) Serial.write(buffer[i]);
235+
for(uint16_t i = 0; i<length; i++) Serial.write(buffer[i]);
236236
#if FPS_DEBUG
237-
this->checksum = CalculateChecksum(buffer, 128);
237+
this->checksum = CalculateChecksum(buffer, length);
238238
#endif
239239
}
240240

241-
// Get the last data packet (<=128 bytes), calculate checksum, validate checksum received and send it to serial
241+
// Get the last data packet, calculate checksum, validate checksum received and send it to serial
242242
void Data_Packet::GetLastData(uint8_t buffer[], uint16_t length)
243243
{
244244
for(uint16_t i = 0; i<length; i++) Serial.write(buffer[i]);
@@ -1128,19 +1128,19 @@ void FPS_GT511C3::GetData(uint16_t length)
11281128
}
11291129
Data_Packet dp(firstdata);
11301130

1131-
uint16_t numberPacketsNeeded = (length-4) / 128;
1131+
uint16_t numberPacketsNeeded = (length-4) / 64;
11321132
bool smallLastPacket = false;
1133-
uint8_t lastPacketSize = (length-4) % 128;
1133+
uint8_t lastPacketSize = (length-4) % 64;
11341134
if(lastPacketSize != 0)
11351135
{
1136-
numberPacketsNeeded++;
1137-
smallLastPacket = true;
1136+
numberPacketsNeeded++;
1137+
smallLastPacket = true;
11381138
}
11391139

1140-
uint8_t data[128];
1140+
uint8_t data[64];
11411141
for (uint16_t packetCount=1; packetCount < numberPacketsNeeded; packetCount++)
11421142
{
1143-
for (uint8_t i=0; i < 128; i++)
1143+
for (uint8_t i=0; i < 64; i++)
11441144
{
11451145
while (_serial.available() == false) delay(1);
11461146
if(_serial.overflow())
@@ -1161,7 +1161,7 @@ void FPS_GT511C3::GetData(uint16_t length)
11611161
}
11621162
data[i]= (uint8_t) _serial.read();
11631163
}
1164-
dp.GetData(data);
1164+
dp.GetData(data, 64);
11651165
}
11661166

11671167
uint8_t lastdata[lastPacketSize];

src/FPS_GT511C3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class Data_Packet
163163
static const uint8_t DATA_DEVICE_ID_1 = 0x01; // Device ID Byte 1 (lesser byte) - theoretically never changes
164164
static const uint8_t DATA_DEVICE_ID_2 = 0x00; // Device ID Byte 2 (greater byte)
165165

166-
void GetData(uint8_t buffer[]);
166+
void GetData(uint8_t buffer[], uint16_t length);
167167
void GetLastData(uint8_t buffer[], uint16_t length);
168168
private:
169169
bool CheckParsing(uint8_t b, uint8_t propervalue, uint8_t alternatevalue, const char* varname);

0 commit comments

Comments
 (0)