Read from file

Description

Read file contents from flash chip.The result is sending back to the serial port.

Note: This function can't run in commands set.

Usage:

Direct:

"fREADfilename ",following with 3 bytes MSB of start pointer from the begin of file, then 3 bytes MSB of data length to be read

Arduino:

void readFile(const char * fnameuint32_t start,uint32_t length)

C:

void Digole_readFile(const char * fname, uint24_t start,uint24_t length)

 

Parameters:

fname

Specify the file name in flash memory.

start

 The pointer of start to read in file, count from the beginning of the file. 3 bytes value, MSB first.

 length 

The length of bytes want to read. If don't have enough bytes in file (file size-start less then length), then only actual bytes of data read out.

Example (Arduino):

unsigned char data[64];

mydisp.readFile("hello.txt",512,64);  //read 64 bytes from file of hello.txt, begin from the 512 byte

//read out the 64 bytes data from serial port

mydisp.cleanBuffer(); //clean the receiving buffer

for(char i=0;i<64;i++){
     data[i]=mydisp.read1();

Example(direct)

unsigned char data[64];
serial.writeString("fREADhello.txt ");
serial.write(0);  //MSB of start
serial.write(2);
serial.write(0);  //LSB of start
serial.write(0);  //MSB of length
serial.write(0);
serial.write(64);  //LSB of length
for(char i=0;i<64;i++){
     data[i]=serial.read();

Changelog

Version Description
V7 function was added.

See Also

Switch flash modes