Hi All,
I am writing a small application in tinyos1.x. I have installed
XUBUNTOS on a VMware server console. I am trying to use FileRead.nc,
an interface in FS folder in tos\library....with its implementation in
memread2.nc file (attached in module files folder).
Once i compile the configuration file named FileOpenread.nc,
using make pc...it is compiled without any error ,,,and similarly if
compiled for make mica2,,,it again shows no errors and is compiled
successfully.
The problem is that once i run this application.. DBG=temp,all
./build/pc/main.exe 1....
It shows the DBG output ..for FileRead.open command ..by returning
success..
Now this happens ,,even if there is no file..so the
if(FileRead.open("mem.txt"==SUCCESS) is always true,,,and i
immediately get a false condition for
..if(FileRead.read(buffer,256)==SUCCESS)
{dbg(DBG_TEMP,"File read success");
return SUCCESS}
else
{dbg(DBG_TEMP,"Failed to read");
kindly guide me if there is anything wrong with my configuration file
(FileOpenread.nc) or module file
*Configuration File*
includes Matchbox;
configuration FileOpenread {}
implementation
{
components Main, Matchbox, Memread2, NoDebug;
Main.StdControl -> Memread2.StdControl;
Main.StdControl -> Matchbox.StdControl;
Matchbox.ready -> Memread2.matchboxReady;
Memread2.FileRead -> Matchbox.FileRead[unique("FileRead")];
Matchbox.Debug -> NoDebug;
}
*Module File*
module Memread2 {
provides
{
interface StdControl;
event result_t matchboxReady();}
uses
{ interface FileRead; }
}
implementation {
command result_t StdControl.init() {return SUCCESS;}
command result_t StdControl.start() {return SUCCESS;}
command result_t StdControl.stop() {return SUCCESS;}
event result_t matchboxReady()
{ uint8_t buffer[256];
if ((call FileRead.open("mem.txt")) == SUCCESS)
{ dbg(DBG_TEMP," success in file opening \n");
/* return SUCCESS;*/
if ((call FileRead.read(buffer,256))==SUCCESS)
{ dbg(DBG_TEMP,"fileread success\n");
dbg(DBG_TEMP,"The Contents are %i\n, %d\n",buffer);
return SUCCESS;}
else {dbg(DBG_TEMP,"Failed to read \n");
return FAIL; }
}
else {dbg(DBG_TEMP,"Failed to open \n");
return FAIL; }
}
event result_t FileRead.opened(fileresult_t result)
{return SUCCESS;}
event result_t FileRead.readDone(void *buf, filesize_t
nRead,fileresult_t result)
{return SUCCESS;}
event result_t FileRead.remaining(filesize_t n, fileresult_t result)
{return SUCCESS;}
}
Is there any other way to open and read the contents of a text
file..and displaying the contents in console or another output
file?..I need to do it for my research assignment...kindly someone do
help me..
I shall be really grateful,
Imran Mak
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help