Sensor
pythonでTwitterを弄ぶ
by kewi on 10 月.20, 2009, under Memo, Sensor, Study
まず必要なもののダウンロード
- Python Twitter
http://code.google.com/p/python-twitter/
(現在 0.6) - simplejson
http://pypi.python.org/pypi/simplejson
(現在 2.0.9)
とってきた圧縮ファイルをそれぞれ展開して
setup.py install
でインストール。
で、http://apiwiki.twitter.com/とか
http://static.unto.net/python-twitter/0.5/doc/twitter.html
def uploadMessageToTwitter(user, password, message) : api = twitter.Api(user,password) api.PostUpdate(message)
こんな感じでいいらしい。エラー処理は考えてない。
とりあえずセンサ出席アプリからこの関数を呼び出して、Twitterに上げることに成功。
こんな感じ
Syncノードでブロードキャストパケットを振り分ける
by kewi on 10 月.20, 2009, under Sensor, Study
Xsnifferを利用して、シンクノード上でパケットの中身を判別、シリアルポートに送るプログラムに変更。
・TOSBaseM.nc
module TOSBaseM {
provides interface StdControl;
uses {
interface StdControl as UARTControl;
interface BareSendMsg as UARTSend;
interface ReceiveMsg as UARTReceive;
interface TokenReceiveMsg as UARTTokenReceive;
interface StdControl as RadioControl;
interface BareSendMsg as RadioSend;
interface ReceiveMsg as RadioReceive;
interface Leds;
async command result_t Setbaud(uint32_t baud_rate);
#ifdef FLS_DEBUG
interface Timer;
#endif
}
}
implementation
{
enum {
QUEUE_SIZE = 15
};
enum {
TXFLAG_BUSY = 0x1,
TXFLAG_TOKEN = 0x2
};
TOS_Msg gRxBufPool[QUEUE_SIZE];
TOS_MsgPtr gRxBufPoolTbl[QUEUE_SIZE];
uint8_t gRxHeadIndex,gRxTailIndex;
TOS_Msg gTxBuf;
TOS_MsgPtr gpTxMsg;
uint8_t gTxPendingToken;
uint8_t gfTxFlags;
uint32_t time;
#define FLS_FIX
#ifdef FLS_FIX
uint8_t num_msgs_pending;
uint8_t radio_rcvd_task_flags;
#define RRT_ACTIVE 1 /* Waiting Senddone */
#define RRT_POSTED 2 /* Posted not yet active */
#endif
/*
command int checkPacketID(TOS_MsgPtr pMsg){
return 1;
}
*/
task void RadioRcvdTask() {
TOS_MsgPtr pMsg;
result_t Result;
uint32_t* t_val;
int flag=0;
uint8_t do_post;
dbg (DBG_USR1, "TOSBase forwarding Radio packet to UART\n");
#ifdef FLS_FIX
atomic {
radio_rcvd_task_flags &= ~RRT_POSTED;
}
TOSH_SET_YELLOW_LED_PIN();
if (num_msgs_pending == 0)
return;
#else
if(gRxTailIndex == gRxHeadIndex) return;
#endif
atomic {
pMsg = gRxBufPoolTbl[gRxTailIndex];
}
//AttendancePacket
if((pMsg->type==0/*Packet Type*/) && (pMsg->data[2] == 5/*Packet ID*/)){
Result = call UARTSend.send(pMsg);
if (Result != SUCCESS) {
//call Leds.yellowToggle();
}
else {
atomic{
gRxTailIndex++; gRxTailIndex %= QUEUE_SIZE;
#ifdef FLS_FIX
radio_rcvd_task_flags |= RRT_ACTIVE; /* Turned off in sendDone */
#endif
}
TOSH_CLR_GREEN_LED_PIN();
}
}
//Drop Packets
else{
atomic{
gRxTailIndex++; gRxTailIndex %= QUEUE_SIZE;
#ifdef FLS_FIX
radio_rcvd_task_flags |= RRT_ACTIVE; /* Turned off in sendDone */
#endif
}
TOSH_CLR_GREEN_LED_PIN();
#ifdef FLS_FIX
atomic {
radio_rcvd_task_flags &= ~RRT_ACTIVE; /* The sendDone has been signalled */
if ((--num_msgs_pending != 0) && !(radio_rcvd_task_flags & RRT_POSTED)) {
radio_rcvd_task_flags |= RRT_POSTED;
do_post = 1;
} else
do_post = 0;
}
if (do_post)
post RadioRcvdTask ();
#else
post RadioRcvdTask();
#endif /* FLS_FIX */
TOSH_SET_GREEN_LED_PIN();
}
}
task void UARTRcvdTask() {
result_t Result;
dbg (DBG_USR1, "TOSBase forwarding UART packet to Radio\n");
gpTxMsg->group = TOS_AM_GROUP;
Result = call RadioSend.send(gpTxMsg);
if (Result != SUCCESS) {
atomic gfTxFlags = 0;
}
else {
call Leds.redToggle();
}
}
task void SendAckTask() {
call UARTTokenReceive.ReflectToken(gTxPendingToken);
//call Leds.yellowToggle();
atomic {
gpTxMsg->length = 0;
gfTxFlags = 0;
}
}
command result_t StdControl.init() {
result_t ok1, ok2, ok3;
uint8_t i;
TOS_LOCAL_ADDRESS = 0xFF00; //make sure it doesn't ack
for (i = 0; i < QUEUE_SIZE; i++) {
gRxBufPool[i].length = 0;
gRxBufPoolTbl[i] = &amp;amp;amp;amp;gRxBufPool[i];
}
gRxHeadIndex = 0;
gRxTailIndex = 0;
gTxBuf.length = 0;
gpTxMsg = &amp;amp;amp;amp;gTxBuf;
gfTxFlags = 0;
ok1 = call UARTControl.init();
ok2 = call RadioControl.init();
ok3 = call Leds.init();
#ifdef FLS_FIX
num_msgs_pending = 0;
#endif
dbg(DBG_BOOT, "TOSBase initialized\n");
return rcombine3(ok1, ok2, ok3);
}
command result_t StdControl.start() {
result_t ok1, ok2;
ok1 = call UARTControl.start();
ok2 = call RadioControl.start();
call Setbaud((uint32_t)115200); //set baud rate to 11520 for XSniffer
#ifdef FLS_DEBUG
call Timer.start(TIMER_REPEAT,2000);
#endif
return rcombine(ok1, ok2);
}
command result_t StdControl.stop() {
result_t ok1, ok2;
ok1 = call UARTControl.stop();
ok2 = call RadioControl.stop();
#ifdef FLS_DEBUG
call Timer.stop();
#endif
return rcombine(ok1, ok2);
}
#ifdef FLS_DEBUG
event result_t Timer.fired () {
TOSH_SET_RED_LED_PIN(); /* Want to see if Radio is active */
TOSH_SET_YELLOW_LED_PIN();
return SUCCESS;
}
#endif
event TOS_MsgPtr RadioReceive.receive(TOS_MsgPtr Msg) {
TOS_MsgPtr pBuf;
dbg(DBG_USR1, "TOSBase received radio packet.\n");
if (Msg->crc)
{
/* Filter out messages by group id */
//if (Msg->group != TOS_AM_GROUP)
//return Msg;
atomic {
#ifdef FLS_FIX
if (num_msgs_pending == QUEUE_SIZE) {
pBuf = NULL; /* No more room to put stuff in q. */
} else
#endif /* FLS_FIX */
{
//Msg->data[0] = Msg->strength;
//Msg->data[1] = Msg->strength >> 8;
pBuf = gRxBufPoolTbl[gRxHeadIndex];
#ifdef not_required
if (pBuf->length == 0)
#endif /* not_required */
{ /* THIS CHECK is NOT REQURIED ** NARAYAN **/
gRxBufPoolTbl[gRxHeadIndex] = Msg;
gRxHeadIndex++; gRxHeadIndex %= QUEUE_SIZE;
#ifdef FLS_FIX
num_msgs_pending++;
#endif
}
#ifdef not_required
else
{
TOSH_CLR_YELLOW_LED_PIN();
pBuf = NULL;
}
#endif /* not_required */
}
#ifdef FLS_FIX
/*
* In case the send earlier had failed,
* we always post a new radiorcvd task(and always whenever there is
* one that is not active).
*/
TOSH_CLR_YELLOW_LED_PIN();
if ((radio_rcvd_task_flags &amp;amp;amp;amp; (RRT_POSTED|RRT_ACTIVE)) == 0) {
radio_rcvd_task_flags |= RRT_POSTED;
post RadioRcvdTask();
}
#endif
if (pBuf) {
#ifndef FLS_FIX
post RadioRcvdTask();
#endif
TOSH_SET_RED_LED_PIN();
}
else {
TOSH_CLR_RED_LED_PIN();
pBuf = Msg;
}
}
}
else {
pBuf = Msg;
}
return pBuf;
}
event TOS_MsgPtr UARTReceive.receive(TOS_MsgPtr Msg) {
TOS_MsgPtr pBuf;
dbg(DBG_USR1, "TOSBase received UART packet.\n");
atomic {
if (gfTxFlags &amp;amp;amp;amp; TXFLAG_BUSY) {
pBuf = NULL;
}
else {
pBuf = gpTxMsg;
gfTxFlags |= (TXFLAG_BUSY);
gpTxMsg = Msg;
}
}
if (pBuf == NULL) {
pBuf = Msg;
}
else {
post UARTRcvdTask();
}
return pBuf;
}
event TOS_MsgPtr UARTTokenReceive.receive(TOS_MsgPtr Msg, uint8_t Token) {
TOS_MsgPtr pBuf;
dbg(DBG_USR1, "TOSBase received UART token packet.\n");
atomic {
if (gfTxFlags &amp;amp;amp;amp; TXFLAG_BUSY) {
pBuf = NULL;
}
else {
pBuf = gpTxMsg;
gfTxFlags |= (TXFLAG_BUSY | TXFLAG_TOKEN);
gpTxMsg = Msg;
gTxPendingToken = Token;
}
}
if (pBuf == NULL) {
pBuf = Msg;
}
else {
post UARTRcvdTask();
}
return pBuf;
}
event result_t UARTSend.sendDone(TOS_MsgPtr Msg, result_t success) {
#ifdef FLS_FIX
uint8_t do_post;
atomic {
radio_rcvd_task_flags &amp;amp;amp;amp;= ~RRT_ACTIVE; /* The sendDone has been signalled */
if ((--num_msgs_pending != 0) &amp;amp;amp;amp;&amp;amp;amp;amp; !(radio_rcvd_task_flags &amp;amp;amp;amp; RRT_POSTED)) {
radio_rcvd_task_flags |= RRT_POSTED;
do_post = 1;
} else
do_post = 0;
}
if (do_post)
post RadioRcvdTask ();
#else
post RadioRcvdTask();
#endif /* FLS_FIX */
Msg->length = 0;
TOSH_SET_GREEN_LED_PIN();
return SUCCESS;
}
event result_t RadioSend.sendDone(TOS_MsgPtr Msg, result_t success) {
if ((gfTxFlags &amp;amp;amp;amp; TXFLAG_TOKEN)) {
if (success == SUCCESS) {
post SendAckTask();
}
}
else {
atomic {
gpTxMsg->length = 0;
gfTxFlags = 0;
}
}
return SUCCESS;
}
}
今回はセットしたパケットのTypeとIDで判別。
パケットの判別したい部分に合わせて適宜変更。
注意するところはパケットを破棄するときにも
RadioRcvdTask()をpostすること。
気付かずに何時間も悩んでしまった…。
#あ、なんかきけんなやつ(<とか>とか&とか)がおきかわったりしてる
MICAz(MPR2600J)でMTS400から加速度センサの値を全力で取り出してみる
by kewi on 10 月.15, 2009, under Memo, Sensor, Study
です。
lesson1のLED点灯で試したときは80Hzくらいまでは対応できてたご様子。
文献とかでTinyOSではサンプリングジッタが発生するとかは読んだけど…。
とりあえず行動認識行えそうな20Hzを目指します。ソースコード。
・ContextAppTest.nc
includes ContextAppTest;
/**
* This module is Unko
**/
configuration ContextAppTest {
}
implementation {
components Main, ContextAppTestM, TimerC, LedsC, GenericComm as Comm, Accel;
Main.StdControl -> TimerC.StdControl;
Main.StdControl -> ContextAppTestM.StdControl;
Main.StdControl -> Comm.Control;
// Wiring for Accelerometer
ContextAppTestM.AccelControl->Accel.StdControl;
ContextAppTestM.AccelCmd -> Accel.AccelCmd;
ContextAppTestM.AccelX -> Accel.AccelX;
ContextAppTestM.AccelY -> Accel.AccelY;
ContextAppTestM.Timer -> TimerC.Timer[unique("Timer")];
ContextAppTestM.Leds -> LedsC.Leds;
ContextAppTestM.SendMsg -> Comm.SendMsg[AM_XSXMSG];
}
・ContextAppTestM.nc
includes ContextAppTest;
module ContextAppTestM {
provides {
interface StdControl;
}
uses {
interface Timer;
interface Leds;
//Accels
interface StdControl as AccelControl;
interface I2CSwitchCmds as AccelCmd;
interface ADC as AccelX;
interface ADC as AccelY;
interface SendMsg;
}
}
implementation {
bool sending_packet;
TOS_Msg msg_buffer;
XDataMsg *pack;
// Zero out the accelerometer, chrl@20061206
norace uint16_t accel_ave_x, accel_ave_y;
norace uint8_t accel_ave_points;
bool accel_ave_end;
//init
command result_t StdControl.init() {
//init conponents
call Leds.init();
call AccelControl.init();
//init the message packet with default values
atomic {
pack = (XDataMsg *)&amp;amp;(msg_buffer.data);
pack->xSensorHeader.board_id = SENSOR_BOARD_ID;
pack->xSensorHeader.packet_id = 2;
pack->xSensorHeader.node_id = TOS_LOCAL_ADDRESS;
pack->xSensorHeader.rsvd = 0;
sending_packet = FALSE;
// Zero out the accelerometer, chrl@20061206
accel_ave_x = 0;
accel_ave_y = 0;
accel_ave_points = ACCEL_AVERAGE_POINTS;
accel_ave_end = FALSE;
}
return SUCCESS;
}
//start
command result_t StdControl.start() {
// Start a repeating timer that fires 20Hz
return call Timer.start(TIMER_REPEAT, 50);
}
//stop
command result_t StdControl.stop() {
return call Timer.stop();
}
//send packet by Single Hop
task void SendData()
{
if (call SendMsg.send(TOS_BCAST_ADDR,sizeof(XDataMsg),&amp;amp;msg_buffer) != SUCCESS)
sending_packet = FALSE;
return;
}
//fire!!!
event result_t Timer.fired()
{
if (accel_ave_points >0)
{
call Leds.greenOn();
call AccelCmd.PowerSwitch(1);
if (accel_ave_points == 1)
{
call Timer.stop();
call Timer.start(TIMER_REPEAT,100);
}
return SUCCESS;
}
if(sending_packet) return SUCCESS;
call Leds.redToggle();
call AccelCmd.PowerSwitch(1);
//call AccelX.getData();
return SUCCESS;
}
task void powerOffAccel(){
call AccelCmd.PowerSwitch(0);
return;
}
/******************************************************************************
* ADXL202E Accelerometer
* At 3.0 supply this sensor's sensitivty is ~167mv/g
* 0 g is at ~1.5V or ~VCC/2 - this varies alot.
* For an accurate calibration measure each axis at +/- 1 g and
* compute the center point (0 g level) as 1/2 of difference.
* Note: this app doesn't measure the battery voltage, it assumes 3.2 volts
* To getter better accuracy measure the battery voltage as this effects the
* full scale of the Atmega128 ADC.
* bits/mv = 1024/(1000*VBATT)
* bits/g = 1024/(1000*VBATT)(bits/mv) * 167(mv/g)
* = 171/VBATT (bits/g)
* C = 0.171/VBATT (bits/mg)
* Accel(mg) ~ (ADC DATA - 512) /C
*****************************************************************************/
async event result_t AccelY.dataReady(uint16_t data){
if (accel_ave_points>0)
{
accel_ave_y = accel_ave_y + data;
accel_ave_points --;
call Leds.greenOff();
if(accel_ave_points == 0)
{
accel_ave_x = accel_ave_x / ACCEL_AVERAGE_POINTS - 450;
accel_ave_y = accel_ave_y / ACCEL_AVERAGE_POINTS - 450;
post powerOffAccel();
}
return SUCCESS;
}
accel_ave_end = TRUE;
atomic pack->xData.dataptest.accel_y = data - accel_ave_y;
post powerOffAccel();
//post SendData();
return SUCCESS;
}
/***************************************************/
async event result_t AccelX.dataReady(uint16_t data){
if (accel_ave_points>0)
{
accel_ave_x = accel_ave_x + data;
call AccelY.getData();
return SUCCESS;
}
atomic pack->xData.dataptest.accel_x = data - accel_ave_x;
call AccelY.getData();
return SUCCESS;
}
/************power on/off**********************************************/
event result_t AccelCmd.SwitchesSet(uint8_t PowerState){
if (PowerState){
call AccelX.getData();
}
else{
if(accel_ave_end==FALSE)
{
return SUCCESS;
}
call Leds.greenOff();
if(!sending_packet) {
atomic sending_packet = TRUE;
post SendData();
}
}
return SUCCESS;
}
event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success) {
call Leds.greenToggle();
atomic sending_packet = FALSE;
return SUCCESS;
}
}
・ContextAppTest.h
// adc channels for accel x,y outputs
#define ADC_ACCEL_X_PORT 1
#define ADC_ACCEL_Y_PORT 2
#define TOS_ADC_ACCEL_X_PORT 2
#define TOS_ADC_ACCEL_Y_PORT 3
#define FEATURE_SOUNDER 1
// Define SOUND_STATE_CHANGE one of two ways:
// One time sound at test init ==> FALSE
// Continuous beeping throughout ==> !sound_state
#define SOUND_STATE_CHANGE FALSE
//#define SOUND_STATE_CHANGE !sound_state
// crossbow sensor board id
#define MTS310
#ifndef MTS310
#define SENSOR_BOARD_ID 0x83 //MTS300 sensor board id
#else
#define SENSOR_BOARD_ID 0x84 //MTS310 sensor board id
#endif
#define ACCEL_AVERAGE_POINTS 3
typedef struct XSensorHeader{
uint8_t board_id;
uint8_t packet_id;
uint8_t node_id;
uint8_t rsvd;
}__attribute__ ((packed)) XSensorHeader;
typedef struct PDatatest {
uint16_t accel_x;
uint16_t accel_y;
} __attribute__ ((packed)) PDatatest;
typedef struct XDataMsg {
XSensorHeader xSensorHeader;
union {
PDatatest dataptest;
}xData;
} __attribute__ ((packed)) XDataMsg;
enum {
AM_XSXMSG = 0,
};
Xmeshのコードから切り張りしてこんな感じ。
うーむ、でも、7Hzくらいしかでてない。
AccelCmd.SwitchesSetつかってがちゃがちゃやりながら、なにやら値をキャリブレーションしてるので、こいつが長げーんじゃないの?と思って全部無視してデータ取り出したら、20Hzくらいで送られてくるけど、データの値が全部0…。瞬間的な加速度をとっても意味ないのはわかるけれども…。
とりあえずもうちょっといじくってみましょう。
Wearable Toolkit
by kewi on 10 月.13, 2009, under Sensor, Study
前回のシンポジウムでみたWearable ToolkitがWebでダウンロードできるよー、みたいなこと言ってたので探してみた。
装着型センサによる行動認識アプリケーション開発ツールです。
http://wearable-toolkit.com/download.html
ほほう、たしかにたしかに。とりあえず基本セットをダウンロードし、exeをダブルクリック、も動かない。
iniがないようなので、WtkStart.iniをつくっておいてみた。
[PLUGIN] BaseGUI.dll ECAParse.dll WtkBasic.dll WtkDebug.dll
そして、exeをダブルクリック…起動できた!
でも、シンポジウムでみたやつとなんか違う…。うーむ。
LiteOS
by kewi on 10 月.10, 2009, under Sensor, Study
・LiteOS(http://www.liteos.net/index.htm)
LiteOS is an open source, interactive, UNIX-like operating system designed for wireless sensor networks. With the tools that come with LiteOS, you can operate one or more wireless sensor networks in a Unix-like manner, transferring data, installing programs, retrieving results, or configuring sensors. You can also develop programs for nodes, and wirelessly distribute such programs to sensor nodes.
—————————————–
・Hello World
見よ、まるでコードがCのようだ!int i…?
#include "leds.h"
#include "thread.h"
#include "radio.h"
int main()
{
int i;
while (1)
{
radioSend_string("Hello, world!\n");
greenToggle();
sleepThread(100);
}
return 0;
}
・ADC.h
うーむMTS400で使う場合は…?
/Get the light sensor reading
int get_light();
//Get the temperature sensor reading
int get_temp();
//Get the magnetic sensor reading, X axis.
int get_magx();
//Get the magnetic sensor reading, Y axis.
int get_magy();
//Get the accelerator sensor reading, X axis.
int get_accx();
//Get the accelerator sensor reading, Y axis.
int get_accy();
ポートが
//ADC interfaces
#define ADC_READ_LIGHT 0xEA40
#define ADC_READ_TEMP 0xEA44
#define ADC_READ_MAGX 0xEA48
#define ADC_READ_MAGY 0xEA4C
#define ADC_READ_ACCX 0xEA50
#define ADC_READ_ACCY 0xEA54
こんな感じだった。いじくればMTS400用になるのかな?
・EEPROM.h
MICAzのEEPROM4096 bytesのうち,はじめの3200 bytesはLiteFSで使用するからあとの896 bytesは自由に使っていいよー
- //Read from the EEPROM for nBytes bytes, starting from address
//specified by addr, and store them in location buffer.
void readFromEEPROM(uint16_t addr, uint16_t nBytes, uint8_t *buffer);
//Write to the EEPROM for nBytes bytes, starting from address
//specified by addr, and store them in location buffer.
void writeToEEPROM(uint16_t addr, uint16_t nBytes, uint8_t *buffer);
この2つの関数で読み書きしてね。
・File.h
ローカルファイルシステムはこれで操作
//Open a file using the pathname and the mode as the parameter
MYFILE *mfopen(char *pathname, const char *mode);
//Close an opened file
void mfclose(MYFILE *fp);
//Read from a file and put the read data into a buffer
void mfread(MYFILE *fp, void *buffer, int nBytes);
//Write to a file using a buffer
void mfwrite(MYFILE *fp, void *buffer, int nBytes);
//Modify the file read/write position
void mfseek(MYFILE *fp, int offset, int position);
//Write to a file using data stored in buffer, but uses the ‘\0’ as the end
void mfwrite_withoutlength(MYFILE *fp, void *buffer);
・Leds.h
LED光らせたいとき
//Toggle the green LED
void greenToggle();
//Toggle the red LED
void redToggle();
//Toggle the yellow LED
void yellowToggle();
//Turn on the red LED
void redOn();
//Turn off the red LED
void redOff();
//Turn on the green LED
void greenOn();
//Turn off the green LED
void greenOff();
//Turn on the yellow LED
void yellowOn();
//Turn off the yellow LED
void yellowOff();
・Malloc.h
なんと!mallocが使えるとな。すごいすごい。
//Get a chunk of memory specified by size from the operating system //Returns NULL if the allocation is unsuccessful
void *malloc(uint16_t size);
//Free the chunk of memory pointed by ptr
void free(void *ptr);
・Radio.h
ふむふむ、あのーマルチホップは…。
//Send out a message using the radio
int radioSend(uint8_t port, uint16_t address, uint8_t length, uint8_t *msg);
//Send out a string using the radio
int radioSend_string(uint8_t *msg);
//Send out an integer which is 16-bit
int radioSend_uint16(uint16_t value);
//Wait to receive a packet through the radio
int radioReceive(uint16_t port, uint8_t maxlength, uint8_t *msg);
//Wait for a limited time to receive a packet through the radio
int radioReceiveTimed(uint16_t port, uint8_t maxlength, uint8_t msg, uint16_t time);
//Change the radio frequency
void setRadioFreq(uint16_t freq);
//Change the radio channel
void setRadioChannel(uint8_t channel);
//Set the radio output power level
void setRadioPower(uint8_t power);
・Serial.h
シリアルとのやりとりです
//Send a string over the serial port to PC
int serialSend_string(uint8_t *msg);
//Send an 16-bit integer over the serial port to PC
int serialSend_uint16(uint16_t value);
//Send a specified length message through the serial port to PC
int serialSend(uint8_t length, uint8_t *msg);
//Wait and receive a message from PC through the serial port
void serialReceive(uint16_t port, uint8_t maxlength, uint8_t *msg);
・Stringutil.h
ほほう、文字列操作は簡単そうですな。使うかな?
int String_length(char* s);
void mystrncpy(char *dest, const char *src, uint16_t n);
void mystrcpy(char *dest, const char *src);
char* string_split(char ** string, char delimiter);
void String_append(char *base, char *string);
char *String_intToString(int num);
uint16_t hex2value(uint8_t hex);
・System.h
Atomicとか
typedef uint8_t _atomic_t;
inline _atomic_t _atomic_start(void);
inline void _atomic_end(_atomic_t oldSreg);
int rnd();
・Thread.h
スレッド!並列処理も
void sleepThread(int milliseconds);
void yield();
thread **getCurrentThread();
uint8_t getCurrentThreadIndex();
void postTask(void (*tp) (void), uint16_t priority);
uint8_t atomic_start(void) ;
void atomic_end(uint8_t oldSreg);
void syscall_postThreadTask();
void debugValue(uint16_t v1, uint16_t v2, uint16_t v3);
・デバッグ
LiteOSにはこのようなデバッグ用コマンドがある。
debug – for setting up the debugging environment
list — for listing current variables
print – for printing variable values
breakpoint – for setting up a breakpoint
listbreakpoint – for listing current breakpoints
continue – for continuing from a previous breakpoint
snapshot – for making a snapshot of a thread
restore – for restoring a thread to an earlier image