Comments (3)
Hi, sorry I'm also no expert on Linux and don't know how to get around this. Maybe someone with enough knowledge reads this and can provide help.
When searching on the web about this you could look for questions like this: https://raspberrypi.stackexchange.com/questions/40105/access-gpio-pins-without-root-no-access-to-dev-mem-try-running-as-root in the past on Raspbian one needed root access to access GPIO's from within a Python script. Maybe the solutions of this can be transferred to your system.
I'd love to hear how you finally solved this.
from pysoem.
Just wanted to follow up on this. After digging into this for a couple of days, and working with some embedded engineers, here is a single (1) solution to this problem. There may be others, but this is the most streamlined. I will be spending time figuring out how to make this work best in a docker container, but for the time being you can use this method for both your home (base) python environment or virtual ones. It should also work with C++ and other languages as well, just with some modification of what your "executable" is. Assuming we are using python:
ll `which python`
You will get a response that looks something like this: lrwxrwxrwx 1 amorgan amorgan 9 Apr 26 2023 **/home/amorgan/miniconda3/envs/play_env/bin/python** -> **python3.8***
Now that you know you are using python 3.8 (or whatever one you are using), then run:
ll `which python3.8`
You will get a reply that looks like: rwxrwxr-x 2 amorgan amorgan 14718232 Nov 6 2019 **/home/amorgan/miniconda3/envs/play_env/bin/python3.8**
Now, you know that when you call python in command line, python3.8
(or whatever it is for your system) is what is being called to run the executable. Finally, you can open up permissions to your python executable by running:
sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ~/miniconda3/envs/play_env/bin/python3.8
Where the final argument is the location of your python executable (as determined in step 2). Hopefully this helps out anyone trying to work with opening ports/adapters for ethernet/ethercat on linux/ubuntu systems.
from pysoem.
def request_root_permissions(m_path, m_pid):
args = ["pkexec", "python3", m_path, str(m_pid)]
process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.wait(60)
if process.returncode == 1:
return True
else:
return False
su_state = True
if os.getuid() != 0:
app_path = os.path.abspath(sys.argv[0])
pid = os.getpid()
su_state = request_root_permissions(app_path, pid)
# Do what you want.....
from pysoem.
Related Issues (20)
- Ethercat Ring Topology HOT 1
- How to install soem to raspberry pi 4 ? HOT 1
- IAI Motor Controller (PCON-CB) - Not Getting to OP State Correctly HOT 6
- config_init append slaves to CdefMaster slaves attribute, but never clean it HOT 1
- IO-Link Ethercat module (EL6224) HOT 2
- Returning PDO frame late (Windows) HOT 2
- Handle Safety HOT 2
- Motion control HOT 1
- read and write PDOS question HOT 2
- Add meaning of 'network adapter ID' to documentation HOT 2
- Script crashes when Python debugger inspects `CdefSlave`
- OD version bug HOT 1
- maybe a BUGm needs deeg in HOT 1
- How to pack / unpack single `BIT`s in PDO `input` / `output` HOT 3
- Open function returns always None HOT 2
- slave.write_eeprom() bug? HOT 2
- Transfer `pysoem` into the `OpenEtherCATsociety` Github group HOT 2
- Code completion / Intellisense not working for HOT 2
- Setuptool version clash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysoem.