C# Mono System.IO.Ports SerialPort类错误处理
我正在调试一些使用串口的单声道代码。 在某些情况下,mono会使用以下代码编写一个表:C# Mono System.IO.Ports SerialPort类错误处理,c#,linux,mono,serial-port,C#,Linux,Mono,Serial Port,我正在调试一些使用串口的单声道代码。 在某些情况下,mono会使用以下代码编写一个表: // Send the 1024 byte (256 word) CRC table progressBar = new ProgressBar(); progressBar.Update(0.0,"Sending CRC table..."); for (int i = 0; i < MyCRC.Length; i++) { MySP.W
// Send the 1024 byte (256 word) CRC table
progressBar = new ProgressBar();
progressBar.Update(0.0,"Sending CRC table...");
for (int i = 0; i < MyCRC.Length; i++)
{
MySP.Write(MyCRC[i].ToString("x8"));
progressBar.Percent = (((Double)(i+1))/MyCRC.Length);
}
progressBar.Update(100.0,"CRC table sent.");
我的理解是SerialPort写入方法不能正确处理-EAGAIN大小写,并在重新开始写入之前将索引更新为-1。因为每次尝试后,原始缓冲区的内容都会移动一个字节
我的问题是,这是一个已知的问题,我如何修改SerialPort类以使其正确运行或以阻塞方式使用串行端口
这个方法没有多大帮助
附加信息:单声道-V输出:
Mono JIT compiler version 1.2.6 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
我有一个解决办法,但我不认为这是一个好的解决方案:
progressBar = new ProgressBar();
progressBar.Update(0.0,"Sending CRC table...");
for (int i = 0; i < MyCRC.Length; i++)
{
MySP.Write(MyCRC[i].ToString("x8"));
while(WySP.BytesToWrite != 0)
{
;
}
progressBar.Percent = (((Double)(i+1))/MyCRC.Length);
}
progressBar.Update(100.0,"CRC table sent.");
progressBar=新的progressBar();
更新(0.0,“发送CRC表…”);
for(int i=0;i
考虑升级到新版本
这个bug已经修复。它没有进入1.9.1版本,1.9.1版本似乎已经被广泛使用,至少在debian和friends上是如此。
progressBar = new ProgressBar();
progressBar.Update(0.0,"Sending CRC table...");
for (int i = 0; i < MyCRC.Length; i++)
{
MySP.Write(MyCRC[i].ToString("x8"));
while(WySP.BytesToWrite != 0)
{
;
}
progressBar.Percent = (((Double)(i+1))/MyCRC.Length);
}
progressBar.Update(100.0,"CRC table sent.");