mica2.h
00001 /* 00002 * Player - One Hell of a Robot Server 00003 * Copyright (C) 2006 Radu Bogdan Rusu (rusu@cs.tum.edu) 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 */ 00020 00021 /* 00022 * TinyOS data structures. 00023 * Portions borrowed from the TinyOS project (http://www.tinyos.net), 00024 * distributed according to the Intel Open Source License. 00025 */ 00026 00027 #include <vector> 00028 00029 // Change to 19200 for Mica2DOT (!) 00030 #define DEFAULT_MICA2_PORT "/dev/ttyS0" 00031 #define DEFAULT_MICA2_RATE B57600 00032 00033 // ---[ Node calibration values ]--- 00034 class NodeCalibrationValues 00035 { 00036 public: 00037 unsigned int node_id; // node identifier 00038 unsigned int group_id; // group identifier 00039 int c_values[6]; // calibration values 00040 }; 00041 typedef std::vector<NodeCalibrationValues> NCV; 00042 00043 // ---[ MTS310 data packet structure ]--- 00044 typedef struct 00045 { 00046 unsigned short vref; 00047 unsigned short thermistor; 00048 unsigned short light; 00049 unsigned short mic; 00050 unsigned short accelX; 00051 unsigned short accelY; 00052 unsigned short magX; 00053 unsigned short magY; 00054 } MTS310Data; 00055 00056 // ---[ MTS510 data packet structure ]--- 00057 typedef struct 00058 { 00059 unsigned short light; 00060 unsigned short accelX; 00061 unsigned short accelY; 00062 unsigned short sound[5]; 00063 } MTS510Data; 00064 00065 // ---[ M1-mini RFID reader command packet structure ]--- 00066 // (Attn: ASCII mode ! make time to change to BINARY!) 00067 typedef struct 00068 { 00069 unsigned char flags [2]; 00070 unsigned char request[2]; 00071 unsigned char type [2]; 00072 unsigned char TID [16]; 00073 unsigned char start [2]; 00074 unsigned char length [2]; 00075 unsigned char data [8]; 00076 } M1miniCommand; 00077 00078 // ---[ Generic sensor data packet structure ]--- 00079 typedef struct 00080 { 00081 unsigned char board_id; // unique sensorboard id 00082 unsigned char packet_id; // unique packet type for sensorboard 00083 unsigned char node_id; // ID of originating node 00084 unsigned char parent; // ID of node's parent 00085 unsigned short data[12]; // data payload defaults to 24 bytes 00086 unsigned char terminator; // reserved for null terminator 00087 } SensorPacket; 00088 00089 // ---[ The standard header for all TinyOS active messages ]--- 00090 typedef struct 00091 { 00092 unsigned short addr; 00093 unsigned char type; 00094 unsigned char group; 00095 unsigned char length; 00096 } __attribute__ ((packed)) TOSMsgHeader; 00097 00098 // ---[ Packet structure for XCOMMAND ]--- 00099 typedef struct 00100 { 00101 unsigned short cmd; 00102 union 00103 { 00104 unsigned int new_rate; // XCOMMAND_SET_RATE 00105 unsigned int node_id; // XCOMMAND_SET_NODEID 00106 unsigned char group; // XCOMMAND_SET_GROUP 00107 unsigned char rf_power; // XCOMMAND_SET_RF_POWER 00108 unsigned char rf_channel; // XCOMMAND_SET_RF_CHANNEL 00109 struct 00110 { 00111 unsigned short device; // device: LEDs, speaker, etc 00112 unsigned short state; // state : on/off, etc 00113 } actuate; 00114 } param; 00115 } __attribute__ ((packed)) XCommandOp; 00116 00117 typedef struct 00118 { 00119 TOSMsgHeader tos; 00120 unsigned short seq_no; 00121 unsigned short destination_id; // 0xFFFF for all 00122 XCommandOp inst[1]; 00123 } __attribute__ ((packed)) XCommandMsg; 00124 00125 // ---[ RFID data packet structure] --- 00126 typedef struct{ 00127 TOSMsgHeader tos; 00128 unsigned char ptotal; // num of packets 00129 unsigned char pi; // index of current packet 00130 unsigned short RID; // receive id 00131 unsigned short SG; // signal strength 00132 unsigned char data[23]; 00133 unsigned short crc; 00134 } __attribute__ ((packed)) RFIDMsg; 00135 00136 // ---[ Health data packet structure ]--- 00137 /*typedef struct 00138 { 00139 unsigned short id; 00140 unsigned char hop_count; 00141 unsigned char send_est; 00142 } DBGEstEntry; 00143 typedef struct 00144 { 00145 unsigned short node_id; 00146 unsigned short origin_addr; 00147 short seq_no; 00148 unsigned char hop_count; 00149 // HealthMsg 00150 unsigned char est_entries; 00151 DBGEstEntry est_list[4]; 00152 } HealthData; 00153 */