Hello
im designing a wireless-camera based device in which I have to receive a "string" from a cmucam3 camera and send it to a pic18 microcontroller using mica2. to check if my program works I want to compare a "string" received from the camera and blink the LEDs accordingly !! yellow if its equal and red if not!! my program is always blinking red !! and I think its not able to compare the string !! can you please help me !! how can I handle strings in tinyos !!! and also I don't really care about crc...etc hence im using bytecomm to sends only bytes over the air not packets!! whereas the Mcontroller is expecting a "string" !! can I do that !!
any hint will be really appretiated
here is my codes
for the sender:
module SM {
provides {
interface StdControl;
}
uses {
provides {
interface StdControl;
}
uses {
interface HPLUART;
interface StdControl as UartControl;
interface Leds;
interface ByteComm;
async command result_t Setbaud(uint32_t baud_rate);
}
}
implementation {
interface StdControl as UartControl;
interface Leds;
interface ByteComm;
async command result_t Setbaud(uint32_t baud_rate);
}
}
implementation {
nx_uint8_t reading;
// display is module static function
result_t display(uint8_t value)
{
if (value==75) call Leds.yellowOn();
else if (value!=75) call Leds.redOn();
result_t display(uint8_t value)
{
if (value==75) call Leds.yellowOn();
else if (value!=75) call Leds.redOn();
return SUCCESS;
}
/**
* Initialize the components.
*
* @return Always returns <code>SUCCESS</code>
**/
command result_t StdControl.init() {
call Leds.init();
call Leds.redOff();
call Leds.yellowOff();
call Leds.greenOff();
call UartControl.init();
* Initialize the components.
*
* @return Always returns <code>SUCCESS</code>
**/
command result_t StdControl.init() {
call Leds.init();
call Leds.redOff();
call Leds.yellowOff();
call Leds.greenOff();
call UartControl.init();
return SUCCESS;
}
command result_t StdControl.start() {
call HPLUART.init();
call Setbaud((uint32_t)115200);
call ByteComm.txByte('\xFF');
call HPLUART.init();
call Setbaud((uint32_t)115200);
call ByteComm.txByte('\xFF');
return SUCCESS;
}
command result_t StdControl.stop() {
call UartControl.stop();
call HPLUART.stop();
return SUCCESS;
}
}
command result_t StdControl.stop() {
call UartControl.stop();
call HPLUART.stop();
return SUCCESS;
}
async event result_t HPLUART.get(uint8_t data){
atomic {
data = ""> }
display(data);
atomic {
data = ""> }
display(data);
return SUCCESS;
}
}
async event result_t ByteComm.txByteReady(bool success){
return SUCCESS;
}
async event result_t ByteComm.txDone(){
return SUCCESS;
}
async event result_t HPLUART.putDone(){
return SUCCESS;
}
async event result_t ByteComm.rxByteReady(uint8_t data, bool error, uint16_t strength){
return SUCCESS;
}
return SUCCESS;
}
}
and the configuration:
configuration S {
}
implementation {
components Main, SM, LedsC, HPLUARTC, HPLUART0M, UARTM, UART;
}
implementation {
components Main, SM, LedsC, HPLUARTC, HPLUART0M, UARTM, UART;
Main.StdControl -> SM.StdControl;
SM.Setbaud -> HPLUART0M.Setbaud;
SM.HPLUART -> HPLUARTC;
SM.ByteComm -> UARTM.ByteComm;
SM.ByteComm -> UART;
SM.UartControl -> UART;
SM.HPLUART -> HPLUARTC;
SM.ByteComm -> UARTM.ByteComm;
SM.ByteComm -> UART;
SM.UartControl -> UART;
SM.Leds -> LedsC.Leds;
}
and reciever :
module RM {
provides {
interface StdControl;
}
uses {
provides {
interface StdControl;
}
uses {
interface HPLUART;
interface StdControl as UartControl;
interface Leds;
interface ByteComm;
async command result_t Setbaud(uint32_t baud_rate);
}
}
implementation {
interface StdControl as UartControl;
interface Leds;
interface ByteComm;
async command result_t Setbaud(uint32_t baud_rate);
}
}
implementation {
// display is module static function
result_t display(uint8_t value)
{
if (value==0x01) call Leds.yellowOn();
else call Leds.greenOn();
result_t display(uint8_t value)
{
if (value==0x01) call Leds.yellowOn();
else call Leds.greenOn();
return SUCCESS;
}
}
/**
* Initialize the components.
*
* @return Always returns <code>SUCCESS</code>
**/
command result_t StdControl.init() {
call Leds.init();
call Leds.redOff();
call Leds.yellowOff();
call Leds.greenOff();
call UartControl.init();
* Initialize the components.
*
* @return Always returns <code>SUCCESS</code>
**/
command result_t StdControl.init() {
call Leds.init();
call Leds.redOff();
call Leds.yellowOff();
call Leds.greenOff();
call UartControl.init();
return SUCCESS;
}
command result_t StdControl.start() {
call HPLUART.init();
call Setbaud((uint32_t)115200);
return SUCCESS;
}
command result_t StdControl.stop() {
call UartControl.stop();
call HPLUART.init();
call Setbaud((uint32_t)115200);
return SUCCESS;
}
command result_t StdControl.stop() {
call UartControl.stop();
call HPLUART.stop();
return SUCCESS;
return SUCCESS;
}
async event result_t HPLUART.get(uint8_t data){
return SUCCESS;
}
async event result_t ByteComm.rxByteReady(uint8_t data, bool error, uint16_t strength){
call HPLUART.put(data);
display(data);
return SUCCESS;
}
async event result_t HPLUART.putDone(){
call HPLUART.put(data);
display(data);
return SUCCESS;
}
async event result_t HPLUART.putDone(){
return SUCCESS;
}
async event result_t ByteComm.txByteReady(bool success){
return SUCCESS;
}
async event result_t ByteComm.txDone(){
return SUCCESS;
}
}
async event result_t ByteComm.txByteReady(bool success){
return SUCCESS;
}
async event result_t ByteComm.txDone(){
return SUCCESS;
}
}
and configuration:
configuration R {
}
implementation {
components Main, RM, LedsC, HPLUARTC, HPLUART0M, UARTM, UART;
}
implementation {
components Main, RM, LedsC, HPLUARTC, HPLUART0M, UARTM, UART;
Main.StdControl -> RM.StdControl;
RM.Setbaud -> HPLUART0M.Setbaud;
RM.HPLUART -> HPLUARTC;
RM.ByteComm -> UARTM.ByteComm;
RM.ByteComm -> UART;
RM.UartControl -> UART;
RM.HPLUART -> HPLUARTC;
RM.ByteComm -> UARTM.ByteComm;
RM.ByteComm -> UART;
RM.UartControl -> UART;
RM.Leds -> LedsC.Leds;
}
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
