Hardware Reference
In-Depth Information
// console.log('Command: ' + command[commIdx]);
b
.
serialWrite
(
port
,
command
[
commIdx
++]);
if
(
commIdx
>=
command
.
length
) {
commIdx
=
0
;
}
}
Select which serial port to use.
Figure 6-20
shows what's available. We've wired
P9_24
and
P9_26
, so we are using serial port
/dev/ttyO1
. (Note that's the let-
ter
O
and not the number
zero
.)
Set the baudrate to 9600, which matches the setting on the LaunchPad.
Read one line at a time up to the newline character (
\n
).
Open the serial port and call
onSerial()
whenever there is data available.
Determine what event has happened on the serial port and respond to it.
If the serial port has been
open
ed, start calling
sendCommand()
every 1000 ms.
These are the two commands to send.
Write the character out to the serial port and to the LaunchPad.
Move to the next command.