perl uart controller
Perl supports UART and parallel port
Code:
use Device::SerialPort;
$pass;
$out;
$port = new Device::SerialPort ( "/dev/ttyS0");
$port->baudrate(9600);
$port->databits(8);
$port->stopbits(1);
$port->parity("none");
$i=1;
while($i){
$pass = $port->write('S$');
$j=0;
while ( $j==0){
$out = $port->input;
if ( $out ne '' ){
$_ = $out;
if ( m/S:/ ){
$string = '';
$string = $_ ;
}#end string start
elsif ( m/:$/ ){
$string = $string + $out ;
print $string;
$j=1;
$i='';
}#deal with the end stuff
else{
$string = $string + $out ;
}
}#end if for read out
}#close while $j
}#close while $i
NAME
Device:
arallelPort - Parallel Port Driver for Perl
SYNOPSIS
my $port = Device:
arallelPort->new();
$port->set_bit(3,1);
print $port->get_bit(3) . "\n";
print ord($port->get_byte(0)) . "\n";
$port->set_byte(0, chr(255));
DESCRIPTION
A parallel port driver module. This module provides an API to all parallel ports, by providing the ability to write any number of drivers. Modules are available for linux (both directly and via parport), win32 and a simple script version.
NOTE - This actual module is a factory class only - it is used to automatically return the correct class and has not other intelligence / purpose.
DRIVER MODULES
NOTE - You MUST load one of the drivers for your operating system before this module will correctly work - they are in separate CPAN Modules.
L<Device:
arallelPort::drv::linux> - Direct hardware access to a base address.
L<Device:
arallelPort::drv:
arport> - Linux access to /dev/parport drivers
L<Device:
arallelPort::drv::script> - Run a script with parameters
L<Device:
arallelPort::drv::dummy_byte> - Pretending byte driver for testing
L<Device:
arallelPort::drv::dummy_bit> - Pretending bit driver for testing
L<Device:
arallelPort::drv::win32> - Windows 32 DLL access driver
DEVICE MODULES
L<Device:
arallelPort:
rinter> - An example that can talk to a printer
L<Device:
arallelPort::JayCar> - Simple JayCar electronics latched, addressable controller
L<Device:
arallelPort::SerialFlash> - SerialFlash of bits - useful for many driver chips