如何在C#中重置串行COM端口 [英] How to Reset a Serial COM Port in C#

查看:163
本文介绍了如何在C#中重置串行COM端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于今年我正在为英特尔ISEF做的项目,我使用的是mbed微控制器( http://www.mbed.http://www.mbed。 org / [ ^ ])从两个包含他们的相机发送数据普通视图,调整大小的视图,斑点检测视图和双目视差图都以921600 bps的波特率进行。



我写了一个C#项目来监视序列使用mbed中的System.IO.Ports.SerialPort类(在串行端口COM6上)的数据,但我遇到了mbed在程序中识别其活动的问题。例如,当我使用Tera Term时( http://sourceforge.jp/projects/ttssh2/releases/ [< a href =http://sourceforge.jp/projects/ttssh2/releases/target =_ blanktitle =New Window> ^ ])并重置端口(在Control-Reset Port下)终端读取从mbed流出的数据完美,但我似乎无法用我的程序复制该功能,我已经尝试了很多东西,例如在短暂的延迟后立即关闭和打开程序。该项目位于此处( http://dl.dropbox.com/u/501412/BinocularCameraOutput.zip [ ^ ])并且很容易导航周围。顺便说一句,它并没有完成所有方面(不包括重置功能)。如果出现任何其他程序错误,我会非常乐意了解这个错误并希望能够解决它。



所以,如果有人能帮我搞清楚如何使用System.IO.Ports.SerialPort或其他类正确重置我的串口,我将非常感激。

For a project I'm doing for the Intel ISEF this year, I'm using an mbed microcontroller (http://www.mbed.org/[^]) to send data from two cameras containing their normal view, resized view, blob detection view, and binocular disparity map all at a baud rate of 921600 bps.

I've written a C# Project that monitors the serial data using the System.IO.Ports.SerialPort class from the mbed (on the serial port COM6), but I'm having a problem with the mbed recognizing its activity with the program. For instance, when I use Tera Term (http://sourceforge.jp/projects/ttssh2/releases/[^]) and reset the port (under Control-Reset Port) the terminal reads the data streaming out from the mbed perfectly, but I can't seem to replicate that function with my program of which I've tried many things already such as Closing and Opening the program right after a short delay. The project is located here (http://dl.dropbox.com/u/501412/BinocularCameraOutput.zip[^]) and is pretty easy to navigate around. By the way, it's isn't quite done with every aspect (reset function not included). If any other program bugs come up, I'd be more than happy to learn about the bug and hopefully fix it.

So, if anyone could help me with figuring out how to properly reset my serial port using the System.IO.Ports.SerialPort or another class, I would be very appreciative.

推荐答案

好吧,我试过用Flush()方法,但它并不像我希望的那样工作。在Tera Term中,当一个重置端口时,它似乎自动链接数据并显示通过端口发送的所有内容,而不实际关闭然后打开它。我看了一下源代码而不是函数,但是我还没有做过它的正面或反面(我认为这是这个文件,http://en.sourceforge.jp/projects/ttssh2/svn/view/trunk/teraterm/teraterm/commlib。 c?root = ttssh2& view = log [ ^ ])。
Well, I tried out using the Flush() method, but it doesn't quite work the way I'd wish it would. In Tera Term, when one "Resets the Port", it seems to automatically link with the data and displays all that is sending through the port without actually Closing then Opening it. I've looked a little through the source for than function, but I haven't quite made heads or tails of it (I think it's this file, http://en.sourceforge.jp/projects/ttssh2/svn/view/trunk/teraterm/teraterm/commlib.c?root=ttssh2&view=log[^]).


这篇关于如何在C#中重置串行COM端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆