#!/usr/bin/perl -w
# cross-platform example5

use strict;
use vars qw( $OS_win $ob $file );

BEGIN {
        $OS_win = ($^O eq "MSWin32") ? 1 : 0;
        if ($OS_win) {
            eval "use Win32::SerialPort 0.11";
	    die "$@\n" if ($@);
        }
        else {
            eval "use Device::SerialPort";
	    die "$@\n" if ($@);
        }
} # End BEGIN

$file = 'tpj4.cfg';

if ($OS_win) {
    $ob = Win32::SerialPort->start ($file);
}
else {
    $ob = Device::SerialPort->start ($file);
}
die "Can't open serial port from $file: $^E\n" unless ($ob);

my $baud = $ob->baudrate;
print "baud from configuration: $baud\n";

$ob->write("ATE0X4\r");
sleep 1;
my $result = $ob->input;
print "result = $result\n";

$ob->write("AT&V\r");
sleep 2;
$result = $ob->input;
print "result = $result\n";

undef $ob;
