Bruce32903 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,

I would like to expand some test equipment at work and it would require more serial ports than I currently have in the boxes. This puts me in a catch-22. I need to be able to say how long it will take and what tasks will be needed before I can get the green light from management, but I won't know the answers until I have done it.

The boxes are Intel Architecture running Ubuntu 7.04 and 7.10. The hardware is probably 3-5 years old. The versions of Perl and Device::SerialPort were all installed "fresh" over the last year or so. If I go down to my local clone shop and get some $20 cards:

1) Will the OS see them and automatically give me new ttyS1, ttyS2, etc. ports? (that Perl can use)

2) Will Device::SerialPort be happy to work or did it become system configuration dependent when I compiled it at install time?

3) Will the name of the serial ports (ttySn) remain stable or will they change every time I reboot? I learned the hard way that ethernet cards will "float" when installed later. It took a long time to trip accross the procedure of setting the MAC addresses in a special file. Is there a similar issue with adding serial ports to a system after the OS install?

4) Anything else I need to know?

5) I assume that someone will respond with "modprobe". I have Googled modprobe in the past and never really gotten a good feel for it. What is "modprobe"?

Thanks,
Bruce

  • Comment on Device::SerialPort and new RS-232 cards

Replies are listed 'Best First'.
Re: Device::SerialPort and new RS-232 cards
by oko1 (Deacon) on May 30, 2008 at 00:52 UTC

    'modprobe' is just a mechanism for loading modules (what Windows people think of as 'drivers'.) 'sudo modprobe serial' would load the 'serial.ko' module, which would allow you to access your ports - assuming that it's not already loaded (you can check that with 'lsmod'.)

    The important bit that you need to do is to configure the file that controls the assignment of your serial ports; that's done via 'setserial'. Look at 'man setserial' and '/etc/init.d/setserial'.

    For an excellent overall view, take a look at the serial HOWTO: http://tldp.org/HOWTO/Serial-HOWTO.html.

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    
Re: Device::SerialPort and new RS-232 cards
by Anonymous Monk on May 30, 2008 at 01:00 UTC

    modprobe is simply a Linux command to load a kernel module; a maybe-necessary prerequisite for working with hardware but probably not. (The udev facility will probably do that for you.)

    The real “issue” here is device-name stability. And, looking at the big-picture here, I don't think that you should have any assumption (much less dependency) concerning the mapping of device-names to the various pieces of equipment that you will need to be talking to.

    Essentially, you should assume that this mapping will change for one reason or another:   controller cards can move, cables can be moved, different Linux/Unix versions, and so-on. None of which have any meaning to anyone in terms of the actual application... who have the very odd tendency to give various devices names like “Sneezy” and “Grumpy.”

    Therefore... just let 'em do that. Set up a configuration file of some kind that allows them to map an arbitrary moniker to an arbitrary device-name:

    grumpy=/dev/ttys4
    And then refer to all devices, anywhere and everywhere, by those monikers.

    grumpy thus becomes an abstract, symbolic name that actually means something to somebody. When (not if...) someone moves cables around, only this file needs to be changed.

    If the devices in question have some way to identify themselves, e.g. a device serial-number query or some other kind of unique-identifier, then so much the better:   you can give your program both a list of devices to consider and (separately) a list of identifiers to seek.

Re: Device::SerialPort and new RS-232 cards
by zentara (Cardinal) on May 30, 2008 at 10:36 UTC
    modprobe will only load the necessary kernel modules to make the chipsets on your serialport card work. To test what port gets assigned to them, maybe check the boot logs, or maybe you could loop thru the possibilities and see what happens?
    #!/usr/bin/perl -w use Device::Modem; # fake array :-) I'm lazy foreach my $port qw( /dev/ttyS0 .. /dev/ttyS24 ){ my $modem = new Device::Modem( log =>'file,modemlog', port => $port ) || die "no $port: $!\n"; $modem->reset(); #hangup + attention + restore setting 0 (Z0) }

    I'm not really a human, but I play one on earth CandyGram for Mongo
      Thank you to the people that have responded so far.

      I'll proceed with the assumption that effort will be required beyond plugging in the cards. My current assumptions are:

      1) The OS will probably see the cards but there is risk of needing to figure out how to use modprobe if the cards are not seen.

      2) I should plan on 5-10 minutes to reinstall Device::SerialPort. I didn't expect this but I had to install Device::SerialPort on a box this morning. As I watched the build messages on the screen it appeared that the install was system configuration dependent.

      3) I am assuming that reinstalling Device::SerialPort will give me a new, clean configuration. If the new install won't cleanly cover up the old install then the old configuration might hang around to cause problems.

      4) It sounds like the port names might be unstable but the "setserial" command in the first response should fix them.

      Thanks,
      Bruce

        Also check your bios settings ( the basic computer settings).... many motherboards allow you to assign or disable onboard serial ports, or assign them irq settings, which will affect the ttyS* numbers.

        Additionally you can test the availability of ports without the perl module,

        open(PORT,"+>/dev/ttyS1") or die "Couldn't open serial port\n"; # etc etc
        If you have some spare diskdpace, and can take the time to setup a dual boot, try a full-featured OS like OpenSuSE. I found that it is the best at finding and setting up hardware.

        You might also want to look in your /dev after booting and see what ttyS* links there are. Some distros do it differently, they may be real devices or links to some subdir like tts/*

        Finally if you don't get the chipset recognized, because it is uncommon, or your distro didn't make a module for it, you can do an lspci (assuming it's a pci card) or hwinfo, etc., to get a list of the chipsets. Then you can google for the kernel patch or module to enable that chipset.


        I'm not really a human, but I play one on earth CandyGram for Mongo