On Wednesday 12 September 2007 09:32:00 am Mayur Maheshwari wrote:
> Steve,
>
> Your response was of great help. Let me know if you can provide some
> pointers on how this could be done using the BSL or share the part of your
> code where the mote is reset if 3 "write failed" events trigger
> consecutively.
You can grab the logic from the tos-bsl program that comes in the tinyos-tools
package and installs into /usr/bin. I've attached a C snippet that I used.
Use the rest_gwbs() function. It's a poor substutue for solving the real
problem, but is an OK stopgap for development or testing, anyway...
Cheers,
Steve
>
> Thanks once again
> Mayur
>
> On 9/10/07, Steve McKown <[EMAIL PROTECTED]> wrote:
> > On Sunday 02 September 2007 12:59:44 pm Mayur Maheshwari wrote:
> > > Hi Romain
> > >
> > > This is regarding the problem which you faced while sending the data to
> >
> > the
> >
> > > BaseStation from SerialForwarder(SF) when it continuously gives the
> >
> > "Write
> >
> > > Failed" event. Let me know if you got any success with that.
> > >
> > > I did few things and later found that the problem lies in the mote:
> > >
> > > 1. I stopped the SF, removed the modules controlling my mote from the
> >
> > linux
> >
> > > kernel i.e. usbserial and ftdi-sio while the mote is still plugged in.
> > > I restarted all the components and the sitaution was the same. However,
> >
> > the
> >
> > > mote was getting continous power from the USB all the time.
> > >
> > > 2. While the SF was running and "Write Failed" event coming up on every
> > > attempt to send data, I pushed the "reset" button on the telosB. This
> >
> > was a
> >
> > > mild success as the SF app was able to send the data after this.
> > >
> > > Right now I am thinking in a direction that the mote should stop and
> > > restart the radio and the UART if such an event occurs. This is not a
> >
> > good
> >
> > > technique but does help in automating the reset scenario.
> >
> > I also see this on our own msp430-based mote design. I tend to suspect
> > clock
> > drift of the DCO taking the baud rate out of spec. I've seen similar
> > behavior on read events as well, and in all cases so far, resetting the
> > mote
> > corrects the problem for some period of time. To work around this in the
> > mean time, our base station code resets the attached mote (using BSL) if
> > we
> > see 3 of these communications errors in a row.
> >
> > If this is the issue, then installing a crystal @ XT2 would solve the
> > problem.
> > We haven't had the time yet to try this out, but I'll report back if/when
> > we
> > ever do this.
void set_scl(int fd, int level)
{
unsigned int rts = TIOCM_RTS;
if (level)
ioctl(fd, TIOCMBIC, &rts);
else
ioctl(fd, TIOCMBIS, &rts);
//usleep(100);
}
void set_sda(int fd, int level)
{
unsigned int dtr = TIOCM_DTR;
if (level)
ioctl(fd, TIOCMBIC, &dtr);
else
ioctl(fd, TIOCMBIS, &dtr);
//usleep(100);
}
void i2c_start(int fd)
{
set_sda(fd, 1);
set_scl(fd, 1);
set_sda(fd, 0);
}
void i2c_stop(int fd)
{
set_sda(fd, 0);
set_scl(fd, 1);
set_sda(fd, 1);
}
void i2c_wbit(int fd, int bit)
{
set_scl(fd, 0);
set_sda(fd, bit);
usleep(2);
set_scl(fd, 1);
usleep(2);
set_scl(fd, 0);
}
void i2c_wbyte(int fd, int byte)
{
i2c_wbit(fd, byte & 0x80);
i2c_wbit(fd, byte & 0x40);
i2c_wbit(fd, byte & 0x20);
i2c_wbit(fd, byte & 0x10);
i2c_wbit(fd, byte & 0x08);
i2c_wbit(fd, byte & 0x04);
i2c_wbit(fd, byte & 0x02);
i2c_wbit(fd, byte & 0x01);
i2c_wbit(fd, 0 ); /* "acknowledge" */
}
void i2c_wcmd(int fd, int addr, int cmdbyte)
{
i2c_start(fd);
i2c_wbyte(fd, 0x90 | (addr << 1));
i2c_wbyte(fd, cmdbyte);
i2c_stop(fd);
}
void tmote_reset(int fd)
{
i2c_wcmd(fd, 0, 3);
i2c_wcmd(fd, 0, 2);
i2c_wcmd(fd, 0, 0);
usleep(250000); /* give MSP430's oscillator time to stabilize */
}
void reset_gwbs(serial_source src)
{
/* This is currently hardcoded to support the telos mote. The reset
* process is different for different motes. See the docs for tos-bsl.
* for more information.
*/
tmote_reset(serial_source_fd(src));
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help