【问题标题】:C# UWP Serial Communication Does Not ConnectC# UWP 串行通信不连接
【发布时间】:2017-11-21 07:44:45
【问题描述】:

我正在使用 UWP 创建串行通信程序..

串行通信未连接。 未捕获“设备”。返回 null。

代码在这里。

// Get a device selector from the given port name
string selector = SerialDevice.GetDeviceSelector(portName);

// Get a list of devices that match the given name
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector, null);

        // If any device found...
        if (devices.Any())

然后,我在 UWP 项目的 Package.appxmanifest 中添加了该代码。

<DeviceCapability Name="serialcommunication">
  <Device Id="any">
    <Function Type="name:serialPort" />
  </Device>
</DeviceCapability>

但它不起作用..

但是,我正在类库中创建串行通信模块。

【问题讨论】:

    标签: c# uwp serial-port


    【解决方案1】:

    在类库中编写代码与在 UWP 项目中编写代码相同。您应该先通过官方sample自己检查问题。尝试此示例并将您的设备与此示例连接。如果官方样品没有问题,则意味着您的设备没有任何问题。您需要检查您的项目和官方示例之间的差异。例如,是否初始化了 deviceWatcher?你开始了吗?

    如果您需要进一步的帮助,也许您需要详细说明您的设备并阅读此How to create a Minimal, Complete, and Verifiable example 以向我们展示示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2018-08-21
      相关资源
      最近更新 更多