■ PHOTO 3. Components secured on the
back of the console before wiring.
■ PHOTO 4. Test for
console hand fit and
for the hand-held portion of the
console. However, if you are
using Parallax products (or any
other), the Embedded Blue product
is a great fit for onboard the bot.
Photo 5 shows Parallax’s Embedded
Last month, I discussed the need
to be able to transmit non ASCII
code back and forth and still be
able to wrap the data in a packet.
To do this, I wrote a couple of
small routines to encapsulate the
packets and to place a ‘marker’
byte in front of any byte which would
conflict with the start and end of
The sendPacket routine is the simpler of the two and
places a header, marker bytes, and trailer in the packet.
Figure 1 shows this simple piece of code.
The code to receive the data is slightly more
complicated because we need to wait for the beginning
of a packet — ignoring everything else — check for
marker bytes and then wait for the end of
the packet, storing everything in between. In
addition, we only want to wait a finite time.
Consequently, we want to pass a parameter
to use as a ‘time out.’ In other words: “Go
get me a packet, but if you don’t get one in
say, two seconds, just come back.” Check
out Figure 2. Allowing the process to time
out like this will safeguard us against noise
or the bot switching off or getting out of
■ PHOTO 5. Embedded Blue from Parallax.
added to the
bot, as well as
the console. The
are symmetrical, however, layered on top of the protocol is
code that makes the bot respond to the console and, of
course, the console respond to the user and to the bot.
As discussed in the previous months,
the protocol portions of code must be
■ FIGURE 1. Code
to packetize the
■ FIGURE 2. Code to
wait for a packet, timing
out if not received.
May 2007 13