67 lines
1.7 KiB
Perl
67 lines
1.7 KiB
Perl
#!/usr/bin/perl
|
|
#################################################################################
|
|
# #
|
|
# transfer tool for chipbasic verion 1.10 #
|
|
# copyright (c) 2006 Joerg Wolfram (joerg@jcwolfram.de) #
|
|
# #
|
|
# #
|
|
# This program is free software; you can redistribute it and/or #
|
|
# modify it under the terms of the GNU General Public License #
|
|
# as published by the Free Software Foundation; either version 2 #
|
|
# of the License, or (at your option) any later version. #
|
|
# #
|
|
# This program is distributed in the hope that it will be useful, #
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU #
|
|
# General Public License for more details. #
|
|
# #
|
|
# You should have received a copy of the GNU General Public #
|
|
# License along with this library; if not, write to the #
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, #
|
|
# Boston, MA 02111-1307, USA. #
|
|
# #
|
|
#################################################################################
|
|
$dir=$ARGV[0];
|
|
$fname=$ARGV[1];
|
|
|
|
system `stty 2400 cs8 -parenb -echo -crtscts -ixon < /dev/ttyS0`;
|
|
|
|
if ($dir eq "-r")
|
|
{
|
|
print "waiting for data... ";
|
|
open (PFIL, ">$fname");
|
|
open (SER, "/dev/ttyS0");
|
|
$rstop=0;
|
|
while ($rstop == 0)
|
|
{
|
|
$data=<SER>;
|
|
$data=~ s/\r//g;
|
|
print PFIL $data;
|
|
if ($data=~ /^\#/)
|
|
{
|
|
$rstop=1;
|
|
}
|
|
print "*";
|
|
}
|
|
|
|
close(SER);
|
|
print " done\n";
|
|
close(PFIL);
|
|
}
|
|
|
|
if ($dir eq "-w")
|
|
{
|
|
print "sending data... ";
|
|
open (PFIL, "$fname");
|
|
open (SER, ">/dev/ttyS0");
|
|
while (<PFIL>)
|
|
{
|
|
$data=$_;
|
|
print SER $data;
|
|
print "*";
|
|
}
|
|
close(SER);
|
|
print " done\n";
|
|
close(PFIL);
|
|
}
|