Zaxter
Zaxter

Reputation: 3035

Serial communication in Linux user space (non blocking)

I'm trying to get an arduino board communicate with a beaglebone ( BB) white running Ubuntu using UART. I have read that the BB uart driver is already interrupt driven.

I want to store all incoming data into a sort of buffer which I can read when required, similar to the way it's done in microcontrollers. But I'm trying to avoid kernel programming so I won't be able to use the driver's data structures. I'm looking for a complete user space solution.

I'm planning to use two python processes, one to write all incoming data (to a shared list) and the other to read it as required so that the read is non blocking.

I have two questions:

  1. Is this the right approach? if yes, please suggest a simple interprocess communication method that will suffice.

  2. What is the right way to implement this?

Note: I'm using the PyBBIO library that reads and writes directly to the /dev/mem special file.

Upvotes: 0

Views: 744

Answers (1)

Dietrich
Dietrich

Reputation: 5541

You might want to use pyserial, which uses the kernel interfaces (I don't know what PyBBIO does). It provides automatic input buffering - so you don't need an extra process. If you do want to have more processes use multiprocessing. A simpler alternative is threading, which saves you the communication part. For multiprocessing with network support use Ipython's cluster

Upvotes: 2

Related Questions