Book Image

Beaglebone Essentials

By : Rodolfo Giometti
Book Image

Beaglebone Essentials

By: Rodolfo Giometti

Overview of this book

Table of Contents (18 chapters)
BeagleBone Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

A simple serial echo


In order to explain a simple serial port communication, we can use the code stored in the chapter_06/echo.py file in the book's example code repository on our host PC, as a serial device that echos the serial data received from the BeagleBone Black.

The code is quite self-explanatory; however, we should note that the serial parameters are set during the communication channel created with the following code:

# Configure the serial connections
ser = serial.Serial(
        port            = dev,
        baudrate        = 115200,
        bytesize        = 8,
        parity          = 'N',
        stopbits        = 1,
        timeout         = None,
        xonxoff         = 0,
        rtscts          = 0
)

While the main server and client functionalities are covered in the homonym-named functions server() and client().

You will notice that this program can work in both server or client mode just by using the correct command line:

root@BeagleBone:~# ./echo.py -h
usage:  echo...