Skip to content

Commit fe6295e

Browse files
committed
Implemented multi-byte read in File::read of Bridge library.
1 parent e5e9d53 commit fe6295e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

libraries/Bridge/src/FileIO.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,21 @@ int File::available() {
137137
void File::flush() {
138138
}
139139

140-
//int read(void *buf, uint16_t nbyte)
140+
int File::read(void *buff, uint16_t nbyte) {
141+
uint16_t n = 0;
142+
uint8_t *p = reinterpret_cast<uint8_t *>(buff);
143+
while (n < nbyte) {
144+
if (buffered == 0) {
145+
doBuffer();
146+
if (buffered == 0)
147+
break;
148+
}
149+
*p++ = buffer[readPos++];
150+
buffered--;
151+
n++;
152+
}
153+
return n;
154+
}
141155

142156
uint32_t File::size() {
143157
if (bridge.getBridgeVersion() < 101)

0 commit comments

Comments
 (0)