Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: RS232, parity, program flow

by Marshall (Canon)
on Jan 19, 2022 at 11:17 UTC ( #11140605=note: print w/replies, xml ) Need Help??


in reply to RS232, parity, program flow

From the docs "The write_settings method writes a new Device Control Block to the driver. The write_settings method will return true if the port is ready for access or undef on failure. Ports are opened for binary transfers. A separate binmode is not needed. The USER must release the object if write_settings does not succeed.

I doubt that you need to save the configuration to the $CONF file. But this: write_settings() or die "port fail! $!"; looks important. That would be a normal paradigm, (1)change a bunch of stuff then (2)say, I'm done, make all of those changes effective. I would imagine that you have to make sure that the serial port is in an "idle state" no characters pending to be send when you fiddle with it's configuration settings. How to do that I don't know, but look carefully at docs. Basically don't screw with the serial port's brain while it is busy.

I would suppose that $obj->write("\xa1\xa2"); would work? Port is already open for binmode.

Your code appears to be deviating from my previous advice about async I/O and "not freezing the GUI". Not sure what is going on there. Remember that in the computer's time frame, it will be a very long time before a buffer of chars are actually sent by the port.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-05-28 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (99 votes). Check out past polls.

    Notices?