0

I'm currently busy with my masters project which involves setting up comms on UART between a Raspberry Pi Model 2 B V1.1 and a Pixhawk Flight Controller using Mavlink protocol.

The first step is, of course, to get the UART set up and working. I'm not one to run after help at the first sign of a problem. I have been struggling with this for days and it's forced me to doubt the purpose of my existence more than once. I feel stupid and frustrated. Please see if you can provide any assistance.

My first resource was this tutorial, which should be relatively straight forward:

http://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html

The tutorial simply installs all the necessary packages and dependencies, as well as sets up the UART. I followed the steps to disable OS use of the serial port through raspi-config, however after attempting to test the connection I get an error:

[Errno 2] No such file or directory: '/dev/ttyAMA0'

Which is very strange. So after disabling and enabling OS use of serial port through rasp-config a few times and checking, every time I disable it, the /dev/ttyAMA0 file disappears. Now how the hell is anything supposed to work on the UART if disabling OS use of the UART removes that file!? Nevertheless I powered through. I enabled OS use of the serial port, which leaves the ttyAMA0 file right where it is and followed another suggestion, which is to change the /boot/cmdline.txt and remove all reference to ttyAMA0, as shown in the following link:

http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/io-pins-raspbian/uart-pins

This seemed to work alright. I could now initiate comms between the RPi and the Pixhawk flight controller and get some information that looked correct. Then the black magic started. The next day I tested the connection and it consistently spat out complete rubbish. But Nothing changed since the previous day. Somewhere I must be missing something. I followed all the same tutorials and steps attempting to get the more positive results I got the previous day. However that only led to more erratic behaviour. When connecting the serial lines to my Pixhawk Flight Controller, the keyboard/mouse seems to get interrupted momentarily every now and then. Everything just went backwards. I have already reinstalled Raspbian Jessie in a desperate attempt to get things to work.

Here are a few things I suspect could possibly contribute to the problems:

  1. Baud rate not correct (to communicate with my Flight Controller baud rate needs to be 57600). Best way I've found to set this baud rate is to append "init_uart_baud=57600" to /boot/config.txt/. I have also read about other ways such as appending a line to /etc/crontab. Any suggestions?

  2. Pixhawk miraculously and sporadically refused to communicate back with RPi.

Any assistance will be appreciated. Thank you.

Josua B
  • 71
  • 6

2 Answers2

1

SOLVED:

Looks like a known bug in the latest raspbian, easy to fix though.

These need to be done as the root user.

  1. Disable "serial console" through GUI-preferences or "sudo raspi-config." Then reboot the pi.

  2. Then change the following line in the file /boot/config.txt at the bottom of the file from:

enable_uart=0 to enable_uart=1

  1. Disable the ModemMonitor service by running the following command as root:

systemctl disable ModemManager.service

  1. Then add youself to the dialout group, just to be sure you have the required permissions on the serial port:

adduser pi dialout

That should give you unrestricted proper access to the serial port.

Resources: [url]https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=148515[/url] and [url]https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=82779[/url]

Josua B
  • 71
  • 6
0

I had researched this for days now and troubleshooting all the readings listed on Google sites. I solved the serial UART settings for connecting my RPi3 Model B (typed at command line the following:

`cat /proc/cpuinfo` 

to find my Pixhawk hardware info.)

FYI: You must be root when working with mavproxy so, sudo su or sudo -s

Also, you must be a member of the dialout group, so do this at CMD line: sudo usermod -a -G dialout root (enable root user!)

  • Do all the RPi regular stuff: sudo apt-get update && sudo apt-get upgrade and sudo rpi-update.
  • Did all as outlined in the Ardupilot website. I did NOT use the "apsync-rpi". (I used the 2017-03-02-raspbian-jessie.img.) at here
  • On my RPi3, using $uname -a: results--> Linux raspberrypi 4.4.50-v7+
  • My $sudo nano /boot/config.txt file has one change at bottom of file; THIS statement: enable_uart=1 (has a good side effect of forcing the core_freq to 250 which reduces poor signal frequency)
  • Important discovery: so the articles state that RPI3 UART and tty settings have changes. (link here) What I have discovered after much ado is this for my sudo nano /boot/cmdline.txt file: dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 etc.,.
    -Notice I am not using ttyS0 in the /boot/cmdline.txt file. I tried the ttyS0 a dozen times and it never worked properly. For some reason, I am not able to explain it at this time, although the console=/dev/tty1 works if written in the /boot/cmdline.txt file.

    • Make sure you have the wiring correct between your RPi and the Pixhawk.
    • Telem 2. Also set the correct parameters in Mission Planner as I have; Go to CONFIGTUNING->STANDARD PARAMS; (my settings)

    • -The Serial0 baud rate(SERIALO_PROTOCOL) is: 115200 -The Console protocol selection(SERIAL0_PROTOCOL) is: MAVlink1 -Telem1 baud rate(SERIAL1_BAUD) is at: 115200 -Telem1 protocol selection(SERIAL1_PROTOCOL) IS MAVlink2 -Telemtry 2 Baud rate(SERIAL2_BAUD) is 921600 -Telemetry 2 protocol selection(SERIAL2_PROTOCOL) is MAVlink1

The RPi and pixhawk communicate at 921600 baud rate.

-Once I get the RPi3 powered up with it's own +5/VCC source and connect to my MP with a 3.0 USB cable from my PC-Windows10PRo, (okay, I have Arch and Debian Linux distros and Apple OSes too!) I enter:

 `mavproxy.py --master=/dev/ttyS0  --baudrate 921600 --aircraft Plane`

It works for me! Happy experimenting and flying!