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

编程入门 行业动态 更新时间:2024-10-25 07:19:20
本文介绍了Mono System.IO.Ports SerialPort类错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在调试一些使用串行端口的单声道代码. 在某个时候,单声道用以下代码编写一个表:

I am debugging some mono code that is using the serial port. At some point the mono write a table with the following code :

// 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.");

MySP是SerialPort实例. 但是,当我使用strace跟踪此代码时,我认为这是生成的系统调用:

MySP is a SerialPort instance. When I trace this code using strace however, here is what I think are the resulting system calls :

16620 write(3, "3ab551ce", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0003ab551c", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0\0003ab551", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0\0\0003ab55", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\10\0\0\0003ab5", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0\10\0\0\0003ab", 8) = -1 EAGAIN (Resource temporarily unavailable) ... 16620 write(3, "\0005\0\230O+\10\0", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "E\0005\0\230O+\10", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0E\0005\0\230O+", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0\0E\0005\0\230O", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "\0\0\0E\0005\0\230", 8) = -1 EAGAIN (Resource temporarily unavailable) 16620 write(3, "4\0\0\0E\0005\0", 8) = 8 16620 write(3, "\230O+\10\0\0\0\0", 8) = 8 16620 write(3, "\0\0\0\0\10\0\0\0", 8) = -1 EAGAIN (Resource temporarily unavailable)

我的理解是SerialPort Write方法不能正确处理-EAGAIN情况,并在重新开始写入之前将索引更新为-1.因为每次尝试后,原始缓冲区的内容都会移动一个字节.

My understanding is that the SerialPort Write method dos not handle the -EAGAIN case correctly and updates the index by -1 before restarting the write. because after each try, the content of the original buffer is shifted by one byte.

我的问题是,这是一个已知问题,如何修改SerialPort类以使其正常运行或以阻塞方式使用串行端口?

My question is, is it a known problem, and how can I modify the SerialPort class so that it behaves correctly or use the serial port in a blocking way ?

有关Mono的文档SerialPort类不是很有帮助

其他信息:单声道-V输出:

Additional Info : mono -V output:

Mono JIT compiler version 1.2.6 (tarball) Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project TLS: __thread GC: Included Boehm (with typed GC) SIGSEGV: altstack Notifications: epoll Architecture: x86 Disabled: none

推荐答案

考虑升级到新版本.

该错误已修复这里.

更多推荐

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

本文发布于:2023-11-14 13:56:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587403.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   System   Mono   IO   SerialPort

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!