Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Unusual error in Win32::SerialPort (Missing REQUIRED setting for BAUD)

by Anonymous Monk
on Aug 28, 2013 at 15:51 UTC ( [id://1051299]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^3: Unusual error in Win32::SerialPort (Missing REQUIRED setting for BAUD)
by dasgar (Priest) on Aug 28, 2013 at 23:25 UTC

    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.

Re^3: Unusual error in Win32::SerialPort (Missing REQUIRED setting for BAUD) (guess)
by tye (Sage) on Aug 28, 2013 at 16:40 UTC

    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

        It was my fault. The code was in a subroutine where $baud_rate was passed by reference and used as if it were passed by value. After correcting the mistake the following construct worked perfectly:
        $Serial->{"_L_BAUD"}{$baud_rate} = $baud_rate; $Serial->baudrate($baud_rate);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1051299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found