root / trunk / code / projects / colonet / common / colonet_defs.h @ 681
History | View | Annotate | Download (4.12 KB)
1 |
/* Eugene Marinelli, Fan
|
---|---|
2 |
* 10/27/06
|
3 |
*
|
4 |
* Colonet Definitions - common definitions and structs used in all colonet
|
5 |
* applications
|
6 |
*/
|
7 |
|
8 |
#ifndef COLONET_DEFS_H_
|
9 |
#define COLONET_DEFS_H_
|
10 |
|
11 |
// PacketGroup id for wireless library.
|
12 |
#define COLONET_PACKET_GROUP_ID 8 |
13 |
#define COLONET_RESPONSE_PACKET_FRAME_ID COLONET_PACKET_GROUP_ID
|
14 |
|
15 |
//Colonet Client commands
|
16 |
//TODO: renamed these to end in LENGTH
|
17 |
#define MAX_COMMAND_LEN 128 |
18 |
#define MAX_RESPONSE_LEN 1024 |
19 |
|
20 |
typedef enum {SEND_TO_ROBOT = 0, REQUEST_FROM_SERVER = 1, RESPONSE_TO_CLIENT_REQUEST = 2} ColonetClientMessageType; |
21 |
typedef enum {COLONET_COMMAND = 13, COLONET_REQUEST = 14, COLONET_RESPONSE = 15} ColonetRobotMessageType; |
22 |
|
23 |
//Packet properties
|
24 |
#define PACKET_DATA_LEN 16 |
25 |
|
26 |
#define WL_DEFAULT_PAN 3332 |
27 |
|
28 |
#define SERIAL_PORT "/dev/ttyS0" |
29 |
#define USB_PORT "/dev/ttyUSB0" |
30 |
|
31 |
// Message dests
|
32 |
#define GLOBAL_DEST 200 |
33 |
#define COLONET_SERVER_RESPONSE_ADDR 201 |
34 |
|
35 |
#define USER_DEFINED_MSG_ID_START 0xF0 |
36 |
#define USER_DEFINED_MSG_ID_END 0xFF |
37 |
#define USER_DEFINED_MSG_TOTAL 0x0F |
38 |
|
39 |
/* This is the packet structure of the data buffer sent from the colonet
|
40 |
* wireless library to the robots and from the robots to the colonet wireless
|
41 |
* library. */
|
42 |
typedef struct { |
43 |
short client_id; // ID number of the client sending the packet. Size of short is common to robots and server. |
44 |
unsigned char msg_code; // Specific instruction for the robot -- see below. |
45 |
unsigned char data[PACKET_DATA_LEN]; |
46 |
} ColonetRobotServerPacket; |
47 |
|
48 |
/* Message codes */
|
49 |
//BUZZER
|
50 |
#define BUZZER_INIT 0x00 |
51 |
#define BUZZER_SET_VAL 0x01 |
52 |
#define BUZZER_SET_FREQ 0x02 |
53 |
#define BUZZER_CHIRP 0x03 |
54 |
#define BUZZER_OFF 0x04 |
55 |
|
56 |
//LCD
|
57 |
#define LCD_INIT 0x05 |
58 |
#define LCD_CLEAR_SCREEN 0x06 |
59 |
#define LCD_PUTBYTE 0x07 |
60 |
#define LCD_PUTCHAR 0x08 |
61 |
#define LCD_PUTSTR 0x09 |
62 |
#define LCD_GOTOXY 0x0A |
63 |
#define LCD_PUTINT 0x0B |
64 |
|
65 |
//ORB
|
66 |
#define ORB_INIT 0x0C |
67 |
#define ORB_SET 0x0D |
68 |
#define ORB_SET_COLOR 0x0E |
69 |
#define ORB_DISABLE 0x0F |
70 |
#define ORB_ENABLE 0x10 |
71 |
#define ORB_SET_DIO 0x11 |
72 |
#define LED_INIT 0x12 |
73 |
#define LED_USER 0x13 |
74 |
#define ORB_SET_NUM_NS 0x14 |
75 |
#define ORB_SET_NUM 0x15 |
76 |
#define ORB_SEND 0x16 |
77 |
|
78 |
//MOTORS
|
79 |
#define MOTORS_INIT 0x17 |
80 |
#define MOTOR1_SET 0x18 |
81 |
#define MOTOR2_SET 0x19 |
82 |
#define MOTORS_OFF 0x1A |
83 |
#define MOVE 0x1B |
84 |
#define MOVE_AVOID 0x1C |
85 |
|
86 |
//SHARP
|
87 |
#define READ_DISTANCE 0x24 |
88 |
#define LINEARIZE_DISTANCE 0x25 |
89 |
#define LOG_DISTANCE 0x26 |
90 |
#define ENABLE_IR 0x27 |
91 |
#define DISABLE_IR 0x28 |
92 |
|
93 |
//SERIAL
|
94 |
#define XBEE_INIT 0x29 |
95 |
#define XBEE_PUTC 0x2A |
96 |
#define XBEE_GETC 0x2B |
97 |
|
98 |
#define USB_INIT 0x2D |
99 |
#define USB_PUTC 0x2E |
100 |
#define USB_GETC 0x2F |
101 |
|
102 |
|
103 |
|
104 |
//DELAY_MS
|
105 |
#define DELAY_MS 0x31 |
106 |
|
107 |
//ANALOG
|
108 |
#define ANALOG_INIT 0x32 |
109 |
#define SET_ADC_MUX 0x33 |
110 |
#define ENABLE_ANALOG 0x34 |
111 |
#define CALL_ANALOG8 0x35 |
112 |
#define CALL_ANALOG10 0x36 |
113 |
#define WHEEL 0x37 |
114 |
#define BATTERY 0x38 |
115 |
|
116 |
//BOM
|
117 |
#define GETMAXBOM 0x39 |
118 |
#define BOM_ON 0x3A |
119 |
#define BOM_OFF 0x3B |
120 |
#define OUTPUT_HIGH 0x3C |
121 |
#define OUTPUT_LOW 0x3D |
122 |
|
123 |
//DIO
|
124 |
#define DIGITAL_INPUT 0x3E |
125 |
#define DIGITAL_OUTPUT 0x3F |
126 |
#define BUTTON1_READ 0x41 |
127 |
#define BUTTON1_WAIT 0x42 |
128 |
#define BUTTON1_WAIT_LED 0x43 |
129 |
#define BUTTON2_READ 0x44 |
130 |
#define BUTTON2_WAIT 0x45 |
131 |
#define BUTTON2_WAIT_LED 0x46 |
132 |
|
133 |
//WL
|
134 |
#define WL_INIT 0x47 |
135 |
#define PARSE_BUFFER 0x48 |
136 |
#define WL_SEND 0x49 |
137 |
|
138 |
//BUMPER
|
139 |
#define DETECT_BUMP 0x50 |
140 |
|
141 |
//Other
|
142 |
#define PRINTF 0x51 |
143 |
#define KILL_ROBOT 0x52 |
144 |
|
145 |
#define MOVE_TO_ABSOLUTE_POSITION 0x53 |
146 |
#define ROBOT_REQUEST_POSITION_FROM_SERVER 0x54 |
147 |
#define SERVER_REPORT_POSITION_TO_ROBOT 0x55 |
148 |
|
149 |
#define CLIENT_REQUEST_ROBOT_POSITIONS 0x56 |
150 |
#define CLIENT_ASSIGN_ROBOT_ID 0x57 |
151 |
|
152 |
#define SERVER_REPORT_ROBOT_LOST 0x58 |
153 |
|
154 |
#define CLIENT_SET_VIRTUAL_WALL 0x59 |
155 |
|
156 |
#define SERVER_REPORT_VIRTUAL_WALL_UPPER 0x5A |
157 |
#define SERVER_REPORT_VIRTUAL_WALL_LOWER 0x5B |
158 |
|
159 |
#define SERVER_CLEAR_VIRTUAL_WALL 0x5C |
160 |
#define ROBOT_REPORT_ARRIVED_AT_POSITION 0x5D |
161 |
|
162 |
///////////////////////////
|
163 |
//Colonet specific commands
|
164 |
//////////////////////////
|
165 |
|
166 |
#define REQUEST_BOM_MATRIX 0x90 |
167 |
//request: REQUEST_FROM_SERVER REQUEST_BOM_MATRIX
|
168 |
//response: RESPONSE_TO_CLIENT_REQUEST REQUEST_BOM_MATRIX <numRobots> <row by row, values separated by spaces>
|
169 |
// if you don't know a value in the matrix, put -1 in there
|
170 |
|
171 |
#define REQUEST_XBEE_IDS 0x91 |
172 |
//request: REQUEST_FROM_SERVER REQUEST_XBEE_IDS
|
173 |
//response: RESPONSE_TO_CLIENT_REQUEST REQUEST_XBEE_IDS <numRobots> <id0> <id1> ... <idNumRobots>
|
174 |
|
175 |
|
176 |
#endif
|