Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Mono System.IO.Ports SerialPort类错误处理_C#_Linux_Mono_Serial Port - Fatal编程技术网

C# Mono System.IO.Ports SerialPort类错误处理

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

我正在调试一些使用串口的单声道代码。 在某些情况下,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.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.");