RIG InMoov Project
serial.ino
Go to the documentation of this file.
1 
8 #include <SoftwareSerial.h>
9 
10 SoftwareSerial cmd_serial (CMD_RX_PIN, CMD_TX_PIN);
11 
12 void serialSetup ()
13 {
14  Serial.begin (DEBUG_SERIAL_BAUDRATE);
15 
16  cmd_serial.begin (CMD_SERIAL_BAUDRATE);
17 
18  cmd_serial.listen ();
19 }
20 
21 bool serialCmdAvailable ()
22 {
23  return cmd_serial.available ();
24 }
25 
26 void serialCmdWait ()
27 {
28  while (!cmd_serial.available ());
29 }
30 
31 void serialCmdWrite (uint8_t c)
32 {
33  cmd_serial.write (c);
34 }
35 
36 void serialDebugWrite (uint8_t c)
37 {
38  Serial.write (c);
39 }
40 
41 uint8_t serialCmdRead ()
42 {
43  return cmd_serial.read ();
44 }
45 
46 int serialCmdGetByte ()
47 {
48  int i;
49 
50  serialCmdWait ();
51  i = serialCmdRead ();
52  if (i == CANCEL_SIGNAL)
53  {
54  serialDebugPrint ("CANCEL_SIGNAL\n");
55  return -1;
56  }
57 
58  return i;
59 }
60 
61 uint8_t serialDebugRead ()
62 {
63  return Serial.read ();
64 }
65 
66 int serialDebugAvailable ()
67 {
68  return Serial.available ();
69 }
70 
71 void serialDebugPrint (const char* s)
72 {
73  if (VERBOSE)
74  {
75  Serial.print (s);
76  }
77 }
78 
79 void serialDebugPrintInt (int i)
80 {
81  if (VERBOSE)
82  {
83  Serial.print (i, DEC);
84  }
85 }
86 
87 void serialDebugPrintIntPretty (const char* pre, int i, const char* post)
88 {
89  if (VERBOSE)
90  {
91  Serial.print (pre);
92  serialDebugPrintInt (i);
93  Serial.print (post);
94  }
95 }
Whether to print debug output to the serial port.
Definition: servo_rhand.h:57