Rpi - 不能在我的 C# 程序上使用我的 /dev/hidraw0 作为串行

本文关键字:我的 hidraw0 dev 不能 Rpi 程序上 | 更新日期: 2023-09-27 18:32:42

我想使用我的USB条形码扫描仪,它在我的Raspi B+设备上使用C#代码/dev/hidraw0

这是我目前的程序:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
namespace USBSupp5
{
    class Program
    {
        static void Main(string[] args)
        {
           SerialPort sp = new SerialPort("/dev/hidraw0", 115200, Parity.None, 20);
           sp.Open();
        }
    }
}

以下是例外情况:

Unhandled Exception: System.IO.IOException: No such file or directory
at System.IO.Ports.SerialPortStream.ThrowIOException () [0x00000] in <filename unknown>:0
at System.IO.Ports.SerialPortStream..ctor (System.String portName, Int32 baudRate, Int32 dataBits, Parity parity, StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable, Handshake handshake, Int32 readTimeout, Int32 writeTimeout, Int32 readBufferSize, Int32 writeBufferSize) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int) at System.IO.Ports.SerialPort.Open () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:Open ()
at USBSupp5.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: No such file or directory
at System.IO.Ports.SerialPortStream.ThrowIOException () [0x00000] in <filename unknown>:0
at System.IO.Ports.SerialPortStream..ctor (System.String portName, Int32 baudRate, Int32 dataBits, Parity parity, StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable, Handshake handshake, Int32 readTimeout, Int32 writeTimeout, Int32 readBufferSize, Int32 writeBufferSize) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int) at System.IO.Ports.SerialPort.Open () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:Open ()
at USBSupp5.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

Rpi - 不能在我的 C# 程序上使用我的 /dev/hidraw0 作为串行

好吧,

没关系。通过进一步的研究,我发现我的条形码扫描仪被视为标准输入设备(键盘),并且我的Raspi已经支持该驱动程序。因此,无需使用程序,因为条形码扫描仪的输入已经正确解释。

我正在通过笔记本电脑通过SSH对我的Raspi进行编程,条形码扫描仪连接到我的Raspi。我没有看到条形码扫描仪输入的原因是,通过SSH标准输入(STDIN)是我的笔记本电脑,而不是Raspi耳边设备(IE。USB端口)