0

I'm quite new to Linux development and I'm facing some problems with permissions. Let's explain in detail: I'm using Mono to create a program which will access to serial ports and when I try to open a serial port (Virtual COM USB serial) I got an exception saying that access is restricted.

Of course there is an easy fix for this using "sudo chmod 777 /dev/ttyUSB0", but I don't thing this is the standard procedure. Since I'm planning to distribute the application as open source, I would like to avoid to create troubles for the user, so Is there any way to make this automatic for any possible port? maybe defining plocies somewhere? Is this something to do with creating distributable packages? I've used some Terminal programs which can access to any serial port without asking for permissions, so I'm pretty sure there is a way to do this.

Just for reference, I'm using USB to serial converters, so ports can change (not fixed); mine is ttyUSB0.

Please, please, please, please, I would really appreciate if someone could give me any clue on how to deal with these kind of things.

Thank you very much in advance.

SOLUTION

Despite this was asked a long time ago, I would like to write the answer to my question: The problem, as @sawdust suggested is that I didn't belong to the dialout group. So adding the current user to the dialout group fixes the problem and I can access to Serial ports after that.

Carles
  • 418
  • 2
  • 18
  • 2
    This is less about programming and more about permissions, so I think it might get more answers at Server Fault or Super User – Sami Kuhmonen Jun 02 '15 at 14:44
  • Make sure that your username belongs to the group that owns these ports (e.g. the group "dialout"). – sawdust Jun 02 '15 at 18:44
  • Hi, thanks @sawdust, What's the standard procedure? Creating a package and adding the app to that group once it's installed? – Carles Jun 03 '15 at 14:44

1 Answers1

0

Perhaps you could use super user priviliages for the entire session: Before you do anything, type id - the output is the user and user group you are currently logged in with.

Now use the following command:

sudo bash

The reply will probably be a password request, type in your password, now you should be logged in as super user.

To verify, type id again, now your user should be 0, as well as your user group.

Now see if you can to open the virtual port.

  • Hi, Thanks for answering. I know that I can open port using root privileges, but I'm trying to find a method valid for any user. I mean, imagine that somebody downloads the program from my website. I'm planning to create a package so they can install the app easily and there is no need to execute anything as SU or similar. – Carles Jun 03 '15 at 14:40