Error connecting UWP app to Arduino by USB

428 views Asked by At

I am following this tutorial, https://developer.microsoft.com/en-us/windows/iot/docs/wra. Code:

using Microsoft.Maker.RemoteWiring;
using Microsoft.Maker.Serial;
public sealed partial class MainPage : Page
{
    IStream connection;
    RemoteDevice arduino;

    public MainPage()
    {
        this.InitializeComponent();
        connection = new UsbSerial("VID_2341", "PID_0043");
        arduino = new RemoteDevice(connection);
        connection.ConnectionEstablished += OnConnectionEstablished;
        connection.begin(9600, SerialConfig.SERIAL_8N1);
    }
    private void OnConnectionEstablished()
    {
        var action = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler( ()=>
        {
            onbutton.IsEnabled = true;
            offbutton.IsEnabled = true;
        }));
    }
}

The exception thrown is

Additional information: Requested Windows Runtime type 'Microsoft.Maker.Serial.UsbSerial' is not registered.

for line

        connection = new UsbSerial("VID_2341", "PID_0043");

Update: AppManifest.xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Package IgnorableNamespaces="uap mp build" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">

  <Identity Name="76b9fbdc-32fc-4b66-9ce0-b3e91c83850b" Publisher="CN=Ramy" Version="1.0.0.0" ProcessorArchitecture="x86"/>
  <mp:PhoneIdentity PhoneProductId="76b9fbdc-32fc-4b66-9ce0-b3e91c83850b" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
  <Properties>
    <DisplayName>ArduinoApp</DisplayName>
    <PublisherDisplayName>Ramy</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10240.0" MaxVersionTested="10.0.10586.0"/>
    <PackageDependency Name="Microsoft.NET.CoreRuntime.1.0" MinVersion="1.0.23819.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
    <PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.23918.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
  </Dependencies>
  <Resources>
    <Resource Language="EN-US"/>
    <Resource uap:Scale="200"/>

  </Resources>
  <Applications>
    <Application Id="App" Executable="ArduinoApp.exe" EntryPoint="ArduinoApp.App">
      <uap:VisualElements DisplayName="ArduinoApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="ArduinoApp" BackgroundColor="transparent">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
        <uap:SplashScreen Image="Assets\SplashScreen.png"/>
      </uap:VisualElements>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient"/>
    <DeviceCapability Name="serialcommunication">
      <Device Id="any">
        <Function Type="name:serialPort"/>
      </Device>
    </DeviceCapability>
  </Capabilities>
  <Extensions>
    <Extension Category="windows.activatableClass.inProcessServer">
      <InProcessServer>
        <Path>Microsoft.Maker.Firmata.dll</Path>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Firmata.StringCallbackEventArgs" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Firmata.UwpFirmata" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Firmata.CallbackEventArgs" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Firmata.SystemResetCallbackEventArgs" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Firmata.SysexCallbackEventArgs" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Firmata.I2cCallbackEventArgs" ThreadingModel="both"/>
      </InProcessServer>
    </Extension>
    <Extension Category="windows.activatableClass.inProcessServer">
      <InProcessServer>
        <Path>Microsoft.Maker.RemoteWiring.dll</Path>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.RemoteWiring.RemoteDevice" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.RemoteWiring.HardwareProfile" ThreadingModel="both"/>
      </InProcessServer>
    </Extension>
    <Extension Category="windows.activatableClass.inProcessServer">
      <InProcessServer>
        <Path>Microsoft.Maker.Serial.dll</Path>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Serial.UsbSerial" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Serial.BleSerial" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Serial.DfRobotBleSerial" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Serial.NetworkSerial" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Serial.BluetoothSerial" ThreadingModel="both"/>
        <ActivatableClass ActivatableClassId="Microsoft.Maker.Serial.CurieBleSerial" ThreadingModel="both"/>
      </InProcessServer>
    </Extension>
  </Extensions>
  <build:Metadata>
    <build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0"/>
    <build:Item Name="VisualStudio" Version="14.0"/>
    <build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Community 2015"/>
    <build:Item Name="OperatingSystem" Version="10.0.14393.0 (rs1_release.160715-1616)"/>
    <build:Item Name="Microsoft.Build.AppxPackage.dll" Version="14.0.25123.0"/>
    <build:Item Name="ProjectGUID" Value="{F5FCE15E-EDD1-4F69-AF51-2232E7915910}"/>
    <build:Item Name="OptimizingToolset" Value="None"/>
    <build:Item Name="TargetRuntime" Value="Managed"/>
    <build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="14.0.25219.0"/>
    <build:Item Name="MakePri.exe" Version="10.0.10586.212 (th2_release_sec.160328-1908)"/>
  </build:Metadata>
</Package>
0

There are 0 answers