Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Calling hyper terminal and executing commands in hyper terminal from Perl

by Sinistral (Monsignor)
on Mar 30, 2010 at 00:09 UTC ( [id://831735]=note: print w/replies, xml ) Need Help??


in reply to Calling hyper terminal and executing commands in hyper terminal from Perl

Since you specifically mention Hyper Terminal, I'm guessing you are running some flavor of Microsoft Windows. That being said, you might want to check out Win32::SerialPort to programmatically interact with the serial port directly, rather than somehow remotely controlling Hyper Terminal

If you really really want to somehow automate interaction with Hyper Terminal (and that's a not so subtle hint that you probably don't), the canonical Perl module for mucking about with Windows applications is Win32::GuiTest.

Replies are listed 'Best First'.
Re^2: Calling hyper terminal and executing commands in hyper terminal from Perl
by mykl (Monk) on Mar 30, 2010 at 11:51 UTC

    I agree that Win32::SerialPort is the way to go, I have used it myself. The API is not simple and the docs are none too clear, though, so I made my own wrapper to make it simpler to use. In case it is of use to you, I am including below my wrapper class (called Win32::RS232Port) and some snippets from an application of mine that use it.

    The Win32::RS232Port class:

    An example of using the Win32::RS232Port (The app uses the classic hashref-as-object OO style, which is why the serial port object is stored in $self->{serport}):

    # open serial port, create instance of Win32::RS232Port object $self->{serport} = Win32::RS232Port->new($comport_name, handshake => +'rts', baudrate => 9600); if (!defined $self->{serport}) { die "Could not open reference COM por +t"; } # manually set state of handshaking output lines: $self->{serport}->rts_active(1); $self->{serport}->dtr_active(1); # transmit some data: $self->{serport}->qtx("SYST:ERR?\r\n"); sub poll { # call this function regularly to check for received data and to p +ass on any queued data for transmission my $self = shift; if ( defined $self->{serport} ) { # pass on any queued data for transmission $self->{serport}->poll_tx; # handle incoming data: here I'm just appending it to $self->{ +com_rxd} where it can be picked up by code that's interested. my $rx = $self->{serport}->rx_data; if ($rx ne q{}) { $self->{com_rxd} = q{} if !defined $self->{com_rxd}; $self->{com_rxd} .= $rx; } } } sub wait_for_tx_done { my $self = shift; my $tstart = time; while (defined $self->{serport} && $self->{serport}->tx_pending) { $self->poll(); die "Timeout on serial port transmission\n" if time > $tstart ++ 10; } } # close the serial port $self->{serport}->close();

    --

    "Any sufficiently analyzed magic is indistinguishable from science" - Agatha Heterodyne

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://831735]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-29 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found