Difference between revisions of "Install serial port"

From xPL
Jump to: navigation, search
(Serial port device)
(CPAN serial port module)
Line 9: Line 9:
  
 
Update [http://www.cpan.org CPAN]:
 
Update [http://www.cpan.org CPAN]:
 +
su
 
  perl -MCPAN -e shell
 
  perl -MCPAN -e shell
 
   > install LWP
 
   > install LWP

Revision as of 17:12, 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:

su
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

Install xPL 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
chown control:users $SCRIPTS_BASE_DIR/*.pl
chmod 775 $SCRIPTS_BASE_DIR/*.pl

Test xPL serial port device

Test it on a BeagleBone:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
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=/home/control/Documents/Controls
$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'