Enabling Serial Communication

I have Mycroft working just fine on a Raspberry 2 running Raspian Jessie-lite. However, I’m having trouble getting Mycroft to connect to UART. I’ve disabled the login console for the pi using raspi-config. Here’s the error message : EnclosureClient - ERROR - It is not possible to connect to serial port: /dev/ttyAMA0. Is there another process using the serial port that I should be disabling? I’ve already tried stopping getty from using the port but to no avail. Can anyone point me in the right direction? I figured I’d take a stab at creating a custom face display for Mycroft.

Hi Gustavo!

First of all, does the /dev/ttyAMA0 UART exist? I assume that it does.

I’ve had to disable getty this way:
sudo systemctl stop serial-getty@ttyAMA0.service sudo systemctl disable serial-getty@ttyAMA0.service

The user that runs the enclosure code should also be a member of the dialout group.
sudo usermod -aG dialout USER

I hope that helps!

Hi Arron!
Thanks for your response. I’ll try that out and post an update. TtyAMA0 definetly exists but it seems another process is using it (getty i guess). I had tried disabling it before but the commands i used differed from yours

Yeah, this changed in raspian jessie:
https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=123081

Whenever you suspect that another process is tying your tty up (and I’ve noticed that screen can do this after you exit,) you can try:
fuser /dev/ttyAMA0
This will show the PID(s) of the process using it. Then you kill them.
kill $PID $PID $PID

Still no luck. I keep getting the same error message.

Mycroft won’t connect even though there are no other processes using /dev/ttyAMA0.

pi@raspberrypi:~/mycroft-core $ dmesg | grep tty
[ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa21041 bcm2709.serial=0x7ca7e0a2 smsc95xx.macaddr=B8:27:EB:A7:E0:A2 bcm2708_fb.fbswap=1 bcm2709.uart_clock=3000000 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
[ 0.001604] console [tty1] enabled
[ 0.091866] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[ 0.594658] console [ttyAMA0] enabled
[ 3.876793] systemd[1]: Expecting device dev-ttyAMA0.device…
[ 4.271138] systemd[1]: Starting system-serial\x2dgetty.slice.
[ 4.281755] systemd[1]: Created slice system-serial\x2dgetty.slice.

Do you have any luck with sudo screen /dev/ttyAMA0 9600 8N1 ?

If you can confirm that the tty is working, it could be that the new enclosure code needs to receive feedback from the Arduino. In that case, you might have a better time re-writing the enclosure client. Could you load an arduino serial test sketch, and test it with screen?

Still no luck. Everything shows that the port is open and unused.The system is able to connect to /dev/ttyAMA0 as I can still get the serial login prompt if I enable it in raspi-config.

I’m still new to python so I can’t quite tell but is the syntax of these lines from enclosure.py correct?

def main():
_ try:_
_ Enclosure().run()_ //Shouldn’t this be Enclosure.run()?
_ finally:_
_ sys.exit()_

So i managed to get it working. Here was my process:
-I installed the arduino IDE
-I installed the setup for the Alamode add-on board (basically an arduino uno that connects to the pi’s gpio pins). The setup does all the configuration work to get uart on the gpio pins working
-lastly, i built mycroft

I have currently just completed the process of enabling serial communication between Raspberry Pi 3 and Arduino. I first ran into some of the problems mentioned in this post and thought I would post my experiences here for anyone interested.

After some research I ran into the Python Arduino Command API, and decided it would be a good foundation for a project I’m working on.

I installed the library on the Pi, which can be installed via pip and then installed the necessary sketch to the Arduino. I then ran the first example. It auto-detected the Arduino and ran smoothly on the first try.

It seems like this could be a good base for a Mycroft skills to interact with an Arduino board (voice response to sensor data, voice command servos, etc.). I’m going to publish a rudimentary skill that interacts with some of the base examples to GitHub within a month or so.

Hope this helps anyone trying to get these two awesome pieces of hardware working together.

hi…most of the successful USB to serial cable users are using the FTDI chip set. Unfortunately you will have to work with FTDI to resolve any issues with your PC install. Because you are doing a dual boot thing are you sure something doesn’t need to allow access to the serial port hardware? I seem to remember reading something like that recently.