#!/usr/bin/perl

use strict;
use Device::SerialPort;

my $noat = 0;
if ($ARGV[0] eq "-x")
{
	$noat = 1;
	shift;
}

my $dev = (glob("/dev/tty.usb*"))[0] || die "no device!\n";
if ($ARGV[0] =~ /tty/)
{
	$dev = shift;
}

print STDERR "Using $dev\n";
my $port = new Device::SerialPort($dev) || die "$! $@";
$port->baudrate(57600);
$port->databits(8);
$port->parity("none");
$port->stopbits(1);
$port->stty_echo(0);

$|++;
while (<STDIN>)
{
	$port->write($_);
	my $c = $port->lookfor();
	print $c;
}
