RPC with PERL

18 Feb 2014

Tested under Ubuntu. You only need to add Perl Device/SerialPort.pm to your Linux box. If you are using Windoz please change /dev/ttyACM0 with your COMx: port.

RPC PERL Sample

#!/usr/bin/perl

use Device::SerialPort;

#
# Lets set the comm parameters with MBED
#
my $port = Device::SerialPort->new("/dev/ttyACM0");
$port->databits(8);
$port->baudrate(9600);
$port->parity("none");
$port->stopbits(1);
#
#Lets define RPC object 
#
$port->write("/DigitalOut/new LED1 myled\n");

#
# Blink LED1 
#

while(1) {
        $port->write("/myled/write 1\n");
        sleep(1);
        $port->write("/myled/write 0\n");
        sleep(1);
}