【问题标题】:Using RFID RC522 Library for Windows IOT Core为 Windows IOT Core 使用 RFID RC522 库
【发布时间】:2016-12-30 15:34:26
【问题描述】:

我使用 Raspberry Pi 2 Model B 和 Windows 10 IOT Core 操作系统。

我使用了RFID RC522 Raspberry PI 2 Windows IOT提供的库

问题是当我将此代码放在 MainPage.xaml.cs 中时

var mfrc = new Mfrc522();
    await mfrc.InitIO();

    while (true)
    {
        if (mfrc.IsTagPresent())
        {
            var uid = mfrc.ReadUid();

            mfrc.HaltTag();
        }

    }

visual studio 说 await 运算符只能在异步方法中使用。我不知道从哪里开始。我只需要 RFID 读取标签,然后在文本框中显示 RFID no/UID

【问题讨论】:

    标签: c# iot rfid windows-10-iot-core


    【解决方案1】:

    您可以将这些代码行放在异步方法中,并在MainPage() 中调用它,如下所示:

        public MainPage()
        {
            this.InitializeComponent();
            InitRC522Async();
        }
    
        private async void InitRC522Async()
        {
            var mfrc = new Mfrc522();
            await mfrc.InitIO();
    
            while (true)
            {
                if (mfrc.IsTagPresent())
                {
                    var uid = mfrc.ReadUid();
    
                    mfrc.HaltTag();
                }
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      相关资源
      最近更新 更多