MCPcopy Create free account
hub / github.com/andysworkshop/stm32plus / sendFile

Method sendFile

examples/fatfs_reader/fatfs_reader.cpp:85–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 */
84
85 void sendFile(const char *filename) {
86
87 scoped_ptr<File> file;
88 char buffer[256];
89
90 // open the file - we own the file pointer that comes back upon success and
91 // we must remember to delete it when we're finished
92
93 if(!_fs->openFile(filename,file.address()))
94 error();
95
96 // declare a file reader to read lines from the file and also a
97 // UsartPollingOutputStream for convenient output to the USART
98
99 FileReader reader(*file);
100 UsartPollingOutputStream output(*_usart);
101
102 while(reader.available()) {
103
104 // read the next line and send to the USART
105
106 if(!reader.readLine(buffer,sizeof(buffer)))
107 error();
108
109 output << buffer << "\r\n";
110 }
111 }
112
113
114 /*

Callers

nothing calls this directly

Calls 4

readLineMethod · 0.80
openFileMethod · 0.45
addressMethod · 0.45
availableMethod · 0.45

Tested by

no test coverage detected