Difference between revisions of "Install serial port"
From xPL
(→Serial port device) |
(→Serial port device) |
||
Line 29: | Line 29: | ||
Download the [http://www.dspc.ch/xPL/Downloads/xpl-serial_port.pl serial port xPL device]. | Download the [http://www.dspc.ch/xPL/Downloads/xpl-serial_port.pl serial port xPL device]. | ||
+ | |||
+ | Move the script to xPL scripts directory: | ||
+ | SCRIPTS_BASE_DIR=/home/control/Documents/Controls | ||
+ | mv xpl-serial_port.pl $SCRIPTS_BASE_DIR | ||
+ | |||
+ | Test it on a [[install BeagleBone|BeagleBone]]: | ||
+ | ll /dev/ttyO* | ||
+ | $SCRIPTS_BASE_DIR/xpl-serial_port.pl -v -n test /dev/ttyO1 baudrate 9600 databits 8 parity none stopbits 1 handshake none | ||
+ | |||
+ | Open a 2nd terminal window (on any machine with xPL installed) and monitor the xPL protocol: | ||
+ | $SCRIPTS_BASE_DIR/xpl-monitor.pl -vf | ||
+ | |||
+ | The monitor should echo the serial port incoming messages. | ||
+ | |||
+ | Open another terminal and send a message to the serial port: | ||
+ | su control | ||
+ | SCRIPTS_BASE_DIR=/home/control/Documents/Controls | ||
+ | $SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.test -c serPort.basic command='hello world' |
Revision as of 16:59, 16 March 2014
Many devices are controlled over an RS-232 serial port.
CPAN serial port module
The xPL serial port device bases on the Perl CPAN Device::SerialPort module.
Open a terminal and login as root.
Update CPAN:
perl -MCPAN -e shell > install LWP > reload LWP > install CPAN > reload CPAN > install YAML > q
Check if the serial port driver is already installed:
perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' 2> /dev/null | grep -i serial
Install the serial port driver:
perl -MCPAN -e "install 'Device::SerialPort'"
Alternatively, on Ubuntu:
apt-get install libdevice-serialport-perl
Serial port device
Download the serial port xPL device.
Move the script to xPL scripts directory:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls mv xpl-serial_port.pl $SCRIPTS_BASE_DIR
Test it on a BeagleBone:
ll /dev/ttyO* $SCRIPTS_BASE_DIR/xpl-serial_port.pl -v -n test /dev/ttyO1 baudrate 9600 databits 8 parity none stopbits 1 handshake none
Open a 2nd terminal window (on any machine with xPL installed) and monitor the xPL protocol:
$SCRIPTS_BASE_DIR/xpl-monitor.pl -vf
The monitor should echo the serial port incoming messages.
Open another terminal and send a message to the serial port:
su control SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.test -c serPort.basic command='hello world'