Electronic – How to setup a RS-232 Cape for BeagleBone Black

beaglebone blackrs232

I'm trying to use a RS-232 cape in a python script. A TU-S9 USB-to-Serial converter works just fine with same code I just change the port. So I don't think it is my code. The only thing I can think of is that I am missing something setup wise. The Cape doesn't come with any documentation (that I have found). I've tried UART 1,2,4 same result. the port will open but it never gets a response from the device. The device is a DirectLogic 05 PLC. I'm using ModBus RTU.

Edit: from what I can tell the UART ports for the beaglebone are listed as /dev/ttyO0, /dev/ttyO1,/dev/ttyO2,/dev/ttyO3,/dev/ttyO4. /dev/ttyO0 is used by the OS though.

Best Answer

Using the version 3.8 or higher of the Linux Kernel, you can set a Device Tree Overlay.

By this method, at runtime, you can incorporate the system device drivers.

Personally, I implemented the necessary hardware to operate with a RS-485 interface and Modbus protocol. This basically is the hardware for Bus transceiver and its associated components. When I wanted to start the operation, I could see that the ttyO4 port was not enabled.
I found the solution here, where the code is presented to compile an Overlay to enable the port ttyO4. Once implemented this, everything worked properly.

Attention

In Beaglebone board I used, the operating system installed was Ubuntu. When compiling the file with the Overlay, compilation tool threw an error concerning did not recognize the option "@". This is solved, and here's how to apply the patch for the Overlay compiler. Therefore, I recommend the Overlay compiler what you obtain source code instead of using a repository.