0

I have a C program that opens a serial port. The code is not the issue here. When I run the program as sudo it works fine and opens the port. When I run it as myself (normal user) it fails to open the serial port.

The serial port is:

crw-rw-rw-  1 root  wheel   18,   5 Dec 26 17:34 /dev/cu.usbmodem1421

I am running Mac OSX 10.11.6 (El Capitan). I have added myself to the 'wheel' group, and that did not help. So I am wondering why I cannot open it if I am a member of the 'wheel' group? Is there something else that I am missing.

<

3
  • 2
    Did you logout/login after adding yourself to wheel ? It is possible that the process that monitors the device file isn't yet aware of your new credentials. A fresh login should fix that, – Tonny Dec 27 '16 at 11:31
  • Can any other programs access the port? If so the it is probably a problem with your program and you might need to post your code that is not working in a question on Stack Overflow. – Mokubai Dec 27 '16 at 11:46
  • @Tonny I restarted the system and it worked fine. Thanks. I logged out previously and that had no effect. Thanks! – Xofo Dec 28 '16 at 2:08
5

Since I am a Mac OS X user, I added myself to the 'wheel' group based on this answer:

sudo dseditgroup -o edit -a $username_to_add -t user admin
sudo dseditgroup -o edit -a $username_to_add -t user wheel

Following the advice of @Tonny, I restarted the system and I was able to access the serial port. Logging out and logging back in did not seem to be enough, I had to restart. Then I could access the serial port as myself.

3
  • 1
    Thanks for closing the loop on your question. Comments can be transient. Since you're posting this as an answer, it would help to preserve the solution if you could edit the answer to elaborate on what you did. – fixer1234 Dec 28 '16 at 4:18
  • 1
    I made the updates and cited the source of my fix. – Xofo Dec 28 '16 at 4:40
  • 1
    Great! Glad I could put you on track of the solution. And nice self-answer too! – Tonny Dec 28 '16 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.