Koozali.org: home of the SME Server

How to install perl Device::SerialPort

Offline Uncle

  • 20
  • +0/-0
How to install perl Device::SerialPort
« on: March 02, 2009, 09:01:44 AM »
I have VERY little knowledge of anything to do with Linux so I am super stuck tryna install the Device::SerialPort module for perl!

I've read about using Yum and rpm's and things like that but I honestly have no idea what to do :( I've googled and searched and come across rpm's for this but the target platform was either RedHat or Fedora and nothing for CentOS. I've seen how to call stuff through yum and that but I don't know WHAT to specify in the arguments and things.

This is not for my own server so i wanna make 100% sure I do the right thing.

Can anybody help me with this? Otherwise will have to rewrite the perl script that needs this! AHHH!!

EDIT: Using SME Server 7.3

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: How to install perl Device::SerialPort
« Reply #1 on: March 02, 2009, 10:01:25 AM »
What are you trying to accomplish with this script? Perhaps there is an alternative.

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #2 on: March 02, 2009, 10:35:34 AM »
It's pretty much just reading incoming data from the serial port and then inserting it into a MySQL DB.

The MySQL part is okay as far as I can tell, it's just the serial comms I need to sort out. I'm not experienced with perl either *cough* so I've taken the clearest way of handling that side of things. Put the serial comms I use below.

Code: [Select]
my $loSerial = new Device::SerialPort (PORT);
 
  #Configure the port.
  $loSerial->baudrate(BAUD)   || (Log("ERROR - ERR06 Failed setting baud rate.")    && die("ERROR - ERR06 Failed setting baud rate."));
  $loSerial->parity(PRTY)     || (Log("ERROR - ERR05 Failed setting parity.")       && die("ERROR - ERR05 Failed setting parity."));
  $loSerial->databits(DBTS)   || (Log("ERROR - ERR04 Failed setting data bits.")    && die("ERROR - ERR04 Failed setting data bits."));
  $loSerial->stopbits(SBTS)   || (Log("ERROR - ERR03 Failed setting stop bits.")    && die("ERROR - ERR03 Failed setting stop bits."));
  $loSerial->handshake(FLOW)  || (Log("ERROR - ERR02 Failed setting flow control.") && die("ERROR - ERR02 Failed setting flow control."));
 
  if (open(DEV, "< ".PORT.""))
  {
    my $loInfo= "";
   
    #Read incoming data.
    while($_ = <DEV>)
    {
      $loInfo .= $_;
      if (length($loInfo) >= MSGLEN)
      {
        #Process the info and store it in the database.
        Process(substr($loInfo, 0, MSGLEN));
       
        $loInfo = substr($loInfo, MSGLEN);
      }
      sleep(0.1);
    }
  } else
  {
    Log("ERROR - ERR01 Can't open ".PORT.": $!") && die("ERROR - ERR01 Can't open ".PORT.": $!");
  }

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: How to install perl Device::SerialPort
« Reply #3 on: March 02, 2009, 10:49:43 AM »
Okay, according to the home page for this Perl module, it emulates Win32 serial functions on UNIX/Linux.

Luckily, the dag repository has this module pre-compiled in the package perl-Device-SerialPort. So give it a go by configuring the Dag repository and then issuing the following command:

Code: [Select]
yum --enablerepo=dag install perl-Device-SerialPort
signal-event post-upgrade ; signal-event reboot

Then try your script again.

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #4 on: March 02, 2009, 12:34:37 PM »
Okay, I did the dag configuration as per the link and tried running
Quote
yum --enablerepo=dag install perl-Device-SerialPort
but it says another copy is running and aborts. Checked using ps -x and
Quote
2977 ?        Ss     0:00 runsv yum
is listed.

Any ideas?

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: How to install perl Device::SerialPort
« Reply #5 on: March 02, 2009, 12:36:40 PM »
Wait a while and try again.

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #6 on: March 02, 2009, 12:43:08 PM »
That's a quick reply!!

Waited a bit and it ran but now have this problem :(

Quote
==============================================================
WARNING: Additional commands may be required after running yum
==============================================================
Loading "smeserver" plugin
Loading "fastestmirror" plugin
Setting up Install Process
Setting up repositories
http://apt.sw.be/redhat/el4/en/i386/dag/repodata/repomd.xml: [Errno 4] IOError: <urlopen error (-3, 'Temporary failure in name resolution')>
Trying other mirror.
Cannot open/read repomd.xml file for repository: dag
failure: repodata/repomd.xml from dag: [Errno 256] No more mirrors to try.
Error: failure: repodata/repomd.xml from dag: [Errno 256] No more mirrors to try.

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: How to install perl Device::SerialPort
« Reply #7 on: March 02, 2009, 12:46:14 PM »
Not your day, is it? Make sure your Internet connection is all in one piece and that the site is accessible:

Code: [Select]
ping -c 4 apt.sw.be

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #8 on: March 02, 2009, 12:58:01 PM »
From the command prompt (using PuTTY) there is no response but using a laptop routing through the SME server and proxy there is a response :(

How does that make any sense?

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: How to install perl Device::SerialPort
« Reply #9 on: March 02, 2009, 01:00:15 PM »
Well, that's why yum isn't working - something is going wrong with the server's connection to the Internet.

My guess is that you will have to configure the server (and yum) to use your proxy server. Alternatively, can you just plug it up to the Internet directly?

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #10 on: March 02, 2009, 01:11:35 PM »
Good news... the server I was accessing is the backup which is isolated from the world and only has LAN access *dies* so I will noW attempt this on the live server which IS connected!

Stay tuned....

...

...


Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: How to install perl Device::SerialPort
« Reply #11 on: March 02, 2009, 01:12:42 PM »
What do you mean by dies? Do you get an error message of some kind?

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #12 on: March 02, 2009, 01:35:54 PM »
:3 Nope, I meant me!

Everything appears to be working just fine now with perl. It all gets interpreted without errors and is happy. Only problem is now I can't get any comms from the serial port! Have tried tty0 and tty1 with the script but if I ls -l within /dev/ then only shm and ptmx have been modified today. Any ideas??

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: How to install perl Device::SerialPort
« Reply #13 on: March 02, 2009, 02:34:40 PM »
Have tried tty0 and tty1 with the script ...

Those aren't serial ports. They are console screens. Try ttyS0 and ttyS1.

Offline Uncle

  • 20
  • +0/-0
Re: How to install perl Device::SerialPort
« Reply #14 on: March 02, 2009, 03:23:13 PM »
That did the trick. Thanks a lot guys you made my day!!