简体   繁体   中英

how can i connect arduino uno to rasberry pi 3 using usb cable as serial port in windows iot using c#

using System;
using System.IO.Ports;
namespace sampleserialport
{
    public sealed partial class MainPage : Page
    {

        public MainPage()
        {
            this.InitializeComponent();
            string[] ports = SerialPort.GetPortNames(); 
            Console.WriteLine("The following serial ports were found:");  
            // Display each port name to the console.      
            foreach(string port in ports) 
            {        
                Console.WriteLine(port);     
            }         
            Console.ReadLine();   
        }  
    }
}

this is the code am using but am getting an error at line

string[] ports = SerialPort.GetPortNames(); 

as

System.PlatformNotSupportedException: 'Enumeration of serial port names is not supported on the current platform.'

APIs in System.IO.Ports namespace can not work on Windows IoT Core. CP2102 USB 2.0 to TTL Module Serial Converter is listed in Hardware compatibility list , and you can refer to the sample code here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM