3

Closed

Applications using Pi sharp cannot be run twice on Raspberry

description

An exception is thrown on the second attempt and the Pi must be restarted.
Closed Mar 12, 2015 at 1:08 AM by andycb

comments

davsebamse wrote Sep 18, 2013 at 7:15 PM

It is the following exception that happens:
Unhandled Exception: System.IO.IOException: Lock violation on path /sys/class/gpio/export
  at System.IO.FileStream.FlushBuffer (System.IO.Stream st) [0x00000] in <filename unknown>:0
  at System.IO.FileStream.FlushBuffer () [0x00000] in <filename unknown>:0
  at System.IO.FileStream.Flush () [0x00000] in <filename unknown>:0
  at System.IO.StreamWriter.Flush () [0x00000] in <filename unknown>:0
  at PiSharp.LibGpio.LibGpio.Export (BroadcomPinNumber pinNumber) [0x00000] in <filename unknown>:0
  at PiSharp.LibGpio.LibGpio.SetupChannel (BroadcomPinNumber pinNumber, Direction direction) [0x00000] in <filename unknown>:0
  at PiSharp.LibGpio.LibGpio.SetupChannel (RaspberryPinNumber pinNumber, Direction direction) [0x00000] in <filename unknown>:0
  at PiSharpMailNotifier.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0

Unhandled Exception: System.IO.IOException: Lock violation on path /sys/class/gpio/export
  at System.IO.FileStream.FlushBuffer (System.IO.Stream st) [0x00000] in <filename unknown>:0
  at System.IO.FileStream.FlushBuffer () [0x00000] in <filename unknown>:0
  at System.IO.FileStream.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Lock violation on path /sys/class/gpio/export
  at System.IO.FileStream.FlushBuffer (System.IO.Stream st) [0x00000] in <filename unknown>:0
  at System.IO.FileStream.FlushBuffer () [0x00000] in <filename unknown>:0
  at System.IO.FileStream.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
The lock issue seems to be a known issue with mono on raspberry pi:

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=11634

tonyhtp wrote Dec 15, 2013 at 7:34 AM

Having the same issue with:
"Lock violation on path /sys/class/gpio/export" on Raspberry.

Does anyone have a workaround/solution to this issue?

wrote Apr 8, 2014 at 11:05 PM

wrote Jan 30, 2015 at 8:19 PM

totolook wrote Jan 30, 2015 at 8:24 PM

I have upload an patch this library, i have added the clean function for specific pin.
An example:
. . . 
Console.ReadKey();
LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Seventeen, Direction.Output);
LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, true);
LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, false);
LibGpio.Gpio.ForceClean(BroadcomPinNumber.Seventeen);
Console.ReadKey();
. . .

wrote Mar 12, 2015 at 1:08 AM

Resolved with changeset 38417.