0 votes
by (120 points)

Dear Rebex Team,

I am currently evaluating your framework for a project, in which I have to open a telnet connection to a server that is running a VT100 emulation.
Whenever I am sending data to the server I have to react to the Escape Sequence 0q.
My first question now is, if it is possible to define an event which fires async if the response stream has an 0q Escape Sequence?

Additionaly I also have the following issue:
I wrote a simple console application, which checks if two user inputs are identical. If so, the application gives an output that includes the escape sequence 0q and writes a line that the given inputs are identical. Whenever I start the console application, the first line displays the text "barcode performance test" and in the second line the user can enter a command prompt, respectively a barcode.
When I now open telnet connection to a computer through the windows telnet server everything is just fine and I am able to authentificate me (for the latter I've used your tutorial example codes). After that I'm able to send a command that starts my console application just like I'd do with a regular command in the command prompt.

The issue now is that whenever I try to start my console application the only result I get is the first line of my application after which the application is being closed, which I can tell because the process of the console application is not started on the remote computer.

I used following scripting command to identify the command prompt on the second line in my console application:

scripting.ReadUntil(ScriptEvent.Prompt);

For example, if I establish a telnet connection through "putty" to run my console application everything is fine.

I sincerly hope that you can help me out. I've used your Rebex Terminal Emulation for .NET (30 day trial).

Thank you.

1 Answer

0 votes
by (72.7k points)

Hello,

the event you are looking for is ITerminal.DataReceived. Using it, you will be notified about all data received from the remote end. To perform action on specific escape sequence, you have to put small logic in it. It can look like this:

// define sequence to observe
string ESC_SEQ = '\x1B' + "[0q";
// helper field to store received data
string rawData = string.Empty;

// register event for data processing
script.Terminal.DataReceived += (s, e) =>
{
    // append received data
    rawData += e.RawData;

    while (true)
    {
        // quit when not enough data
        if (rawData.Length < ESC_SEQ.Length)
            return;

        // check presence of observed sequence
        int idx = rawData.IndexOf(ESC_SEQ);
        if (idx < 0)
        {
            // remember only necessary characters
            rawData = rawData.Substring(rawData.Length - ESC_SEQ.Length - 1);
            return;
        }

        // remove data preceding observed sequence and the sequence
        rawData = rawData.Substring(idx + ESC_SEQ.Length);

        // do something - observed sequence just received
        Console.WriteLine("RECEIVED: {0}", ESC_SEQ.Replace("\x1B", "<ESC>"));
    }
};

Now, to your second issue. I am not sure whether I understand the problem well. Can you please post here, or send us (to support@rebex.net) your code, so I can imagine better what you are trying to do?

Please write comment on line (or lines) which causes troubles and what you are expecting to happen.

Thank you.

...