<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I had a request for another look at the code for the serial cable.
Here are the two pieces.<br>
<br>
-Bill<br>
<br>
<br>
com2sock.pl:<br>
<br>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<title></title>
<meta name="GENERATOR" content="OpenOffice.org 1.9.118 (Linux)">
<meta name="CREATED" content="20050930;12474600">
<meta name="CHANGED" content="16010101;0">
<style>
        <!--
                @page { size: 8.5in 11in; margin: 0.79in }
                P { margin-bottom: 0.08in }
        -->
        </style>
<pre>#!/usr/bin/perl
#use strict;
use IO::Socket;
use Device::SerialPort;
$com2 = Device::SerialPort->start ("/usr/local/work/cuaa0.cfg") or die "Can't start COM1\n";
my ($remote, $port, $iaddr, $paddr, $proto, $line, $buf);
$remote = '123.123.123.123';
$port = 12; # random port
$iaddr = inet_aton($remote) || die "no host: $remote";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
$data = '';
while(1) {
if ($data = $com2->input) {
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "no connecty...\n";
$buf = $data;
print SOCK $data;
close SOCK;
$data = "0";
}
}</pre>
<br>
sock2com.pl:<br>
<br>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<title></title>
<meta name="GENERATOR" content="OpenOffice.org 1.9.118 (Linux)">
<meta name="CREATED" content="20050930;12481700">
<meta name="CHANGED" content="16010101;0">
<style>
        <!--
                @page { size: 8.5in 11in; margin: 0.79in }
                P { margin-bottom: 0.08in }
        -->
        </style>
<pre>#!/usr/bin/perl
#use strict;
use IO::Socket;
use Device::SerialPort;
$com2 = Device::SerialPort->start ("/usr/local/work/cuaa0.cfg") or die "Can't start COM1\n";
$sock = new IO::Socket::INET (LocalHost => '123.123.123.123',
LocalPort => 10,
Proto => 'tcp',
Listen => 5,
Reuse => 1 );
die "No Socket because: $! \n" unless $sock;
while ($new_sock = $sock->accept()) {
while (defined ($buf = <$new_sock>)) {
#print "$buf\n";
$com2->write($buf);
print $new_sock "Thanx\n";
}
}
close ($sock);
</pre>
<br>
</body>
</html>