in reply to Unusual error in Win32::SerialPort (Missing REQUIRED setting for BAUD)

Reading the code, I notice several things. (1) You can $Serial->user_msg(1), $Serial->error_msg(1), $Serial->debug(1) to get more error output.

The most likely cause of your problem is that the CommProperties is not giving 115200 as an available baudrate. To see this, try print "baud rate: ", join(" ", $Serial->baudrate), "\n"; just after the new() and see what it says.

You can override this after the new and before the baudrate by giving it some new ones:

$Serial->{"_L_BAUD"}{115200} = 115200;
Let us know if that helps.

Replies are listed 'Best First'.
Re: Re: Unusual error in Win32::SerialPort (Missing REQUIRED setting for BAUD)
by BronzeWing (Monk) on May 21, 2003 at 15:36 UTC

    Perfect, it worked exactly as you said. Printing the available baud rates showed that 115200 was missing, and adding it to $Serial->{"_L_BAUD"} made everything work right. Thanks very much for your help!

    -BronzeWing

      Hi! I am also working on the Win32::SerialPort. I tried the debug method mentioned above and got this response back, baud rate: 115200 1200 38400 4800 2400 600 57600 19200 9600 300. What does that mean? Does that mean I can only use those baudrates in my perl script? Please let me know. Thanks.

        What other baud rate would you want to use?

        And yes, it seems that Win32::SerialPort wants a baud rate configured before doing any interesting stuff. But without seeing code, it's kinda hard to tell exactly.

        I want to use baudrate such as, 921600 or 230400 or some higher baudrates. I tried to stick in this line here for 921600 since it seems to be working in the previous thread. Here is my code. $PortObj$devNum = Win32::SerialPort->new ($PortName, $quiet) || die "Cant open $PortName: $^E\n"; # quiet is optional unless (defined($PortObj$devNum)) { &logout("openUart ... new failed\n"); return 0; } $PortObj$devNum->{"_L_BAUD"}{921600} = 921600; #$PortObj$tmpDevNum->debug(1); #$PortObj$tmpDevNum->debug_comm(1); #print("\t set options\n"); $PortObj$devNum->baudrate("$baudrate"); But when I do this later, I don't see 921600 shows up in the list. print "baud rate: ", join("",$PortObj$devNum->baudrate),"\n"; Thanks.
        Hi, i tried the same but it is not working for me. With the print statement i am getting error as "Can't call method "baudrate" on an undefined value at serialport_logger.pl line 36" with the _L_BAUD setting i am getting the same error as "Missing REQUIRED setting for STOP at serialport_logger.pl line 42 write_settings failed, closing port at serialport_logger.pl line 42 no settings at serialport_logger.pl line 42." can anyone help me on this?????????
Re^2: Unusual error in Win32::SerialPort (Missing REQUIRED setting for BAUD)
by Anonymous Monk on Aug 28, 2013 at 15:51 UTC
    I experienced the same error but it seems not related to what you discussed. I tried all your suggestions, but it did not work. Or at least partially did not work. The suggestion works if you have an unlisted baudrate. But the problem persists if you try to pass the baudrate by a variable and not by a code literal constant. That is: $Serial->baudrate(38400); # works $Serial->baudrate($baud_rate); # with $baud_rate containing 38400, does not work

      Can you post minimal code needed to reproduce the error? Also, what version of Win32::SerialPort and Perl are you using?

      Looking at some old code of mine that used Win32::SerialPort, my code did do something along the lines of $serial->baudrate($baudrate); and it did work.

      Out of curiosity, did you happen set the value of $baudrate like $baudrate = "38400";? If so, try changing that to be $baudrate = 38400; instead.

      Try $Serial->baudrate(0+$baud_rate).

      - tye        

        Thank you. But it does not work. Nor work similar other tricks like:

        $Serial->baudrate(0+$baud_rate)

        $Serial->baudrate(int($baud_rate))

        $Serial->baudrate("$baud_rate")

        $Serial->baudrate(eval{$baud_rate})

        I don't know what it may be

        Thank you. But it does not work. Nor work similar other tricks like:

        $Serial->baudrate(int($baud_rate)) $Serial->baudrate("$baud_rate") $Serial->baudrate(eval{$baud_rate})

        The following seems to work (in the sense that it does not produces an error message), but the serial stream does not have the baudrate it is supposed to have

        $Serial->{"_L_BAUD"}{$baud_rate} = $baud_rate; $Serial->baudrate($baud_rate);

        I don't know what it may be