Project

General

Profile

Revision 1216

Added by Rich Hong about 15 years ago

spline server and master

View differences:

master.c
1 1
#include <dragonfly_lib.h>
2 2
#include <wireless.h>
3
#include <termios.h>           
3
//#include <termios.h>           
4 4
#include <stdio.h>
5
#include <unistd.h>
5
//#include <unistd.h>
6 6

  
7 7
#define GROUP 1
8 8
#define TYPE 0
9 9

  
10
unsigned char data[4];
11

  
10 12
void packet_receive (char type, int source, unsigned char* packet, int length);
11 13

  
12 14
PacketGroupHandler packetHandler = {GROUP, 0, 0, &packet_receive, 0};
13 15

  
14 16
void packet_receive (char type, int source, unsigned char* packet, int length) {
17
	orb_set_color(YELLOW);
18
	//send to server
19
	usb_putc(packet[0]);
20
	usb_putc(packet[1]);
21
	usb_putc(packet[2]);
22
	usb_putc(packet[3]);
15 23

  
24
	//Read in from server
25
	data[0] = usb_getc(); 
26
	data[1] = usb_getc(); 
27
	data[2] = usb_getc();
28
	data[3] = usb_getc();
29
	  
30
	wl_send_global_packet(GROUP, TYPE, data, 4, 0);
31
	//orb_set_color(GREEN);
16 32
}
17 33

  
18 34
int main (void) {
19
  	dragonfly_init(SERIAL | USB | COMM | ORB | ANALOG | MOTORS | BUZZER);
35
  	//dragonfly_init(SERIAL | USB | COMM | ORB | ANALOG | MOTORS | BUZZER);
36
	dragonfly_init(ALL_ON);
20 37
	wl_init();
21
  
38
	lcd_init();
39
	lcd_puts("S");
40

  
41
//	orb_set_color(RED);
42

  
43
//  	wl_register_packet_group(&packetHandler);
44
	
45
  //      orb_set_color(YELLOW);	
46
	//Read in from server
47
//	delay_ms(1000);
48
//	data[0] = usb_getc(); 
49
	//motor1_set(0,200);
50
//	data[1] = usb_getc();
51
	//motor2_set(0,200);
52
//	data[2] = usb_getc();
53
	//motor1_set(1,200);
54
//	data[3] = usb_getc();
55
	wl_register_packet_group(&packetHandler);
56
	//motor2_set(1,200);
57
	
58
//	orb_set_color(PURPLE);
59
	//packet_receive(TYPE, 0, data, 4);
60
	wl_send_global_packet(GROUP, TYPE, data, 4, 0);
61
//	orb_set_color(GREEN);
22 62
  while (1) {
23
	  char vel[4] = {170, 0, 170, 1};
24
	  wl_send_global_packet(GROUP, TYPE, vel, 4, 0);	  
63
	 // char vel[4] = {170, 0, 170, 1};
64
	 // wl_send_global_packet(GROUP, TYPE, vel, 4, 0);	  
25 65
	  wl_do();
26 66
  }
27 67
  

Also available in: Unified diff