Subversion Repositories shark

Rev

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

#include "kernel/kern.h"
#include "drivers/keyb.h"

#include "servo.h"

#define N_SEND 100000

int main () {

  TIME seme;
  int res, i, err=0;
  int rnd1, rnd2;
  //char ch;

  seme = sys_gettime(NULL);
  srand(seme);

  servo_open(COM2, 19200);

  /*cprintf("servo_set_RS232_baudrate\n");
  res = servo_set_RS232_baudrate(COM2, 9600);
  cprintf("Res = %d\n",res);

  cprintf("servo_get_RS232_baudrate\n");
  res = servo_get_RS232_baudrate(COM2);
  cprintf("Res = %d\n",res);

  cprintf("servo_store_RS232_baudrate\n");
  res = servo_store_RS232_baudrate(COM2);
  cprintf("Res = %d\n\n",res);

  ch = keyb_getch(BLOCK);*/



  for (i=0; i<N_SEND; i++) {

        rnd1 = rand()%16;
        rnd2 = rand()%180 - 90;
        res = servo_set_angle_sec(COM2, rnd1,ANGLE2SEC(rnd2,0,0));
        cprintf("Pin = %2d - Angle = %3d - Res = %d\n",rnd1, rnd2, res);
        if (res) err++;

  }
  cprintf("\nEvents = %d; Errors = %d\n",i, err);


  servo_close(COM2);

  return 0;

}