Difference between revisions of "Install serial port"

From xPL
Jump to: navigation, search
(Serial port device)
(Serial port device)
Line 26: Line 26:
 
  apt-get install libdevice-serialport-perl
 
  apt-get install libdevice-serialport-perl
  
= Serial port device =
+
= Install xPL serial port device =
  
 
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].
Line 33: Line 33:
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  mv xpl-serial_port.pl $SCRIPTS_BASE_DIR
 
  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 [[install BeagleBone|BeagleBone]]:
 
Test it on a [[install BeagleBone|BeagleBone]]:
 +
su control
 +
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  ll /dev/ttyO*
 
  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
 
  $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:
 
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
 
  $SCRIPTS_BASE_DIR/xpl-monitor.pl -vf
  

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

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'