1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
my $sortie="F:\\Cours\\TX\\resultat.txt";
my $entree="F:\\Cours\\TX\\essai.txt";
my $port_entree="COM1"; #Choix du port série sur COM1
my $port_sortie="COM2";
my $speed="96"; #Vitesse 11=110Baud/15=150Baud/30=300Baud/60=600Baud/12=1200Baud/24=2400Baud/48=4800Baud/96=9600Baud/19=19200Baud
my $parity="n"; #Parité n=none/e=even/o=odd=m=mark/s=space
my $bit="8"; #bit de donnée 5 à 6 bits
my $bitStop="1"; #bit de stop 1 ou 2
my $protoc=",x"; #Protocol ",x": XON/XOFF ",p": HANDSHAKE, "": Aucun
my $test="";
my $term="M30";
my $ligne;
my $buff;
my $i="0";
if (!($entree eq ""))
{
system "mode $port_entree:$speed,$parity,$bit,$bitStop $protoc";
system "mode $port_sortie:$speed,$parity,$bit,$bitStop $protoc";
#Configuration PORT série avec commande MS-DOS MODE
open PORT_ENTR, "<$port_entree" or die "Impossible d'ouvrir ";
open PORT_SORT, "+>$port_sortie" or die "Impossible d'ouvrir ";
open ENTREE, "<$entree" or die "Impossible d'ouvrir ";
open SORTIE, "+>$sortie" or die "Impossible d'ouvrir le fichier ";
print("Emission en cours, patientez....\n");
while ($ligne = <ENTREE>)
{
print PORT_SORT $ligne;
print($ligne);
}
print("Réception en cours, patientez....\n");
while (read( PORT_ENTR, $buff, 1))
{
print ("ligne ".$i." : ".$buff."\n");
print SORTIE $buff;
print ("a");
$i=$i+1;
}
print("Transmission OK\n");
close(PORT_ENTR);
close(PORT_SORT);
close(ENTREE);
close(SORTIE);
}
else
{
print("erreur fichier");
} |
Partager