Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1234

Python • Re: super user command from Python script

$
0
0
Hi

to enable an external trigger on the global shutter camera, the trigger_mode parameter needs to be changed from 0 to 1. What I understand from this is that a txt file named trigger_mode that is hiding in /sys/module/imx296/parameters and contains only the value "0" needs to change to contain the value "1".
following the instructions online, using the terminal I run the following in the terminal:

Code:

pi@raspberrypi:~ $ sudo suroot@raspberrypi:/home/pi# echo 1 > /sys/module/imx296/parameters/trigger_moderoot@raspberrypi:/home/pi# exitexitpi@raspberrypi:~ $
As far as I can see, after reboot, the trigger_mode parameter changes back to 1. so this procedure needs to be repeated.

I would like to make the change to the trigger_mode parameter from my Python script. namely, to give the command to change it from "0" to "1" at the beginning of the script and change it back to "0" when I'm done, at the end of the script, such that the camera can also be used without external trigger.
can you explain how to do that?
thanks!

I don't have an appropriate camera module to check against, hence I don't have that file structure under /sys/module.

But if /sys/module/imx296/parameters/trigger_mode is simply a text file, won't it be possible to use completely standard Python File I/O operations to modify it?

Ref: Reading and Writing Files - https://docs.python.org/3/tutorial/inpu ... ting-files


Completely untested - something like this perhaps?

Code:

with open('/sys/module/imx296/parameters/trigger_mode', 'w') as f:    f.write('1')    

Statistics: Posted by B.Goode — Thu Jun 13, 2024 1:25 pm



Viewing all articles
Browse latest Browse all 1234

Trending Articles