读取SD卡文件的字节数组 – fileReadBytes
读取字节数组
定义
int fileReadBytes(string filePath , int offset , byte array[ ] , int start , int len);
参数
- filePath:
文件路径
- offset:
文件中的偏移
- array:
保存读取数据的字节数组
- start:
保存读取的数据的起始位置
- len:
要读取的数据长度
备注
如果offset小于0,那么不执行读取;
返回值
0表示成功。
示例
byte a[10];//定义一个长度为10的数组a
// 读取SD_WR文件夹下test.bin 中的字节数组,偏移为0,数组名a,起始位置0,长度为1个字节
fileReadBytes("SD_WR/test.bin",0,a,0,1);
// 在 num3.val 上显示读取的数据
num3.val = a[0];
//读取10个字节,
fileReadBytes("SD_WR/test.bin",0,a,0,10);
//拖入日志控件log1,控件属性中勾选 hexMd,则可打印显示hex数据
log1.addBytes(a,0,10);