@@ -185,8 +185,14 @@ int ECC508Class::readSlot(int slot, byte data[], int length)
185
185
return 0 ;
186
186
}
187
187
188
- for (int i = 0 ; i < length; i += 4 ) {
189
- if (!read (2 , addressForSlotOffset (slot, i), &data[i], 4 )) {
188
+ int chunkSize = 32 ;
189
+
190
+ for (int i = 0 ; i < length; i += chunkSize) {
191
+ if ((length - i) < 32 ) {
192
+ chunkSize = 4 ;
193
+ }
194
+
195
+ if (!read (2 , addressForSlotOffset (slot, i), &data[i], chunkSize)) {
190
196
return 0 ;
191
197
}
192
198
}
@@ -204,8 +210,14 @@ int ECC508Class::writeSlot(int slot, const byte data[], int length)
204
210
return 0 ;
205
211
}
206
212
207
- for (int i = 0 ; i < length; i += 4 ) {
208
- if (!write (2 , addressForSlotOffset (slot, i), &data[i], 4 )) {
213
+ int chunkSize = 32 ;
214
+
215
+ for (int i = 0 ; i < length; i += chunkSize) {
216
+ if ((length - i) < 32 ) {
217
+ chunkSize = 4 ;
218
+ }
219
+
220
+ if (!write (2 , addressForSlotOffset (slot, i), &data[i], chunkSize)) {
209
221
return 0 ;
210
222
}
211
223
}
@@ -440,7 +452,7 @@ int ECC508Class::read(int zone, int address, byte buffer[], int length)
440
452
return 0 ;
441
453
}
442
454
443
- delay (1 );
455
+ delay (2 );
444
456
445
457
if (!receiveResponse (buffer, length)) {
446
458
return 0 ;
@@ -550,7 +562,7 @@ int ECC508Class::sendCommand(uint8_t opcode, uint8_t param1, uint16_t param2, co
550
562
551
563
int ECC508Class::receiveResponse (void * response, size_t length)
552
564
{
553
- int retries = 25 ;
565
+ int retries = 20 ;
554
566
int responseSize = length + 3 ; // 1 for length header, 2 for CRC
555
567
byte responseBuffer[responseSize];
556
568
0 commit comments