Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NETCore Application terminating due to StackOverflowException

So,

I'm using a Raspberry Pi model 3b and i have successfully got .NetCore v2.0.1 running on it. I have been able to build the CoreIOT Hello World project and ran it without problem on my Pi now i have some custom hardware i have created using the GPIO board and the only way i could think to use it in .NETCore was to use the FileSystem method /sys/class/gpio I have built a very small app

https://github.com/barkermn01/CanReader

There is not much in there but for some reason when i run the app all i get is a message saying Proccess is terminating due to StackOverflowException I'm not sure what is causing it there is nothing in there too big i don't think just basic file system reading.

The only thing i can think of is it does not like the infinite loops

From: https://github.com/barkermn01/CanReader/blob/master/Program.cs

while (!exiting)
{
    Console.Write("\rCurrent State " + state);
    string input = Console.ReadLine();
    if (input == "exit")
    {
        watcher.Stop();
        exiting = true;
    }
}

and From: https://github.com/barkermn01/CanReader/blob/master/GPIOWatcher.cs

public void watch()
{
    GPIO.Value val = Gpio.ReadValue();
    while (val != OldValue)
    {
        val = Gpio.ReadValue();
        if (Delegate != null)
        {
            Delegate.DynamicInvoke();
        }
        Thread.Sleep(10);
    }
}
like image 438
Barkermn01 Avatar asked Dec 19 '22 04:12

Barkermn01


1 Answers

Check the property getter of GPIO.FullPath which accesses itself:

   /// <summary>
    /// Generates the full path for the Filesystem mappings for this GPIO pin
    /// </summary>
    public string FullPath
    {
        get
        {
            return this.Path + "/" + this.FullPath;
        }
    }
like image 98
Waescher Avatar answered Dec 31 '22 13:12

Waescher