Project

General

Profile

Statistics
| Revision:

root / branches / encoders / code / behaviors / spline / master / master.c @ 1216

History | View | Annotate | Download (1.56 KB)

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

    
7
#define GROUP 1
8
#define TYPE 0
9

    
10
unsigned char data[4];
11

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

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

    
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]);
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);
32
}
33

    
34
int main (void) {
35
          //dragonfly_init(SERIAL | USB | COMM | ORB | ANALOG | MOTORS | BUZZER);
36
        dragonfly_init(ALL_ON);
37
        wl_init();
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);
62
  while (1) {
63
         // char vel[4] = {170, 0, 170, 1};
64
         // wl_send_global_packet(GROUP, TYPE, vel, 4, 0);          
65
          wl_do();
66
  }
67
  
68
}
69