1
我想为Raspberry Pi创建一个无头应用程序,它涉及从串口读取数据。UWP无串连应用程序上的串行连接
来自Microsoft的示例应用程序正常工作,但它有一个用户界面。
在创建无头的应用程序,我把所有相关的部分超过如下:
var aqs = SerialDevice.GetDeviceSelector();
var dis = await DeviceInformation.FindAllAsync(aqs);
foreach (var t in dis)
{
if (t.Id.Contains("FTDI"))
{
listOfDevices.Add(t);
}
}
if (listOfDevices.Count == 1)
{
DeviceInformation entry = listOfDevices[0];
try
{
serialPort = await SerialDevice.FromIdAsync(entry.Id);
serialPort.WriteTimeout = TimeSpan.FromMilliseconds(1000);
serialPort.ReadTimeout = TimeSpan.FromMilliseconds(1000);
serialPort.BaudRate = 9600;
serialPort.Parity = SerialParity.None;
serialPort.StopBits = SerialStopBitCount.One;
serialPort.DataBits = 8;
serialPort.Handshake = SerialHandshake.None;
...
有一个USB-FTDI电缆,其中ID中包含 “FTDI” 如下:
serialPort = await SerialDevice.FromIdAsync(entry.Id);
程序在程序实例消失并忽略我的断点之前到达此行。
任何想法?
嗨丽塔,我不得不在已经devicecapabilities: \t <能力> \t \t <在DeviceCapability NAME = “serialcommunication”> \t \t \t <设备Id = “任何”> \t \t \t \t <功能类型= “名称:的SerialPort”/> \t \t \t \t \t在DeviceCapability> \t能力> 但没有结果。 – Axel
@Axel你介意显示完整的代码吗? –
我怎样才能发送给你? – Axel