Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / lib / colonet_defs.h @ 75

History | View | Annotate | Download (3.52 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
//Message types
12
#define COLONET_COMMAND 0x0D
13
#define COLONET_REQUEST 0x0E
14
#define COLONET_RESPONSE 0x0F
15

    
16
//Packet properties
17
#define PACKET_DATA_LEN 7
18
#define PACKET_SIZE 16
19

    
20
//Packet error codes
21
#define WL_ERRCODE_ROBOTDEATH 123     //For timeouts
22
#define WL_ERRCODE_NEEDTOCHARGE 250   //For pinging charging station
23
#define WL_ERRCODE_CHARGESTATION 251  //Charging station response to ping
24
#define WL_ERR_DEAD_LOC 5
25
#define WL_ERROR_DEST 255
26
#define WL_ERROR_LOC 4
27

    
28
#define WL_DEFAULT_PAN 3332
29

    
30
typedef struct {
31
  unsigned char prefix[2];
32
  unsigned char token_src;
33
  unsigned char token_dest;
34
  unsigned char msg_dest;
35
  unsigned char msg_type;
36
  unsigned char msg_code;
37
  unsigned char data[PACKET_DATA_LEN];
38
  unsigned char num_robots;
39
  unsigned char checksum;
40
} ColonetPacket;
41

    
42
#define SERIAL_PORT "/dev/ttyS0"
43
#define USB_PORT "/dev/ttyUSB0"
44

    
45
// Message dests
46
#define GLOBAL_DEST 200
47
#define MAX_NUM_ROBOTS 7
48
#define COLONET_SERVER_RESPONSE_ADDR 201
49

    
50
#define USER_DEFINED_MSG_ID_START 0xF0
51
#define USER_DEFINED_MSG_ID_END 0xFF
52
#define USER_DEFINED_MSG_TOTAL 0x0F
53

    
54

    
55
/* Low level robot commands */
56
//BUZZER
57
#define BUZZER_INIT 0x00
58
#define BUZZER_SET_VAL 0x01
59
#define BUZZER_SET_FREQ 0x02
60
#define BUZZER_CHIRP 0x03
61
#define BUZZER_OFF 0x04
62

    
63
//LCD
64
#define LCD_INIT 0x05
65
#define LCD_CLEAR_SCREEN 0x06
66
#define LCD_PUTBYTE 0x07
67
#define LCD_PUTCHAR 0x08
68
#define LCD_PUTSTR 0x09
69
#define LCD_GOTOXY 0x0A
70
#define LCD_PUTINT 0x0B
71

    
72
//ORB
73
#define ORB_INIT 0x0C
74
#define ORB_SET 0x0D
75
#define ORB_SET_COLOR 0x0E
76
#define ORB_DISABLE 0x0F
77
#define ORB_ENABLE 0x10
78
#define ORB_SET_DIO 0x11
79
#define LED_INIT 0x12
80
#define LED_USER 0x13
81
#define ORB_SET_NUM_NS 0x14
82
#define ORB_SET_NUM 0x15
83
#define ORB_SEND 0x16
84

    
85
//MOTORS
86
#define MOTORS_INIT 0x17
87
#define MOTOR1_SET 0x18
88
#define MOTOR2_SET 0x19
89
#define MOTORS_OFF 0x1A
90
#define MOVE 0x1B
91
#define MOVE_AVOID 0x1C
92

    
93
//SHARP
94
#define READ_DISTANCE 0x24
95
#define LINEARIZE_DISTANCE 0x25
96
#define LOG_DISTANCE 0x26
97
#define ENABLE_IR 0x27
98
#define DISABLE_IR 0x28
99

    
100
//SERIAL
101
#define XBEE_INIT 0x29
102
#define XBEE_PUTC 0x2A
103
#define XBEE_GETC 0x2B
104

    
105
#define USB_INIT 0x2D
106
#define USB_PUTC 0x2E
107
#define USB_GETC 0x2F
108

    
109

    
110

    
111
//DELAY_MS
112
#define DELAY_MS 0x31
113

    
114
//ANALOG
115
#define ANALOG_INIT 0x32
116
#define SET_ADC_MUX 0x33
117
#define ENABLE_ANALOG 0x34
118
#define CALL_ANALOG8 0x35
119
#define CALL_ANALOG10 0x36
120
#define WHEEL 0x37
121
#define BATTERY 0x38
122

    
123
//BOM
124
#define GETMAXBOM 0x39
125
#define BOM_ON 0x3A
126
#define BOM_OFF 0x3B
127
#define OUTPUT_HIGH 0x3C
128
#define OUTPUT_LOW 0x3D
129

    
130
//DIO
131
#define DIGITAL_INPUT 0x3E
132
#define DIGITAL_OUTPUT 0x3F
133
#define BUTTON1_READ 0x41
134
#define BUTTON1_WAIT 0x42
135
#define BUTTON1_WAIT_LED 0x43
136
#define BUTTON2_READ 0x44
137
#define BUTTON2_WAIT 0x45
138
#define BUTTON2_WAIT_LED 0x46
139

    
140
//WL 
141
#define WL_INIT 0x47
142
#define PARSE_BUFFER 0x48
143
#define WL_SEND 0x49
144

    
145
//BUMPER
146
#define DETECT_BUMP 0x50
147

    
148
//Other
149
#define PRINTF 0x51
150
#define KILL_ROBOT 0x52
151

    
152
//Colonet specific commands
153
#define REQUEST_BOM_MATRIX 0x90
154
//request: REQUEST_FROM_SERVER REQUEST_BOM_MATRIX 
155
//response: RESPONSE_TO_CLIENT_REQUEST REQUEST_BOM_MATRIX <numRobots> <row by row, values separated by spaces>
156
// if you don't know a value in the matrix, put -1 in there
157

    
158

    
159
/* End low-level robot commands */
160

    
161

    
162
//Colonet Client commands
163
//TODO: renamed these to end in LENGTH
164
#define MAX_COMMAND_LEN 128
165
#define MAX_RESPONSE_LEN 1024
166

    
167
#define SEND_TO_ROBOT      0x00
168
#define REQUEST_FROM_SERVER 0x01
169
#define RESPONSE_TO_CLIENT_REQUEST 0x02
170

    
171

    
172
#endif