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 new method notes below
The following interface modules use HiPi::Device::SerialPort as a backend and may contain code that helps with your own usage.
Create a new instance of the HiPi::Device::SerialPort class.
use HiPi::Device::SerialPort; my $dev = HiPi::Device::SerialPort->new; # 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', );
Write a buffer to the serial port
$device->write( $buffer );