It is currently Tue Aug 22, 2017 9:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Serial port functions require raised priveleges
PostPosted: Sat Apr 15, 2017 12:49 am 
Offline
Addict
Addict
User avatar

Joined: Fri Jul 02, 2004 6:49 pm
Posts: 853
Location: Australia
Hi, been a long long time since I have done any programming at all now, so a stupid question........ :oops:
I am wanting to do some serial port work but find in Linux it appears I need sudo access or else the device access is just simply denied.
How do I do that from my source so i can run in debug screen?
e.g. from the help file:
Code:
  If OpenSerialPort(0, "/dev/ttyUSB0", 300, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 1024)
    Debug "Success"
  Else
    Debug "Failed"
  EndIf

Will just fail the same as if I use GTKterm without sudo priveleges.


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial port functions require raised priveleges
PostPosted: Sat Apr 15, 2017 1:03 am 
Offline
Addict
Addict
User avatar

Joined: Fri Jul 02, 2004 6:49 pm
Posts: 853
Location: Australia
It's ok, just worked out I need to run purebasic its'self as sudo... :oops:
Code:
sudo /home/baldrick/purebasic/compilers/purebasic


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial port functions require raised priveleges
PostPosted: Mon Apr 17, 2017 2:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 218
Location: Germany
Hello Baldrick,

you are on Linux :wink:
You shouldn't start PureBasic with sudo!

A way is (during programming work) to add the current user to a group with permission for the serial ports, like 'dialout', similar to this example on Xubuntu.Image

You can query groups with access to a specific port (here USB0) in a terminal with:
ls -l /dev/ttyUSB0

Another way (for the current login) is to give access to specific serial ports for 'others' like this (in terminal):
sudo chmod o+rw /dev/ttyUSB0
or to lock again:
sudo chmod o-rw /dev/ttyUSB0

Regards, Charly
ps: The image will not be available forever.

_________________
PureBasic 5.3-5.5, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial port functions require raised priveleges
PostPosted: Mon Apr 17, 2017 3:52 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Jul 02, 2004 6:49 pm
Posts: 853
Location: Australia
Many thanks for this tip Oma! :D
Code:
sudo chmod o+rw /dev/ttyUSB0

has worked, so again thank you.
Much I have to learn about Linux, especially now that I very rarely ever do any programming these years.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye