Merge pull request #1251 from MattiasBuelens/cooja-cfs-file-size
Cooja: Track CFS file size
This commit is contained in:
commit
bab413b824
2 changed files with 16 additions and 6 deletions
|
@ -50,6 +50,7 @@ const struct simInterface cfs_interface;
|
||||||
// COOJA variables
|
// COOJA variables
|
||||||
#define CFS_BUF_SIZE 4000 /* Configure CFS size here and in ContikiCFS.java */
|
#define CFS_BUF_SIZE 4000 /* Configure CFS size here and in ContikiCFS.java */
|
||||||
char simCFSData[CFS_BUF_SIZE] = { 0 };
|
char simCFSData[CFS_BUF_SIZE] = { 0 };
|
||||||
|
int simCFSSize = 0;
|
||||||
char simCFSChanged = 0;
|
char simCFSChanged = 0;
|
||||||
int simCFSRead = 0;
|
int simCFSRead = 0;
|
||||||
int simCFSWritten = 0;
|
int simCFSWritten = 0;
|
||||||
|
@ -61,10 +62,14 @@ cfs_open(const char *n, int f)
|
||||||
if(file.flag == FLAG_FILE_CLOSED) {
|
if(file.flag == FLAG_FILE_CLOSED) {
|
||||||
file.flag = FLAG_FILE_OPEN;
|
file.flag = FLAG_FILE_OPEN;
|
||||||
file.access = f;
|
file.access = f;
|
||||||
|
file.fileptr = 0;
|
||||||
|
file.endptr = simCFSSize;
|
||||||
|
if(f & CFS_WRITE) {
|
||||||
if(f & CFS_APPEND) {
|
if(f & CFS_APPEND) {
|
||||||
file.fileptr = file.endptr;
|
file.fileptr = file.endptr;
|
||||||
} else {
|
} else {
|
||||||
file.fileptr = 0;
|
file.endptr = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,6 +115,9 @@ cfs_write(int f, const void *buf, unsigned int len)
|
||||||
if(file.fileptr > file.endptr) {
|
if(file.fileptr > file.endptr) {
|
||||||
file.endptr = file.fileptr;
|
file.endptr = file.fileptr;
|
||||||
}
|
}
|
||||||
|
if(file.fileptr > simCFSSize) {
|
||||||
|
simCFSSize = file.fileptr;
|
||||||
|
}
|
||||||
return len;
|
return len;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -120,6 +120,7 @@ public class ContikiCFS extends MoteInterface implements ContikiMoteInterface, P
|
||||||
}
|
}
|
||||||
|
|
||||||
moteMem.setByteArray("simCFSData", data);
|
moteMem.setByteArray("simCFSData", data);
|
||||||
|
moteMem.setIntValueOf("simCFSSize", data.length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,8 @@ public class ContikiCFS extends MoteInterface implements ContikiMoteInterface, P
|
||||||
* @return Filesystem data
|
* @return Filesystem data
|
||||||
*/
|
*/
|
||||||
public byte[] getFilesystemData() {
|
public byte[] getFilesystemData() {
|
||||||
return moteMem.getByteArray("simCFSData", FILESYSTEM_SIZE);
|
int size = moteMem.getIntValueOf("simCFSSize");
|
||||||
|
return moteMem.getByteArray("simCFSData", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue