Hi everybody,
I would like to thank the people who helped me out with my problem with Tymo,
though I don't have the time to try it again for now. In fact, I have a more
urgent problem right now : I don't understand how to change the amp gain of the
magnetometer.
I know I have to use those 2 functions ( gainAdjustX() and
gainAdjustY() ) , and 2 events ( gainAdjustXDone() and gainAdjustYDone() ), but
it's not working like it should.
This is my simple test code with adjustment on X-axis only :
-------------- CONFIG ------------------
#include "XMTS300.h"
#include "mts300.h"
configuration TestMts300C
{
}
implementation
{
components MainC, TestMts300P, LedsC, NoLedsC;
components new TimerMilliC() as MTS300Timer;
// sensorboard devices
components new SensorMts300C();
components new MagXC() as MagX;
TestMts300P -> MainC.Boot;
TestMts300P.MTS300Timer -> MTS300Timer;
TestMts300P.Leds -> LedsC;
TestMts300P.MagX -> SensorMts300C.MagX;
TestMts300P.MagY -> SensorMts300C.MagY;
TestMts300P.Setting -> MagX;
}
------------ MODULE ---------------
#include "Timer.h"
#include "XMTS300.h"
#include "mts300.h"
module TestMts300P
{
uses
{
interface Leds;
interface Boot;
interface Timer<TMilli> as MTS300Timer;
interface Read<uint16_t> as MagX; //!< magnetometer sensor
interface Read<uint16_t> as MagY; //!< magnetometer sensor
interface Mag as Setting;
}
}
implementation
{
Mts300Msg* pMsg;
event void Boot.booted()
{
call MTS300Timer.startPeriodic(1000);
}
event void MTS300Timer.fired()
{
call MagX.read();
return ;
}
task void adjustGain()
{
atomic
{
if(call Setting.gainAdjustX(128) == SUCCESS)
call Leds.led1On();
else
call Leds.led2Toggle();
//if(call Setting.gainAdjustY(128) == SUCCESS)
// call Leds.led2On();
}
}
/**
* MagX data read
*
*/
event void MagX.readDone(error_t result, uint16_t data)
{
if (result == SUCCESS)
{
pMsg->magX = data;
}
else
{
pMsg->magX = 0;
}
call MagY.read();
}
/**
* MagY data read
*
*/
event void MagY.readDone(error_t result, uint16_t data)
{
if (result == SUCCESS)
{
pMsg->magY = data;
}
else
{
pMsg->magY = 0;
}
post adjustGain();
}
event error_t Setting.gainAdjustXDone(bool result)
{
call Leds.led1Off();
return SUCCESS;
}
event error_t Setting.gainAdjustYDone(bool result)
{
//call Leds.led2Off();
return SUCCESS;
}
// end of the implementation
}
When I compile I got those warnings :
/opt/tinyos-2.x/tos/sensorboards/mts300/MagP.nc:83: warning: `Mag.gainAdjustXDon
e' called asynchronously from `I2CPacket.writeDone'
/opt/tinyos-2.x/tos/sensorboards/mts300/MagP.nc:87: warning: `Mag.gainAdjustYDon
e' called asynchronously from `I2CPacket.writeDone'
When I start the Mote, the led1 turn on, showing that the call of gainAdjustX
was successful. But the led1 never turn off and the led2 is continously
toggling. So it seems that only the first call of gainAdjustX() is OK, and that
the event "error_t Setting.gainAdjustXDone(bool result)" is never called.
However, the magnetometer is working properly, cause I can get the values on my
PC (by radio). I have 5 MTS310 boards, and 5 IRIS motes and I tried several
combinations, the result is the same, so I guess we can exclude a hardware
problem.
I spent 2 days trying to work it out, in vain, so if you could help me a
little... it would be great =)
Thank you all,
Raphael
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help