Project

General

Profile

Revision 1226

Robot/Station communication:
- Implemented timeouts
- Implemented command acknowledgement

View differences:

main.c
71 71
// ** Request handlers **
72 72
// **********************
73 73

  
74
static void message_send_encoders (int length, uint8_t *data)
74
static void message_read_encoders (int length, uint8_t *data)
75 75
{
76 76
	int16_t left, right;
77 77
	
......
90 90
	wl_send_global_packet (robot_station_group, robot_station_data_encoders, senddata, 4, 0);
91 91
}
92 92

  
93
// ***************************
94
// ** Message acknowledging **
95
// ***************************
93 96

  
97
static void send_done ()
98
{
99
	wl_send_global_packet (robot_station_group, robot_station_done, NULL, 0, 0);
100
}
101

  
94 102
// ***********************
95 103
// ** Receive callbacks **
96 104
// ***********************
......
111 119
	switch (type)
112 120
	{
113 121
		// Command messages
114
		case station_robot_set_orbs:        message_set_orbs        (length, packet); break;
115
		case station_robot_set_motors:      message_set_motors      (length, packet); break;
116
		case station_robot_set_bom:         message_set_bom         (length, packet); break;
117
		case station_robot_set_motors_off:  message_set_motors_off  (length, packet); break;
118
		case station_robot_set_motors_time: message_set_motors_time (length, packet); break;
119
		case station_robot_reset_encoders:  message_reset_encoders  (length, packet); break;
122
		case station_robot_set_orbs:        message_set_orbs        (length, packet); send_done (); break;
123
		case station_robot_set_motors:      message_set_motors      (length, packet); send_done (); break;
124
		case station_robot_set_bom:         message_set_bom         (length, packet); send_done (); break;
125
		case station_robot_set_motors_off:  message_set_motors_off  (length, packet); send_done (); break;
126
		case station_robot_set_motors_time: message_set_motors_time (length, packet); send_done (); break;
127
		case station_robot_reset_encoders:  message_reset_encoders  (length, packet); send_done (); break;
120 128
		
121 129
		// Request messages
122
		case station_robot_read_encoders:	message_send_encoders	(length, packet); break;
130
		case station_robot_read_encoders:	message_read_encoders	(length, packet); break;
123 131
	}
124 132
	
125 133
	orb_set (255, 127, 0);
......
131 139

  
132 140
int main(void) {
133 141
    dragonfly_init(ALL_ON);
142
	encoders_init ();
134 143

  
135 144
    usb_init ();
136 145
    usb_puts ("Diagnostic station robot starting up\r\n");

Also available in: Unified diff