小编use*_*271的帖子

从Fairbanks SCB-9000 USB秤读取重量

我正在尝试创建一个可以调用的可执行文件,并从Fairbanks SCB-9000 USB规模传回权重.我找到了一些针对不同模型规模的代码,但它并不适合我.我特别遇到以下方法的问题.它给了我一个错误:"Can not Implicity转换类型'System.Collections.Generic.IEnumerable'到'HidLibrary.HidDevice []'." 我已经尝试了几种方法来实现这一点,但我无法让它发挥作用.这里有什么建议,或者有没有人为这个特定的规模编写任何代码?

谢谢,

这是有问题的方法:

    public HidDevice[] GetDevices()
    {
        HidDevice[] hidDeviceList;

        // Fairbanks Scale
        hidDeviceList = HidDevices.Enumerate(0x0B67, 0x555E);

        if (hidDeviceList.Length > 0)

            return hidDeviceList;

    }
Run Code Online (Sandbox Code Playgroud)

对不起应该补充一下,我在这里使用Mike Obrien的HidLibrary:http://nuget.org/packages/hidlibrary

使用完整代码更新......

这是我正在使用的代码......

Program.cs中

using System;
using System.Threading;
using HidLibrary;
using Scale;

namespace ScaleReader
{
    class Program
    {
        public static void Main(string[] args)
        {
            decimal? weight;
            bool? isStable;

            USBScale s = new USBScale();
            s.Connect();

            if (s.IsConnected)
            {
                s.GetWeight(out weight, out isStable);
                s.DebugScaleData();
                Console.WriteLine("Weight: {0:0.00} LBS", weight);
            } …
Run Code Online (Sandbox Code Playgroud)

c# usb hid

3
推荐指数
1
解决办法
4124
查看次数

标签 统计

c# ×1

hid ×1

usb ×1