C# Terminal program

  • Thread starter Thread starter Z.K.
  • Start date Start date
Z

Z.K.

I was writing a program to display data from a serial device that I need
to interact with and go into a backdoor menu in order to verify certain
information. It works fine until I go into the menu and then instead of
returning the string sysconfig> as hyperterminal does, it returns some
strange characters such as [?7H[24H. Anyone have any ideas as to what
is happening. I think it might need terminal emulation, but I am not
certain and if it does I do not know how to implement terminal emulation.

Z.K.

This is a section of the code I use.

char inchar;

// in DataReceived event handler
while (stpSerialPort.BytesToRead != 0)
{
inchar = (char)stpSerialPort.ReadByte();

strReturnString += inchar;



if (inchar == '\r')
{
lbxDeviceMessage.BeginInvoke(new
UpdateListBoxStringsHandler(UpdateListBoxStrings),
new object[] { strReturnString });

CheckCertificate2(); //just some if statements to decide what

//strings to send to the device.

strReturnString = "";
}
inchar = ' ';
}
 
MC said:
Z.K. said:
I was writing a program to display data from a serial device that I need to
interact with and go into a backdoor menu in order to verify certain
information. It works fine until I go into the menu and then instead of
returning the string sysconfig> as hyperterminal does, it returns some
strange characters such as [?7H[24H. Anyone have any ideas as to what is
happening. I think it might need terminal emulation, but I am not certain
and if it does I do not know how to implement terminal emulation.

Those look like they may be VT-100 (ANSI) terminal control codes.

http://vt100.net/emu/

Thanks for the Info. The strange thing is that I can do this in C++
with no problem. I use a C++ file and header file containing some
simple serial functions and I have never had a problem getting the data
back. I am thinking that it is the serial control that is the problem
for some reason. So, I suppose I will either have to get another serial
control or rewrite the C++ routines if I can. The C++ routines use
COMMTIMEOUTS and ReadFile to read data from the serial port.

Z.K.
 
Back
Top