首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复raspberry pi上GPIO写入的内存映射失败异常

如何修复raspberry pi上GPIO写入的内存映射失败异常
EN

Stack Overflow用户
提问于 2017-06-02 13:41:22
回答 1查看 556关注 0票数 3

我正在尝试使用Raspberry Sharp IO库来写入Pi上的一个引脚。但它给了我一个运行时的例外。它以前起过作用,但现在不再起作用了。为什么要抛出此错误?

代码语言:javascript
复制
using System;
using Raspberry.IO.GeneralPurpose;
using Raspberry.IO.GeneralPurpose.Behaviors;
using System.Threading;

  namespace blinky
    {
       class MainClass
     {
    public static void Main (string[] args)
    {

    // Here we create a variable to address a specific pin for output
    // There are two different ways of numbering pins--the physical numbering, and the CPU number
    // "P1Pinxx" refers to the physical numbering, and ranges from P1Pin01-P1Pin40
        var led1 = ConnectorPin.P1Pin03.Output();

    // Here we create a connection to the pin we instantiated above
    var connection = new GpioConnection(led1);

    while(true){
        // Toggle() switches the high/low (on/off) status of the pin
        connection.Toggle(led1);
        Thread.Sleep(250);
    }

//  connection.Close();

}
}
 }

返回此错误:

代码语言:javascript
复制
pi@Minion01 ~/blinky1/blinky1/bin/Debug $ mono ./blinky1.exe

Unhandled Exception:
Raspberry.IO.Interop.MemoryMapFailedException: Exception of type 'Raspberry.IO.Interop.MemoryMapFailedException' was thrown.
  at Raspberry.IO.Interop.MemoryMap.ThrowOnError[MemoryMapFailedException] (IntPtr result) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.Interop.MemoryMap.Create (IntPtr address, UInt32 size, MemoryProtection protection, MemoryFlags memoryflags, Int32 fileDescriptor, UInt32 offset) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionDriver..ctor () [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.GetBestDriver (GpioConnectionDriverCapabilities capabilities) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in <filename unknown>:0 
  at blinky.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Raspberry.IO.Interop.MemoryMapFailedException: Exception of type 'Raspberry.IO.Interop.MemoryMapFailedException' was thrown.
  at Raspberry.IO.Interop.MemoryMap.ThrowOnError[MemoryMapFailedException] (IntPtr result) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.Interop.MemoryMap.Create (IntPtr address, UInt32 size, MemoryProtection protection, MemoryFlags memoryflags, Int32 fileDescriptor, UInt32 offset) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionDriver..ctor () [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.GetBestDriver (GpioConnectionDriverCapabilities capabilities) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in <filename unknown>:0 
  at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in <filename unknown>:0 
  at blinky.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 

怎样才能修好呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-02 13:46:25

我试着通过pi上的单开发和mono filename.exe来运行这个过程。两样都没用。但是当我使用sudo ./filename.exe的时候它做到了。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44330382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档