Home All Groups Group Topic Archive Search About

Write commands to the COM port

Author
21 Sep 2006 12:54 PM
Ivovh
Hi,

I am writing a application that should be able send commands to a device
using the COM port.

I have tested the commands with hyper terminal and there they work. For
Example I press: Escape then shift-x then shift-j and the device does what
its suppose to do.

No I made a little programma that connects to the comport. I use
comport.Write() to send commands but I have no idea how I should send the
escape and the shift to the comport.  And I what format I should send
command hex/ascii??

Anybody got some suggestions?

Author
21 Sep 2006 1:15 PM
Chris Dunaway
Ivovh wrote:
Show quoteHide quote
> Hi,
>
> I am writing a application that should be able send commands to a device
> using the COM port.
>
> I have tested the commands with hyper terminal and there they work. For
> Example I press: Escape then shift-x then shift-j and the device does what
> its suppose to do.
>
> No I made a little programma that connects to the comport. I use
> comport.Write() to send commands but I have no idea how I should send the
> escape and the shift to the comport.  And I what format I should send
> command hex/ascii??
>
> Anybody got some suggestions?

Escape should be Chr$(26) and shift-x and shift-j are just capital X
and capital J.  You could construct a string like this:

Dim commandString As String = Chr$(26) & "XJ"

and try sending that string.
Author
21 Sep 2006 1:42 PM
Ivovh
TY this was the solution :)

Show quoteHide quote
"Chris Dunaway" <dunaw***@gmail.com> schreef in bericht
news:1158844557.631173.314570@h48g2000cwc.googlegroups.com...
> Ivovh wrote:
>> Hi,
>>
>> I am writing a application that should be able send commands to a device
>> using the COM port.
>>
>> I have tested the commands with hyper terminal and there they work. For
>> Example I press: Escape then shift-x then shift-j and the device does
>> what
>> its suppose to do.
>>
>> No I made a little programma that connects to the comport. I use
>> comport.Write() to send commands but I have no idea how I should send the
>> escape and the shift to the comport.  And I what format I should send
>> command hex/ascii??
>>
>> Anybody got some suggestions?
>
> Escape should be Chr$(26) and shift-x and shift-j are just capital X
> and capital J.  You could construct a string like this:
>
> Dim commandString As String = Chr$(26) & "XJ"
>
> and try sending that string.
>
Author
21 Sep 2006 2:56 PM
Andrew Morton
Chris Dunaway wrote:
> Escape should be Chr$(26)

Er, no... it Chr$(27), aka ctrl-open-square-bracket. Chr$(0),
Chr$(1)...Chr$(26) are ctrl-@, ctrl-A...ctrl-Z.

I don't know, young people these days - you'd think they'd never controlled
an FX-80 by typing escape sequences on a keyboard :-)

Andrew
Author
22 Sep 2006 1:12 PM
Chris Dunaway
Andrew Morton wrote:
> Chris Dunaway wrote:
> > Escape should be Chr$(26)
>
> Er, no... it Chr$(27), aka ctrl-open-square-bracket. Chr$(0),
> Chr$(1)...Chr$(26) are ctrl-@, ctrl-A...ctrl-Z.
>
> I don't know, young people these days - you'd think they'd never controlled
> an FX-80 by typing escape sequences on a keyboard :-)
>
> Andrew.

Thanks Gramps! :)

I must be getting old,  don't know why I forgot that!
Author
21 Sep 2006 4:48 PM
Dick Grier
Hi,

If HyperTerminal worked, then you can use simple Strings (ASCII).  For an
example, try the VS2005 Terminal example from my homepage.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.