Recent

Author Topic: How to handle elevation requirement on linux? Synaser RS232  (Read 2212 times)

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Hi, I am using synaser to communicate with a serial port through RS232.

https://github.com/cpicanco/stimulus_control/blob/master/src/units/interface_rs232.pas

On linux it requires full privileges to do its stuff. So how you would solve this?? For debugging, for example, execute lazarus with sudo?? Any other option for asking for privileges during runtime somehow (any suggestions?)
Be mindful and excellent with each other.
https://github.com/cpicanco/

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: How to handle elevation requirement on linux? Synaser RS232
« Reply #1 on: May 23, 2017, 10:58:01 pm »
Is there a way to completely avoid elevated privileges with TBlockSerial??
Be mindful and excellent with each other.
https://github.com/cpicanco/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: How to handle elevation requirement on linux? Synaser RS232
« Reply #3 on: May 25, 2017, 12:44:29 am »
Thanks, this actually pointed me to right direction. I have found this:

https://gist.github.com/cbrake/4337154

Here are my steps:
Code: Bash  [Select][+][-]
  1. # check your device specific constants
  2. udevadm info --attribute-walk -n /dev/ttyUSB0
  3.  
  4. # create a new dev rule based on some constants
  5. echo 'SUBSYSTEM=="tty", ATTRS{serial}=="A1004chl", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0664"' | sudo tee /etc/udev/rules.d/50-usb-serial.rules > /dev/null
  6.  
  7. # reload rules
  8. sudo udevadm control --reload-rules
  9.  
  10. # re-add all devices
  11. sudo udevadm trigger
  12.  
  13. # test
  14. ls -al /dev/ttyUSB0
  15.  
  16. # you should reboot your system
  17. sudo reboot
  18.  

Also the following answers help me understand the Linux device path logic:

https://unix.stackexchange.com/questions/144029/command-to-determine-ports-of-a-device-like-dev-ttyusb0
« Last Edit: May 25, 2017, 02:02:01 am by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

 

TinyPortal © 2005-2018