SerialPort与SerialStream(设备驱动专家欢迎) [英] SerialPort vs SerialStream (Device driver experts welcome)

查看:203
本文介绍了SerialPort与SerialStream(设备驱动专家欢迎)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出是否可以完全免除SerialPort类,只使用底层的SerialStream类,它直接为读取和写入公开异步Begin / End。

I'm trying to find out if I can dispense completely with the SerialPort class and just use the underlying SerialStream class which exposes async Begin/End directly for reads and writes.

SerialPort存在许多问题,例如阅读这篇内容丰富的文章:

There are a host of problems with SerialPort, for example read this informative article:

http://www.sparxeng.com/blog/software/must-use-net-system -io-ports-serialport

http://www.sparxeng.com/blog/software/must-use-net-system-io-ports-serialport

那个工程师是100%正确的当我使用SerialPort时,他描述我得到了很好的结果,但现在我想知道为什么我们甚至需要SerialPort,所以这里有人每次使用SerialStream直接用于Windows COM端口上的串行IO?

That enginner is 100% correct and when I use SerialPort as he describes I get excellent results, but now I wonder why we even need SerialPort, so has anyone here every use SerialStream directly for serial IO on Windows COM ports?

谢谢

推荐答案

如果你真的想使用底层流,那么使用SerialPort配置并打开它,然后使用

BaseStream
可以访问流。当然,您无法访问任何特定于SerialStream的成员,但流本身是可访问的,并且可以像任何其他流一样使用。你应该仔细查看SerialPort代码,但要确保它不是你需要做的事情。
If you really wanted to use the underlying stream then use SerialPort to configure and open it and then use BaseStream to get access to the stream. Of course you wouldn't have access to any members that are SerialStream specific but the stream itself is accessible and can be used like any other stream. You should carefully review the SerialPort code though to make sure it isn't doing things that you need to be doing as well.


这篇关于SerialPort与SerialStream(设备驱动专家欢迎)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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