UWP link to serial port

前端 未结 1 1332
谎友^
谎友^ 2021-01-14 10:04

I want to create an UWP application to receive information sent by Waspmote board.

in WindowsForms, it\'s using System.IO.Ports; it can work

bu

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-14 10:23

    You're trying to use an old API which is not accessible to UWP apps.

    Serial communication can be achieved by using the classes from Windows.Devices.SerialCommunication.

    The class you'll use is SerialDevice which will allow you to enumerate, open the device and perform I/O operations.

    In order to use the API, you will need to add the serial port capability in your application manifest. UWP applications can only access to declared hardware resources.

    
      
        
      
    
    

    or if you want to access any hardware:

    
      
        
      
    
    

    You will find a full serial port sample as part of the UWP sample collection.

    0 讨论(0)
提交回复
热议问题