Project

General

Profile

Revision 1345

Added by Rich Hong almost 10 years ago

Final spline code for master/slave

updated outdated libdragonfly and libwireless

View differences:

wireless.h
1 1
/**
2
 * Copyright (c) 2007 Colony Project
3
 *
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
26
/**
2 27
 * @file wireless.h
3 28
 * @brief Contains definitions for the wireless library.
4 29
 *
......
6 31
 *
7 32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
8 33
 **/
9
 
34

  
35
#ifndef WIRELESS_H
36
#define WIRELESS_H
37

  
10 38
//Note: If this is raised above 16, we will need to do
11 39
//something about frame numbers for TX Status packets.
12 40
/**
13 41
 * The maximum number of packet groups.
14 42
 **/
43
//TODO: a PacketGroupHandler is at least 10 bytes (I don't know if function pointers are 2 bytes
44
// or 4 bytes).  That means that in the c file, your array of packet groups is at least 160 bytes.
45
// Normally that might be fine (the robot's avr chips have 4k SRAM), but austin's chip only has
46
// 1k SRAM, so if this number can be reduced or if the size of the struct could be reduced, that would be a plus.
15 47
#define WL_MAX_PACKET_GROUPS 16
16 48

  
17 49
/**
......
20 52
 *
21 53
 * Contains functions and definitions for dealing with wireless functionality.<br><br>
22 54
 *
23
 * The wireless library provides a modular method for dealing with 
55
 * The wireless library provides a modular method for dealing with
24 56
 * wireless packets, by allowing packet groups to be registered.
25 57
 * A packet group is a collection of packets which share a packet
26
 * group code. Each packet in the group also has a type. A packet 
58
 * group code. Each packet in the group also has a type. A packet
27 59
 * group code and type are sent with each packet. When a packet
28
 * with a group code registered in the wireless library is 
60
 * with a group code registered in the wireless library is
29 61
 * received, the corresponding event handler is called. The
30 62
 * event handler uses the packet type and other information
31 63
 * stored in the packet to respond.<br><br>
......
39 71

  
40 72
/**
41 73
 * @struct PacketGroupHandler
42
 * A PacketGroupHandler represents a packet group, and is used to 
74
 * A PacketGroupHandler represents a packet group, and is used to
43 75
 * register a packet group with the wireless library. It contains
44 76
 * handlers for various events which can occur related to a packet
45 77
 * group.
46 78
 **/
79
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct
80
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size.
81
// Thus, pointers should be first, followed by int, followed by char.
47 82
typedef struct
48 83
{
49 84
	/**
......
51 86
	 * must be unique. The maximum number of packet groups
52 87
	 * is defined by WL_MAX_PACKET_GROUPS.
53 88
	 **/
89
  //TODO: if this number must be less than or equal to WL_MAX_PACKET_GROUPS, don't you only need
90
  // one byte for it and it can be made an unsigned char?
54 91
	unsigned int groupCode;
55 92

  
56 93
	/**
......
58 95
	 * but in wl_do).
59 96
	 **/
60 97
	void (*timeout_handler) (void);
61
	
98

  
62 99
	/**
63 100
	 * Called when a transmit status packet is received
64 101
	 * from the XBee where the first four bits of the frame
......
69 106
	 * we did not.
70 107
	 **/
71 108
	void (*handle_response) (int frame, int received);
72
	
109

  
73 110
	/**
74 111
	 * Called when we receive a packet from this group.
75 112
	 *
......
79 116
	 * @param packet the packet received
80 117
	 * @param length the length of the packet
81 118
	 **/
82
	void (*handle_receive) (char type, int source, unsigned char* packet,
83
							int length);
84
	
119
	void (*handle_receive) (char type, int source, unsigned char* packet, int length);
120

  
85 121
	/**
86 122
	 * Called for any cleanup when the network is turned off.
87 123
	 **/
88 124
	void (*unregister) (void);
89
	
125

  
90 126
} PacketGroupHandler;
91 127

  
92 128
/**@brief Initialize the wireless library **/
93
void wl_init(void);
129
int wl_init(void);
94 130
/**@brief Uninitialize the wireless library **/
95 131
void wl_terminate(void);
96 132
/**@brief Perform wireless library functionality **/
......
101 137
void wl_unregister_packet_group(PacketGroupHandler* h);
102 138

  
103 139
/**@brief Send a packet to a specific robot in any PAN **/
104
void wl_send_robot_to_robot_global_packet(char group, char type,
105
		char* data, int len, int dest, char frame);
140
int wl_send_robot_to_robot_global_packet(char group, char type, char* data, int len, int dest, char frame);
106 141
/**@brief Send a packet to a specific robot in our PAN **/
107
void wl_send_robot_to_robot_packet(char group, char type,
108
		char* data, int len, int dest, char frame);
142
int wl_send_robot_to_robot_packet(char group, char type, char* data, int len, int dest, char frame);
109 143
/**@brief Send a packet to all robots **/
110
void wl_send_global_packet(char group, char type,
111
		char* data, int len, char frame);
144
int wl_send_global_packet(char group, char type, char* data, int len, char frame);
112 145
/**@brief Send a packet to all robots in our PAN **/
113
void wl_send_pan_packet(char group, char type,
114
		char* data, int len, char frame);
146
void wl_send_pan_packet(char group, char type, char* data, int len, char frame);
115 147

  
116 148
/**@brief Set the PAN we are using **/
117
void wl_set_pan(int pan);
149
int wl_set_pan(int pan);
118 150
/**@brief Get the PAN we are using **/
119 151
int wl_get_pan(void);
120 152
/**@brief Set the channel we are using **/
121
void wl_set_channel(int channel);
153
int wl_set_channel(int channel);
122 154
/**@brief Get the channel we are using **/
123 155
int wl_get_channel(void);
124 156
/**@brief Get the 16-bit address of the XBee module **/
125
unsigned int wl_get_xbee_id(void);
157
int wl_get_xbee_id(void);
158
/**@brief Set the com port on a computer, undefined on the robot.**/
159
void wl_set_com_port(char* port);
126 160

  
127 161
/** @} **/ // end defgroup
128 162

  
163
#endif
164

  

Also available in: Unified diff