mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-19 03:05:14 +00:00
Merge pull request #1251 from MattiasBuelens/cooja-cfs-file-size
Cooja: Track CFS file size
This commit is contained in:
commit
bab413b824
@ -50,6 +50,7 @@ const struct simInterface cfs_interface;
|
||||
// COOJA variables
|
||||
#define CFS_BUF_SIZE 4000 /* Configure CFS size here and in ContikiCFS.java */
|
||||
char simCFSData[CFS_BUF_SIZE] = { 0 };
|
||||
int simCFSSize = 0;
|
||||
char simCFSChanged = 0;
|
||||
int simCFSRead = 0;
|
||||
int simCFSWritten = 0;
|
||||
@ -61,11 +62,15 @@ cfs_open(const char *n, int f)
|
||||
if(file.flag == FLAG_FILE_CLOSED) {
|
||||
file.flag = FLAG_FILE_OPEN;
|
||||
file.access = f;
|
||||
if(f & CFS_APPEND) {
|
||||
file.fileptr = file.endptr;
|
||||
} else {
|
||||
file.fileptr = 0;
|
||||
}
|
||||
file.fileptr = 0;
|
||||
file.endptr = simCFSSize;
|
||||
if(f & CFS_WRITE) {
|
||||
if(f & CFS_APPEND) {
|
||||
file.fileptr = file.endptr;
|
||||
} else {
|
||||
file.endptr = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -110,6 +115,9 @@ cfs_write(int f, const void *buf, unsigned int len)
|
||||
if(file.fileptr > file.endptr) {
|
||||
file.endptr = file.fileptr;
|
||||
}
|
||||
if(file.fileptr > simCFSSize) {
|
||||
simCFSSize = file.fileptr;
|
||||
}
|
||||
return len;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -120,6 +120,7 @@ public class ContikiCFS extends MoteInterface implements ContikiMoteInterface, P
|
||||
}
|
||||
|
||||
moteMem.setByteArray("simCFSData", data);
|
||||
moteMem.setIntValueOf("simCFSSize", data.length);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -129,7 +130,8 @@ public class ContikiCFS extends MoteInterface implements ContikiMoteInterface, P
|
||||
* @return Filesystem data
|
||||
*/
|
||||
public byte[] getFilesystemData() {
|
||||
return moteMem.getByteArray("simCFSData", FILESYSTEM_SIZE);
|
||||
int size = moteMem.getIntValueOf("simCFSSize");
|
||||
return moteMem.getByteArray("simCFSData", size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user