RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    db9_gpio_rpi driver script

    Scheduled Pinned Locked Moved Help and Support
    driverpythondb9-gpio-rpi
    3 Posts 2 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jeddo
      last edited by Jeddo

      Hi there,

      im working on my retropie right now. I installed the db9_gpio_rpi driver for SEGA genesis gamepads an it is working no problem what so ever.

      Im writing my script for a driverchange right now and in this script i want to unload the driver.
      from the documentation: "sudo modprobe --first-time -r db9_gpio_rpi" unloads the driver.

      this is working in the command line. No problem what so ever.
      But the same line in the python script without sudo (running the script with "sudo python driverchange.py") gives me a SyntaxError: invalid syntax...

      def unloaddriver(channel):
      print('unloaddriver')
      pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]

      for pid in pids:
      	try:
      		commandpath = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
      	#	if commandpath[0:24] == '/opt/retropie/supplementary/emulationstation':
      			
      			# unload db9_gpio_rpi driver (SEGA, ATARI)
      		modprobe --first-time -r db9_gpio_rpi
      		print('unloaded db9_gpio_rpi')
      

      somebody any hint how to fix that? What am I doing wrong?

      synackS 1 Reply Last reply Reply Quote 0
      • synackS
        synack @Jeddo
        last edited by

        @Jeddo python isn't bash; you can't just use the same commands you'd use at the bash shell.

        This URL has a few examples of how to call external programs (i.e., modprobe) from python

        http://stackoverflow.com/questions/89228/calling-an-external-command-in-python

        1 Reply Last reply Reply Quote 0
        • J
          Jeddo
          last edited by

          Ah ok thank you. So basicly i neet to change the command to

          subprocess.call("modprobe --first-time -r db9_gpio_rpi", shell=True)

          and import the subprocess?!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.