none
SerialPort vs SerialStream (Device driver experts welcome) RRS feed

  • Question

  • 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.

    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

    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?

    Thanks

    OK - Ignore this question, the SerialStream class is internal ! 

    Tuesday, February 12, 2019 6:20 PM

All replies

  • 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.

    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, February 12, 2019 9:21 PM
    Moderator
  • 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.

    Michael Taylor http://www.michaeltaylorp3.net

    Yes you're correct all O really need are the Begin/End async Send/Receive methods - all working anyway, thanks.
    Thursday, February 14, 2019 4:06 PM