title: RPi2 UART Setup & Operation Issues
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>My first resource was this tutorial, which should be relatively straight forward:</p>
  
  <p><a href="http://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html" rel="nofollow">http://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html</a></p>
  
  <p>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:</p>
  
  <p>[Errno 2] No such file or directory: '/dev/ttyAMA0'</p>
  
  <p>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:</p>
  
  <p><a href="http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/io-pins-raspbian/uart-pins" rel="nofollow">http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/io-pins-raspbian/uart-pins</a></p>
  
  <p>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.</p>
  
  <p>Here are a few things I suspect could possibly contribute to the problems:</p>
  
  <ol>
  <li><p>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?</p></li>
  <li><p>Pixhawk miraculously and sporadically refused to communicate back with RPi.</p></li>
  </ol>
  
  <p>Any assistance will be appreciated. Thank you.</p>