Hi all,
I want to control the DAC of my telosb mote using commands from the
computer through the USB port. For that, I've programmed an application
which receives a message with two fields: uint8_t for the command and
uint16_t for the value we want to set the DAC to.
There are two commands: set (1), with a value, to set the DAC, and show,
without a value, to see to which value the DAC is set to (when issuing a
set command, the mote returns the DAC value as well).
On the computer side, the commands are issued using a small java
application:
java Dimmer set X
java Dimmer show
The problem is that the value field (uint16_t) is not recognised: I will
issue java Dimmer set 10 ten times and each time I will get a different
DAC output and a different return value from the mote. I have tried to
modify my message type and have the value field as a uint8_t. In this
way, issuing a set command from 0 to 256 will give me right values.
Above that, it doesn't seem to work anymore.
Can anyone enlighten me a little on what I am doing wrong? It'd be much
appreciated.
Below I include the relevant code.
Thanks,
- Jose.
// DimmerControlM.nc (on the mote)
// DimmerControlMSG has two fields: todo (uint8_t) and value (uint16_t)
task void sendMsg(){
struct DimmerControlMSG* sen;
sen = (struct DimmerControlMSG *)outw.data;
sen->value = value;
call SendMsg.send( TOS_UART_ADDR, sizeof(struct DimmerControlMSG),
&outw);
}
event TOS_MsgPtr ReceiveMsg.receive( TOS_MsgPtr inw ){
struct DimmerControlMSG* rec;
rec = (struct DimmerControlMSG *)inw->data;
if( rec->todo & 0x1 ) {
value=rec->value;
if(call DAC.output(value) == SUCCESS)
call Leds.redToggle();
}
post sendMsg();
return inw;
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help