MCPcopy Create free account
hub / github.com/SmingHub/Sming / readWriteTest

Function readWriteTest

samples/SDCard/app/application.cpp:151–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151void readWriteTest()
152{
153 //2. Open file, write a few bytes, close reopen and read
154 Serial.println(_F("2. Open file \"test.txt\" and write some data..."));
155 FIL file;
156 FRESULT fRes = f_open(&file, "test.txt", FA_WRITE | FA_CREATE_ALWAYS);
157
158 if(fRes == FR_OK) {
159 //you can write directly
160 uint32_t actual = 0;
161 f_write(&file, "hello ", 5, &actual);
162
163 //or using printf for convenience
164 f_printf(&file, _F(" has %d letters\r\n"), actual);
165
166 if(actual != 5) {
167 Serial << _F("Only written ") << actual << _F(" bytes") << endl;
168 }
169 f_close(&file);
170 } else {
171 Serial << _F("fopen FAIL: ") << fRes << endl;
172 }
173}
174
175void readTest()
176{

Callers 1

runTestFunction · 0.85

Calls 5

f_openFunction · 0.85
f_writeFunction · 0.85
f_printfFunction · 0.85
f_closeFunction · 0.85
printlnMethod · 0.80

Tested by

no test coverage detected