Subversion Repositories shark

Rev

Rev 1284 | Rev 1464 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1284 giacomo 1
#include "kernel/kern.h"
2
#include "drivers/keyb.h"
3
 
4
#include "servo.h"
5
 
6
#define N_SEND 100000
7
 
8
int main () {
9
 
10
  TIME seme;
11
  int res, i, err=0;
12
  int rnd1, rnd2;
13
  //char ch;
14
 
15
  seme = sys_gettime(NULL);
16
  srand(seme);
17
 
1306 giacomo 18
  servo_open(COM2, 19200);
1284 giacomo 19
 
20
  /*cprintf("servo_set_RS232_baudrate\n");
21
  res = servo_set_RS232_baudrate(COM2, 9600);
22
  cprintf("Res = %d\n",res);
23
 
24
  cprintf("servo_get_RS232_baudrate\n");
25
  res = servo_get_RS232_baudrate(COM2);
26
  cprintf("Res = %d\n",res);
27
 
28
  cprintf("servo_store_RS232_baudrate\n");
29
  res = servo_store_RS232_baudrate(COM2);
30
  cprintf("Res = %d\n\n",res);
31
 
32
  ch = keyb_getch(BLOCK);*/
33
 
34
 
35
  for (i=0; i<N_SEND; i++) {
36
 
37
        rnd1 = rand()%16;
38
        rnd2 = rand()%180 - 90;
39
        res = servo_set_angle_sec(COM2, rnd1,ANGLE2SEC(rnd2,0,0));
40
        cprintf("Pin = %2d - Angle = %3d - Res = %d\n",rnd1, rnd2, res);
41
        if (res) err++;
42
 
43
  }
44
  cprintf("\nEvents = %d; Errors = %d\n",i, err);
45
 
46
 
47
  servo_close(COM2);
48
 
49
  return 0;
50
 
51
}
52