Link to home
Start Free TrialLog in
Avatar of scorpion53061
scorpion53061

asked on

ASCII Conversions (I think)

This is what I believe to be a ASCII string that in my system at work represents a F7 (I think)

00000000  1b 62 0d                                         .b.

How can I tell what characters this transalates to in vb.net

such Chr(27) & Chr(79) & Chr(83)

I know this is not right but it is an example.
Avatar of AlexFM
AlexFM

Your question is not clear, can you give mode details?
Some remarks :
You have the Keys class. There you will find all the possible key the user may type. Then you can use the Asc or AscW method to get a ASCII value
Otherwise, you also have several constants you can use in string :

VbCrLf
vbCr
VbLf
VbNewLine
VbTab
Avatar of scorpion53061

ASKER

ok what I need to do is send this string as a telnet command. This is a hex dump log.

00000000  1b 62 0d                                         .b.

and what is suppose to happen is that this will result in the F2 key actions being performed.

are you saying I can say

Telnet1.Send(Chr(&H00000000  1b 62 0d                                         .b.))

and this will work?
>    00000000  1b 62 0d                                         .b.
To me, this looks like a typically hex dump.
The 00000000 represents the address.  All zeros indicates the begining of the file.
The 1b 62 0d is the hex representation of the data.
The .b. is the character representation of the data, where the dots represent unprintable characters.

Therefore, I believe you only need to send the 1b 62 0d.

I'm unfamiliar with your Telnet control, but assuming that the Send method can take a Byte array, you could use the following.

        Dim bytes As Byte() = {&H1B, &H62, &HD}
        Telnet1.Send(bytes)

Those bytes happen to have decimal values of 27, 98, and 13.  I got those values by putting a breakpoint on the Telnet1.Send line, and running to that line.  Then, while still in debug mode, I looked in the locals window (or menu Debug / Windows / Locals ).  
Hex 0d (dec 13) represents a carriage return, which makes sense at the end of a line.
I see what you are thinking but it didn't work for some reason it didnt work. I got a weird looking character.

This did work for F7

Telnet1.Send(Chr(27) & "[18~")

now why which is what is bugging me (I saw this in the raw data of the emulator) I don't have a clue.

The problem I am going nuts on is that what htey are calling F11 is the same as what htey are calling F5 and it is making F5 of course do F11' functions.

Lets do this. Do you know how I might say

(ShiftKey? & Chr(27) & "[23~")

"[23~" is the F11 code but I am oging to add a shift key to it to see if it changes the raw data.

(1) Those look like VT-??? codes for the keys.
Often a device is emulating a particular VT-terminal-type.  Is your device doing this?
Are you supposed to be using one particular terminal emulation with telnet to communicate with your device?  Which one? (This will help a lot.)

(I'm not saying it is, but ...)
If it's VT-320 emulation, see http://www.cs.utk.edu/~shuford/terminal/vt320.termcap.txt
Cryptic, isn't it!  It's not really as bad as it first looks.
Chunk it in blocks delimited by the colon ":" character.
For example:
       :k3=\EOR:k4=\EOS:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k0=\E[21~:\
means:
The k3 key sends \EOR, where \EOS means ESC "O" "R", then
the k4 key sends \EOS, where \EOS means ESC "O" "S",  then
the k6 key sends \E[17~, where \E[17~ means ESC "[17~", etc.
I think k1-k9 correspond to F1-F9, and k0 to k10, but I don't know what keyname corresponds to F11.
Maybe kI corresponds to F11, but I really don't know.
ESC is the same as Chr(27) in VB.NET.  From that info, it's pretty easy to write the VB.NET code.

(2) The codes sent for each F-key are configurable.  This explains how F5 and F11 can be the same.
http://www.oswego.edu/network/ncsa_config.html

(3) Make a clear distinction between (a) a keypress, and (b) the data sent over the wire for that key.  They are very different things.

---

If this worked for F7:
  Telnet1.Send(Chr(27) & "[18~")
and if the correct code for F11 is 23, then this should work for F11:
  Telnet1.Send(Chr(27) & "[23~")

The shift key has nothing to do with the data sent.  Shift-key is for input, not data transmission.
On the other hand, the shift key may (and probably does) cause the shift-F11 keypress to generate a different sequence, so maybe 23 is not right for shift-F11.  I suspect that ESC "[23~" is NOT the code the device is expecting for shift-F11. In other words, the codes sent for F11 can be completely different from the codes sent for shift-F11.


Yeah this is a ibm3151 system and the control uses vt100. I have been successful thus far in manipulating the situation to adapt to the 3151 by mimicing a vt240 terminal.

THe one lone stumbling block is F5.

I can communicate "F5" to the emulator by saying

Telnet1.Send(Chr(27) & Chr(101) & Chr(13)

but I cannot anticipate it in my case statement like I did the others so I can build waitfor and statements as such.

The one lead I have on this is "\27m" but I do not know how to say

Case Chr(27) & "m"   'F5 - does not work
                    Telnet1.Send(Chr(27) & "m")
also tried
Telnet1.Send(Chr(27) & Chr(101) & Chr(13)

Thank you much for your help. You seem to know your way around this stuff. I didnt think I would find anybody.

On the F11 situation this is what I came up with

Case Chr(27) & "[28~"   'what is being received when F11 is hit
                    Telnet1.Send(Chr(27) & "[23~") 'I send this and F11 functions perform. Again I do not know why.
Shoot

it is the same as F10. Now what do I do.....
Case Chr(27) & "[21~"   'F10
                    Telnet1.Send(Chr(27) & "[21~")
> the control uses vt100
You mean Telnet1 ?
Can you configure Telnet1 to emulate the VT240.
All these codes you need should be in the documentation for the VT240 or the the Telnet1 control.
ASCII table:  http://www.neurophys.wisc.edu/www/comp/docs/ascii.html

>  You seem to know your way around this stuff.
Not as much as it might seem.  I'm dredging a little up from my memory of many years ago.

It looks like you have the Telnet1.Send() and the Chr() down.  That takes care of how to send things.
Now all you need to do is find the right codes to send.

--- F5 ---
  Chr(27) & Chr(101) & Chr(13)    is equivalent to ESC "e" CR
but you talk about ESC "m"
That's inconsistent.  Why?

--- F11 ---
> 'I send this and F11 functions perform. Again I do not know why.
it's probably because the terminal you're sending to is emulating a different terminal type than the terminal you're typing at.  Therefore the codes sent by the keys are different.

---

> it is the same as F10.
Are you saying that both F5 and F10, when pressed on your terminal send the same code?
Are you also implying that the code you need to send to the remote terminal are different for F5 and F10?
If so, it seems like you'll need to either (1) use a different emulator you're typing into, (2) find a way to configure to redefine what that key sends, or (3) find/write something else to do the appropriate terminal emulation.
No I am afraid I cannot switch to that emulation I am afraid. For whatever reason it does nto work.

see
http://helpdesk.uvic.ca/how-to/support/mac/telnet/docs/MacTelnetapxB_4.html

towards the bottom of the page and it shows F5 and F10 being the same. The hex value it gives returns to [21~  which works great for F10 but not with F5.

This is a little maddening. I am trying to get my people off of ibm3151.
In your link http://helpdesk.uvic.ca/how-to/support/mac/telnet/docs/MacTelnetapxB_4.html
I don't see that it says F5 and F10 are the same.
It makes a distinction between the "VT" column which has F1 thru F15 and the "Key Name" column which has a F6 thru F20 in parentheses.  Which of these naming conventions is useful to you?  I'm assuming the VT column, because you keep mentioning F5, which doesn't exist at all in the "Key Name" column.

Using the VT names:

F5    ===>   9B 32 31 7E
                     CSI 2 1 ~
F10   ===>   9B 32 38 7E
                     CSI 2 8 ~
Ok lets really make this simple....

\27[17~ Is written like this:

Chr(27) & "[17~"

How would this be written:

\27m
ASKER CERTIFIED SOLUTION
Avatar of farsight
farsight

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perhaps it would be more meaningful to define a constant or variable once, and use it often.
Dim ESC As String = Chr(27)

then use

ESC & "[17~"
ESC & "m"
I need to send this keystroke to a vb.net application. This came from ethereal. Here is its value in "Hex Dump"

00000000  1b 65 0d                                         .e.


Here is its value in ASCII

e

Here is its value in EBCDIC

.

Here is its value in "C Arrays". I am not exactly sure what they mean here.

char peer0_0[] = {
0x1b, 0x65, 0x0d };


Does anyone know how I might utilize this to send what I need to in my vb.net windows app?
If you need to "send this keystroke to a vb.net application", you would use SendKeys().

Read tomazsr's last comment in this question:
https://www.experts-exchange.com/questions/20826444/SendKeys-with-external-runing-application.html

Here are several different alternatives you could use to create the string to send.
Use any one.  I prefer Option 4.

        ' The key sequence is: ESC e carriage-return
        Dim keys As String = Chr(&H1B) & Chr(&H65) & Chr(&HD)                                          ' Option 1

        Dim keys As String = Chr(&H1B) & "e" & vbCr                                                            ' Option 2

        ' If you have Imports Microsoft.VisualBasic (Included by default for VB projects)
        Const ESC As String = Chr(&H1B)
        Dim keys As String = ESC & "e" & vbCr                                                                      ' Option 3

        'If you have Imports System.Windows.Forms (Included by default for Windows Forms projects)
        Dim keys As String = Keys.Escape & "e" & Keys.Enter                                                  ' Option 4

Then use this line as shown in the link at the top.
       SendKeys.SendWait(keys)

Here's a nicer ASCII table.   http://www.cs.mun.ca/~michael/c/ascii-table.html
I don't think there is an answer but this needed to get closed.