2011年10月25日星期二

10.25

tinyos normal communication interface:

/opt/tinyos-2.1.1/tos/interfaces/Packet.nc

#include

interface Packet{
command void clear(message_t* msg);
command uint8_t payloadLength(message_t* msg);
command void setPayloadLength(message_t* msg, uint8_t len);
command uint8_t maxPayloadLength();
command void* getPayload(message_t* msg, uint8_t len);
}


---------------------------
/opt/tinyos-2.1.1/tos/types/message.h

#include "platform_message.h"

typedef nx_struct message_t {
nx_uint8_t header[sizeof(message_header_t)];
nx_uint8_t data[TOSH_DATA_LENGTH];
nx_uint8_t footer[sizeof(message_footer_t)];
nx_uint8_t metadata[sizeof(message_metadata_t)];
} message_t;


Send:no address interface for sending data

#include
#include

interface Send {


command error_t send(message_t* msg, uint8_t len);

command error_t cancel(message_t* msg);

event void sendDone(message_t* msg, error_t error);

command uint8_t maxPayloadLength();

command void* getPayload(message_t* msg, uint8_t len);
}

Receive:receive interface for message

#include
#include

interface Receive {


event message_t* receive(message_t* msg, void* payload, uint8_t len);

}

PacketAcknowledgements:

interface PacketAcknowledgements {


async command error_t requestAck( message_t* msg );

async command error_t noAck( message_t* msg );

async command bool wasAcked(message_t* msg);

}

async:

RadioTimeStamping:
interface RadioTimeStamping
{

async event void transmittedSFD( uint16_t time, message_t* p_msg );

async event void receivedSFD( uint16_t time );
}

------------------------------------
TestSerial.java do the work of serial communication.

But in android platform, there is no software environment to control telosb.
I need to learn how android get the data from serial port. It should be NDK and JNI development and produce a lib for the upper app to call it.

I bought IOIO today and hope it work well for my project.


没有评论: