Contents Up Previous Next

HiPi::Device::SerialPort

This module is a thin wrapper around the standard CPAN module Device::SerialPort.

It is implemeted to give a simple write only interface to the TX output pin for devices such as LCD controllers that accept commands on their RX pins without needing a connection on their TX pins. ( TX output pin on Raspberry Pi goes to RX input pin on device ).

For more complex interaction over a serial TX/RX link it is recommended to use Device::SerialPort directly.

Note that by default on the Raspberry Pi 3 the mini uart ( UART1 ) broken out via pins 14 and 15 on the GPIO header as the main UART0 is used for Bluetooth. See the the contstructor method notes below

The following interface modules use HiPi::Device::SerialPort as a backend and may contain code that helps with your own usage.

HiPi::Interface::SerLCD
HiPi::Interface::HTBackpackV2 ( as an optional backend )

Object Constructor and Methods

my $dev = HiPi::Device::SerialPort->new();
    Returns a new instance of the HiPi::Device::SerialPort class.

    You can optionally specify several parameters as key 
    value pairs in the constructor. Their default values
    are:

    my $dev = HiPi::Device::SerialPort->new(
        devicename   => '/dev/ttyAMA0',
        baudrate     => 9600,
        parity       => 'none',
        stopbits     => 1,
        databits     => 8,
    );

    The devicename is passed the Device::SerialPort constructor
    while all other parameters are used to set the corresponding
    Device::SerialPort object properties.

    If you are using a Raspberry Pi 3 with default settings, the header pins
    on the Rpi gpio are connected to the mini uart. You will therefore need
    to specify the mini uart device to override the default.

    my $dev = HiPi::Device::SerialPort->new(
        devicename   => '/dev/ttyS0',
    );
 
$dev->write( $buffer );
    Writes the $buffer to the open port using Device::SerialPort->write.
    Then calls Device::SerialPort->write_drain.




Contents Up Previous Next


HiPi Modules Copyright © 2013 - 2016 Mark Dootson