I'm developing an App in .net (Xamarin) and I'm trying to establish a connection with a serial port. Whenever I try to open the connection with the port I'm getting this error_message:
System.IO.IOException: 'Too many posts were made to a semaphore'
Can't find anything specific by googling. Any help appreciated!
Example code:
private void Open()
{
IsOpen = true;
_serialPort.PortName = "COM3";
_serialPort.BaudRate = 19200;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8;
_serialPort.StopBits = StopBits.One;
_serialPort.Handshake = Handshake.None;
_serialPort?.Open();
}
This is because you need to add
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
to your Package.appxmanifest.
Took me awhile to figure this out myself.
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.