CSC 499 Grinnell College Fall, 2013-Fall, 2014  
Scribbler 2 Bluetooth
Communication
with C
Scribbler 2
 
 

Development Notes

by Henry M. Walker

This page documents understandings, experiments, and sample programs in the development of Bluetooth communication in C with the Scribbler 2 robots.

Chapter 1: Communication through low-level Bluetooth procedures and BlueZ

The textbook, Bluetooth Essentials for Programmers by Albert S. Huang and Larry Rudolph, Cambridge University Press, 2007, provides detailed commentary and examples for using C to communicate over Bluetooth.

Chapter 2: Serial Communication with fopen

Email correspondence with Douglas Blank (Bryn Mawr College) and Keith O'Hara (now at Bard College) noted that use of low-level Bluetooth procedures with BlueZ or other packages can work fine, but would require much detailed coding for synchronization, error handling, etc. Thus, they suggested using a higher-level serial communication over Bluetooth.

The first attempt involved treating the Scribbler 2 as a file, designated on MathLAN as /dev/rfcomm0. A natural mechanism for file handling in C involves fopen with various procedures to read and write.

Chapter 3: Issuing Commands with open

Since file pointers to an internal struct include moderate infrastructure and do not easily support direct byte-oriented data communication, the next logical step seemed to use open, which returns a port number (int) rather than a file pointer (FILE *).

Communication with Keith O'Hara clarified that

To illustrate, the following code (adapted from Keith O'Hara) using a 1-byte command to turn an LED on and off on the Fluke.

Chapter 4: Two-way commands

Many Scribbler 2 commands instruct the robot to return data. This activity is complicated by several details:

Some initial experiments turned out to be unreliable.

To obtain reliable communication, it seems necessary to count the number of bytes received, until an anticipated data set is obtained.


This document may be found at

    http://www.cs.grinnell.edu/~walker/bluetooth-with-c/development-notes.shtml

created 21 June 2013
last revised 21 June 2013
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.