Distinct offers Network Monitor, the ONLY natural language Protocol Analyzer, ONC RPC for C++, .NET and Java, and IntelliTerm, the fastest Terminal Emulator for TN3270, TN5250 and VT420 on the market.

Knowledge Base

   Products   Downloads   Sales   Support   About us
  Knowledge Base  Ask Cody  Manuals  Source Code Library  Resources



        
 
I am using the Distinct VIT VT220 Component to connect to a host via a third-party library (e.g. a Serial Port library) and it seems escape sequences are not processed correctly. How can I correct this?
 
Product: Distinct VITTopic: VT220Last updated: 3/23/2008
 
Q.: I am using the Distinct VIT VT220 Component to connect to a host via a third-party library (e.g. a Serial Port library) and it seems escape sequences are not processed correctly. How can I correct this?
A.: The problem is that the data from the serial port should be passed to the
VT220 component without any changes, i.e. in binary format. When you read
from the port using ReadExisting, .Net tries to parse the incoming data and
thus the escape sequences are lost.

Use the Read method instead to read into a Byte[] (not Char[] !) array, or
ReadByte to read binary data from the port. Do not use any text-reading
methods on the serial port since that would corrupt the data.

You can then convert the read data into a String using Chr() function (this
way the escape sequences won't be lost) and supply the resulting string to
the component. Here's how the DataReceived event may be handled in this scenario:

Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e
As System.IO.Ports.SerialDataReceivedEventArgs) Handles
SerialPort1.DataReceived
Dim a() As Byte = {}
Dim dataSize As Integer
Dim s As String
Dim i As Integer


dataSize = SerialPort1.BytesToRead

Array.Resize(a, dataSize)

SerialPort1.Read(a, 0, dataSize)

s = ""
For i = 0 To a.Length - 1
s = s + Chr(a(i))
Next

AxVT2201.WriteData = s

End Sub
Do you find this information useful ?       Yes   No   Not Sure




Search by Keyword


If you did not find what you are looking for:


Products

 Network Monitor
The Distinct Network Monitor is a protocol analyzer for Windows that includes both packet sniffing and network traffic statistical analysis tools.

 Intelliterm
The Most Complete Terminal Emulator for TN3270, TN5250 and DEC VT220 to VT420

 RPC for C and C++
The Fastest Way to Port Your Existing Unix-RPC Applications to Windows

  8/7/2008   Legal notices | PRIVACY Policy | Networking News |