Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 113455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:42:18+00:00 2026-05-11T02:42:18+00:00

I’m trying to open and read from a serial port using the System.IO.Ports.SerialPort class.

  • 0

I’m trying to open and read from a serial port using the System.IO.Ports.SerialPort class. I dragged the serial port from the tool pane (Visual Studio 2008) on to my Windows Forms application.

I’ve got a property grid set up so I can easily change properties of the serial port at runtime. When I try to open the port, I get the error shown below. I don’t understand why because I can open and read from the port using Hyperterminal.

Any ideas?

System.IO.IOException Error connection: A device attached to the system is not functioning    at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)    at System.IO.Ports.InternalResources.WinIOError()    at System.IO.Ports.SerialStream.set_DtrEnable(Boolean value)    at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)    at System.IO.Ports.SerialPort.Open()    at Test.CardReader.frmMain.Connect() in D:\Develop\2.0\Projects\Kiosk\EmbeddedBrowser\Windows Forms\Test.CardReader\Form1.cs:line 166 

Note, this is a USB connection, so it’s actually a virtual serial port.

My settings are as follows:

BaudRate = 9600
DataBits = 8
DiscardNull = false
DtrEnable = false
Handshake = None
Parity = None
ParityReplace = 63
PortName = COM3
ReadBufferSize = 4096
ReadTimeout = -1
ReceivedBytes = 1
TrsEnable = False
StopBits = One
WriteBufferSize = 2048
WriteTimeout = -1

I downloaded PortMon from Sysinternals. I’ve captured two logs. The first is the log how what happens when HyperTerminal opens the port, and the second is what happens when the .NET SerialPort class tries to open the port:

HyperTerminal:

IRP_MJ_CREATE                  USBSER000  SUCCESS       Options: Open IOCTL_SERIAL_SET_QUEUE_SIZE    USBSER000  SUCCESS       InSize: 8192 OutSize: 8192 IOCTL_SERIAL_CONFIG_SIZE       USBSER000  SUCCESS       Size: 0 IOCTL_SERIAL_GET_BAUD_RATE     USBSER000  SUCCESS IOCTL_SERIAL_GET_LINE_CONTROL  USBSER000  SUCCESS IOCTL_SERIAL_GET_CHARS         USBSER000  SUCCESS IOCTL_SERIAL_GET_HANDFLOW      USBSER000  SUCCESS IOCTL_SERIAL_GET_BAUD_RATE     USBSER000  SUCCESS IOCTL_SERIAL_GET_LINE_CONTROL  USBSER000  SUCCESS IOCTL_SERIAL_GET_CHARS         USBSER000  SUCCESS IOCTL_SERIAL_GET_HANDFLOW      USBSER000  SUCCESS IOCTL_SERIAL_SET_BAUD_RATE     USBSER000  SUCCESS       Rate: 9600 IOCTL_SERIAL_SET_RTS           USBSER000  SUCCESS IOCTL_SERIAL_SET_DTR           USBSER000  * 0xC0000001 IOCTL_SERIAL_SET_LINE_CONTROL  USBSER000  SUCCESS       StopBits: 1 Parity: NONE WordLength: 8 IOCTL_SERIAL_SET_CHAR          USBSER000  SUCCESS       EOF:1a ERR:0 BRK:0 EVT:1a XON:f6 XOFF:6 IOCTL_SERIAL_SET_HANDFLOW      USBSER000  SUCCESS       Shake:80000001 Replace:80000040 XonLimit:80 XoffLimit:200 IOCTL_SERIAL_SET_TIMEOUTS      USBSER000  SUCCESS       RI:10 RM:0 RC:0 WM:0 WC:5000 IOCTL_SERIAL_SET_WAIT_MASK     USBSER000  SUCCESS       Mask: RLSD ERR IOCTL_SERIAL_GET_MODEMSTATUS   USBSER000  SUCCESS IOCTL_SERIAL_WAIT_ON_MASK      USBSER000 IRP_MJ_READ    USBSER000                                Length 80 

.NET SerialPort:

IRP_MJ_CREATE                  USBSER000  SUCCESS       Options: Open IOCTL_SERIAL_GET_PROPERTIES    USBSER000  SUCCESS IOCTL_SERIAL_GET_MODEMSTATUS   USBSER000  SUCCESS IOCTL_SERIAL_GET_BAUD_RATE     USBSER000  SUCCESS IOCTL_SERIAL_GET_LINE_CONTROL  USBSER000  SUCCESS IOCTL_SERIAL_GET_CHARS         USBSER000  SUCCESS IOCTL_SERIAL_GET_HANDFLOW      USBSER000  SUCCESS IOCTL_SERIAL_GET_BAUD_RATE     USBSER000  SUCCESS IOCTL_SERIAL_GET_LINE_CONTROL  USBSER000  SUCCESS IOCTL_SERIAL_GET_CHARS         USBSER000  SUCCESS IOCTL_SERIAL_GET_HANDFLOW      USBSER000  SUCCESS IOCTL_SERIAL_SET_BAUD_RATE     USBSER000  SUCCESS       Rate: 9600 IOCTL_SERIAL_CLR_RTS           USBSER000  SUCCESS IOCTL_SERIAL_CLR_DTR           USBSER000  * 0xC0000001 IOCTL_SERIAL_SET_LINE_CONTROL  USBSER000  SUCCESS       StopBits: 1 Parity: NONE WordLength: 8 IOCTL_SERIAL_SET_CHAR          USBSER000  SUCCESS       EOF:1a ERR:0 BRK:0 EVT:1a XON:11 XOFF:13 IOCTL_SERIAL_SET_HANDFLOW      USBSER000  SUCCESS       Shake:0 Replace:0 XonLimit:4096 XoffLimit:4096 IOCTL_SERIAL_GET_BAUD_RATE     USBSER000  SUCCESS IOCTL_SERIAL_GET_LINE_CONTROL  USBSER000  SUCCESS IOCTL_SERIAL_GET_CHARS         USBSER000  SUCCESS IOCTL_SERIAL_GET_HANDFLOW      USBSER000  SUCCESS IOCTL_SERIAL_SET_BAUD_RATE     USBSER000  SUCCESS       Rate: 9600 IOCTL_SERIAL_CLR_RTS           USBSER000  SUCCESS IOCTL_SERIAL_CLR_DTR           USBSER000  * 0xC0000001 IOCTL_SERIAL_SET_LINE_CONTROL  USBSER000  SUCCESS       StopBits: 1 Parity: NONE WordLength: 8 IOCTL_SERIAL_SET_CHAR          USBSER000  SUCCESS       EOF:1a ERR:0 BRK:0 EVT:1a XON:11 XOFF:13 IOCTL_SERIAL_SET_HANDFLOW      USBSER000  SUCCESS       Shake:0 Replace:0 XonLimit:4096 XoffLimit:4096 IOCTL_SERIAL_CLR_DTR           USBSER000  * 0xC0000001 IRP_MJ_CLEANUP                 USBSER000  SUCCESS IRP_MJ_CLOSE                   USBSER000  SUCCESS 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:42:19+00:00Added an answer on May 11, 2026 at 2:42 am

    Regarding the differences between HyperTerminal and the .NET serial port object, HyperTerminal is a commercial, stable application. If the underlying serial port object died or threw an exception, HyperTerminal hid it from you. The .NET serial port object throws more exceptions than any other .NET object I’ve used.

    Points to make:

    • Whenever you change a setting, close it first, change it, then re-open it. Some ports really hate it when you change it while open.
    • Expect to do a lot of ‘try-catch’s around your serial port object, around every thing you do.
    • Make sure you have one for each possible exception listed, and make sure each one checks the message (it can be different under different circumstances). Many are recoverable simply by closing and reopening.
    • Try following exactly where the exceptions are being thrown. See if modifying the order you set things fixes it … the object is really finicky.

    If you’ve tried explicitly setting DTR to false before opening, then you may just have to grin and bear it with that device. The SerialPort object is not one of the glowing examples of a well implemented library in .NET. If you notice, HyperTerminal gets that same error, but it just ignores it.

    If you can, try it with a regular serial port or a different brand USB device. If you still get the same error, it might be something on your application side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using jsonparser to parse data and images obtained from json response. When
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.