Hi Philip,
I still feel very difficult to finish this project. The main difficulty is
how to write component AccelStreamC. I feel how to make a interface between
ReadStream and Read as AdcReadClient only provide interface Read.I will
explain in next.
I define the packet name as 'GetAccel'. According to your method, I use
interface ReadStream in 'GetAccelC.nc'. It was initialized in:
event void Boot.booted() {
...
call ReadStream.postBuffer(buf, BUF_SIZE);
}
Read was started at timer event as:
event void Timer.fired() {
if (call ReadStream.read(1) != SUCCESS)
report_problem();
}
Read data as:
event void ReadStream.bufferDone( error_t result,
uint16_t* buffer, uint16_t count )
{
if (result != SUCCESS)
{
buffer[0] = 0xffff;
buffer[1] = 0xffff;
report_problem();
}
local.readings[0] = buffer[0];
local.readings[1] = buffer[1];
}
I use DemoSensorStreamC in GetAccelAppC as:
components new DemoSensorStreamC() as Sensor;
GetAccelC.ReadStream -> Sensor;
The DemoSensorStreamC in my MTS310 folder is written as:
generic configuration DemoSensorStreamC() {
provides interface ReadStream<uint16_t>;
}
implementation {
components new AccelStreamC() as SensorStream;
ReadStream = SensorStream;
}
But I feel difficult to write AccelStreamC. it is:
#include "mts300.h"
generic configuration AccelStreamC()
{
provides interface ReadStream<uint16_t>;
}
implementation {
enum {
ID = unique(UQ_ACCEL_RESOURCE)
};
components AccelReadP,AccelConfigP, new AdcReadClientC() as AdcX,new
AdcReadClientC() as AdcY;
ReadStream = AccelReadP.ReadX[ID]; //compile error here: no match
AccelReadP.ActualX[ID] -> AdcX;
AdcX.Atm128AdcConfig -> AccelConfigP.ConfigX;
ReadStream = AccelReadP.ReadY[ID]; //compile error here: no match
AccelReadP.ActualY[ID] -> AdcY;
AdcY.Atm128AdcConfig -> AccelConfigP.ConfigY;
}
Beside this, every AccelConfigP make WarmupTimer, so in my AccelStreamC, it
seems the sensor was Warmup again when I want to read Y axis.
Could you give more detail direction?
Regards,
Fangming
On 5/13/07, Philip Levis <[EMAIL PROTECTED]> wrote:
On May 13, 2007, at 5:01 PM, Hugo Sousa wrote:
> Hi Fangming,
>
> You don't have to wait for a readDone() to read the other, you can
> call both Reads because accelconfigp has an arbiter that prevents
> simultaneous access. It is also better that you call them both
> because that way the sensor is not turned off between the two
> readings, doubling your maximum sample frequency. That's 60Hz, not
> quite the 64Hz you want
This is correct; in T2, the best way to sample multiple sensors is to
request all of them at once. In this case, "best" means "most power
efficient" and "fastest." Basically, by issuing a bunch of parallel
calls to the OS, you give it the flexibility to automatically
schedule I/O as efficiently as possible.
Phil
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help