Problem with NMEA (COM Port) Connections on Ubuntu

Nautical Tux

In response to a comment on my recent “Managing the Device Manager”, where Michael reported problems getting his AIS100USB working on LINUX, I decided to download the latest OpenCPN and make sure that the new NMEA Connections code that they have recently added to V3.20 did in fact still work like the previous versions.

It has been a while since I played with the LINUX version of OpenCPN and with a normal Ubuntu V12.04 32 bit setup, I was surprised when I could not get the NMEA data from my AIS receiver or transponder to be received. To investigate further, I opened a Terminal Window and typed…

dmesg  | grep tty

Which returned the following information about all of the serial ports – “tty” is a legacy term in LINUX from the days of Teletypewriters which then evolved in to computer terminals that used serial ports to connect to the mainframe computer.


The Dmesg command extracts information from various log files and returns the current and historical information about USB devices that have been connected to the PC. In the screen above, you can see that a USB to Serial converter was connected and given the name ttyUSB0 (this was my AIS receiver) but that this was disconnected. Then you can see that another USB ACM device was  connected and given the name ttyACM0 (this was my AIS transponder) which is still connected.

So I now knew which serial port had been setup by LINUX for my AIS transponder, so the next step was to use a LINUX program called Screen to send the NMEA data coming in to ttyACM0 to my terminal screen. First I installed the Screen program by typing the following command in to the terminal…

sudo apt-get install screen

Once installed, the following command should have displayed the NMEA data coming in on port ttyACM0…

screen /dev/ttyACM0 38400

However, when I ran this command, I very briefly saw a warning displayed saying that I did not have the necessary permissions to access this device. This was my first clue as to the problem with no NMEA in OpenCPN. I re-entered the command this time running it as the “Root” user using the sudo command…

sudo screen /dev/ttyACM0 38400

This time the Screen command worked and I saw the following display…


So it would appear that for some reason I was being denied access to the COM port devices. My first thought was that this was a problem with OpenCPN and I looked at ways to run OpenCPN as root. Fortunately advice was on hand from a Digital Yacht customer called Fulup who had previously helped me in getting OpenCPN to work with our AIT2000.

Once again Fulup’s good LINUX advice was invaluable and he highlighted that the problem lay with changes in the way the latest versions of Ubuntu set default user permissions. The COM ports use to be available to all Users but now you need dialout permissions to access them. Fulup advised that I should add my Username to the dialout Group and then I should be able to access the COM ports, without opening up a potential security risk of running OpenCPN as root.

To do this, it was necessary to open a Terminal Window again and to run the following command exactly as written, note that $LOGNAME is a shell variable and will automatically get the name of the currently logged on user;

sudo usermod -a -G dialout $LOGNAME 

So now your username has been added to the dialout group and you just need to logout and log back in again to make the changes take effect. Once logged back in, run OpenCPN to make sure you can now read data from the COM ports.

I was very pleased to find that this fixed the problem (thanks Fulup) and I now have NMEA data coming in from my AIS Transponder or my AIS Receiver. Hope this helps anyone else having similar problems on the latest 12.04 or higher versions of Ubuntu.

2 thoughts on “Problem with NMEA (COM Port) Connections on Ubuntu

  1. Running OpenCPN as root is not a good idea, your probleme is not comming from version 3.x but from latest version of Ubuntu default security schema.

    In order to solve your problem without creating a security risk, add your username at the end of the line “dialout:x:20:” in /etc/group and after in logout/login your probleme will be solved.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s