Solved

ASCII Conversions (I think)

Posted on 2004-03-28
18
559 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:scorpion53061
18 Comments
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Your question is not clear, can you give mode details?
0
 
LVL 4

Expert Comment

by:Jarodtweiss
Comment Utility
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
0
 

Author Comment

by:scorpion53061
Comment Utility
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?
0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
>    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.
0
 

Author Comment

by:scorpion53061
Comment Utility
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.

0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
(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.


0
 

Author Comment

by:scorpion53061
Comment Utility
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.
0
 

Author Comment

by:scorpion53061
Comment Utility
Shoot

it is the same as F10. Now what do I do.....
Case Chr(27) & "[21~"   'F10
                    Telnet1.Send(Chr(27) & "[21~")
0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
> 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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:scorpion53061
Comment Utility
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.
0
 

Author Comment

by:scorpion53061
Comment Utility
http://www.kolej.mff.cuni.cz/info/navod/dos/telnet.key

middle of page gives the \27m value
0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
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 ~
0
 

Author Comment

by:scorpion53061
Comment Utility
Ok lets really make this simple....

\27[17~ Is written like this:

Chr(27) & "[17~"

How would this be written:

\27m
0
 
LVL 12

Accepted Solution

by:
farsight earned 500 total points
Comment Utility
Chr(27) & "m"
0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
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"
0
 

Author Comment

by:scorpion53061
Comment Utility
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?
0
 
LVL 12

Expert Comment

by:farsight
Comment Utility
If you need to "send this keystroke to a vb.net application", you would use SendKeys().

Read tomazsr's last comment in this question:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20826444.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
0
 

Author Comment

by:scorpion53061
Comment Utility
I don't think there is an answer but this needed to get closed.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now