Please help! HyperTerminal can read COM port, but .NET code can't


in past, if reading our device (an electronic tag reader outputs string) in hyperterminal, assured reading show in our .net winforms app.

but have situation works in hyperterminal not via our .net code.  anybody have clue?  below .net code works fine of time, except today @ 1 location.  i'm thinking maybe while hyperterminal can read com ports, .net balking @ 1 or more reason?  and yes, we're sure close 1 app before trying other.

below our code in case has clue.  thanks in advance.

using system;
using system.io.ports;
using system.threading.tasks;
using system.windows.forms;

namespace frc.cow.device.diagnosis
{
    public partial class mainform : form
    {
        serialport _serialport;
    
        public mainform()
        {
            initializecomponent();
        }

        
        private void openportbutton_click(object sender, eventargs e)
        {
            _serialport = new serialport(“com8”, 9600, parity.none, 8, stopbits.one);

            _serialport.datareceived += this._serialport_datareceived;
            
            checkforillegalcrossthreadcalls = false;

            if (_serialport.isopen == false)
            {
                try
                {
                    _serialport.open();

                }
                catch (exception ex)
                {
                    displaytextbox.text += ex.message;
                    cursor.current = cursors.default;
                }
            }
        }

        private void _serialport_datareceived(object sender, system.io.ports.serialdatareceivedeventargs e)
        {
            displaytextbox.text += _serialport.readline() + "\r\n";
        }

        private void closeportbutton_click(object sender, eventargs e)
        {
            _serialport.close();
        }
    }
}

hi coojbs,

  welcome msdn forum support.

  take @ c# hyper terminal emulation / serial port adapter read , write issues. tell how read serial port using hyper terminal.

  sincerely,

  jason wang


we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'