in reply to Win32::SerialPort Query Current Values

The module can't do it because the machine can't do it. The host can not know the connection characteristics of the client device without 'sucking it to see'. If you know that you are getting a stream of characters from the client device (a serial connection to a GPS for example), then you can configure the host for different parameters until you get sensible data from the client. That is not a general solution to the problem however.

Note that the number of stop bits can be set to 2 without affecting receiving characters from the client. Probably hand shake can be safely set to none, at least to get going. Parity can generally be set to none, at least for determining baud rate if data bits is set to 8 and the high bit is ignored. That really just leaves the baud rate to be determined.


True laziness is hard work
  • Comment on Re: Win32::SerialPort Query Current Values

Replies are listed 'Best First'.
Re^2: Win32::SerialPort Query Current Values
by spickles (Scribe) on Sep 21, 2009 at 21:03 UTC
    So if I wanted to determine the settings on a serial connection, I'd have to call the program several times with settings that I guess and save the output to a file. When I get readable output back, I know I have the right settings. Is that about right?

      Tell us more about what you are trying to achieve and we may be able to help more. Running a program several times doesn't sound like a sensible use of a computer to me. I'd be writing the code to make the guesses and test the outcomes - run one program once and let the computer do the hard work.


      True laziness is hard work
        GrandFather -

        Here is what I'd like to do:
        We have a Cisco box that doesn't output anything on the Console line other than jibberish. This is often due to just to a mismatch between the settings on the device and the settings on the COM port used to connect. So before we ditch this box for having a bad console port, I'd like to have my script 'query' the console port and get its settings (if that's at all possible). Right now, when I run my program all it does is return the values that are set by me on my COM port on the PC. What I want is the program to tell me what the current settings are on the switch. We got this switch off of Craigslist for twenty bucks, and we can't do a thing with it until we can get a console connection. Because of the age of the switch (circa 2000) there's no hardware reset that we know of. We've cracked it open and tried serial connection headers and shorting pins, but no luck. So if it isn't possible to have the device cough up its current settings using Win32::SerialPort, perhaps it's possible with another module? If it isn't possible at all, meaning I don't fully understand the way a serial port works, then it was my thought to have the script keep all variables constant except for one (like baudrate) and modify its value sequentially. Then I would send some characters to the device and record the output. When I get something back I can read, I know I've got the right settings.

        Regards,
        Scott