/* test stall sensor
 * MyroC Reference Manual (http://wiki.roboteducation.org/Myro_Reference_Manual) states
 *    Every time you issue a move command, the stall sensor resets, and it needs to wait
 *    a short time to see whether the motors are stalled.  This means that the sensor 
 *    won't give accurate results if you test it too soon after the robot starts to move.
 *
 * This program and all MyroC software is licensed under the Creative Commons
 * Attribution-Noncommercial-Share Alike 3.0 United States License.
 * Details may be found at http://creativecommons.org/licenses/by-nc-sa/3.0/us/
*/

#include <stdio.h>
#include "MyroC.h"

int main ()
{
  printf ("test of sensor functions\n");

  char onOff[2];
  printf ("print Bluetooth communications ('y' or 'n')? ");
  scanf ("%s", onOff);
  rSetBluetoothEcho (onOff[0]);

  //rConnect ("/dev/rfcomm0");
  //rConnect ("/dev/tty.Fluke2-0958-Fluke2");
  rConnect ("/dev/tty.IPRE6-365897-DevB");
  //rConnect ("00:1E:19:01:0E:8C");  // IPRE365827 - post

  rMotors (0.5, 0.5);

  int i;

  for (i = 0; i < 20; i++)
    {
      printf ("\tstalled data (1=stalled):  %d\n", rGetStall(1));
      rBeep (0.5, 880);
    }

  return 0;  
}
