[Solved] How do I reset 32u4 using Python code on a Yun ?

What is the procedure to get my Python code to cause the 32u4 on a Yun to reset?

…R

GPIO 18 of the AR9331 is connected to the '32U4 reset pin. So that pin needs to be set up as an output and pulsed. The shell script to do it is in /usr/bin/reset-mcu:

#!/bin/sh

echo 18 > /sys/class/gpio/export
echo "high" > /sys/class/gpio/gpio18/direction
echo 1 > /sys/class/gpio/gpio18/value
echo 0 > /sys/class/gpio/gpio18/value
echo 18 > /sys/class/gpio/unexport

I directly translated it into Python, and it works:

#!/usr/bin/python

def writeFile(value, file):
   with open(file, "w") as f:
      f.write(value)

writeFile("18",   "/sys/class/gpio/export")             # make GPIO18 available
writeFile("high", "/sys/class/gpio/gpio18/direction")   # set pin 18 as output
writeFile("1",    "/sys/class/gpio/gpio18/value")       # Set pin 18 high
writeFile("0",    "/sys/class/gpio/gpio18/value")       # Set pin 18 low
writeFile("18",   "/sys/class/gpio/unexport")           # close out GPIO18

Thanks very much for that.

I will try it very soon.

...R

I have tried it now and, as expected, it worked perfectly. Thanks again.

I can now get my Python server program to work on my Yun as well as on my PC.

I am even learning a little Vim.

...R

@Robin2,
Can you pleased add [SOLVED] to the thread subject?

TIA
Jesse

jessemonroy650:
@Robin2,
Can you pleased add [SOLVED] to the thread subject?

Somebody did - Thanks.
I had overlooked it.

...R