de-vri-es / serial2-rs

Cross platform serial ports for Rust
Other
41 stars 10 forks source link

Need simple example showing how to apply dcb settings from the application #16

Closed jerrywrice closed 8 months ago

jerrywrice commented 9 months ago

I'm a relative novice using type conversion operators (such Into) with rust.

Could you add an example source file that applies port settings using the DCB under Windows? To be clear, I understand how the serial DCB fields work with Windows serial ports, but don't know how to accomplish this from a rust application using the serial2 crate.

Thx

de-vri-es commented 9 months ago

Is there anything from Settings you're missing? Do you want access to the raw DCB structure?

jerrywrice commented 9 months ago

Maarten,

Thanks for replying, and for publishing and supporting this crate.

My app needs to customize the Windows Receive timeout configuration, based on the device I’m controlling. In various scenarios I need to set different DCB ReadIntervalTimeout, ReadTotalTimeoutMultiplier, and ReadTotalTimeoutConstant DCB field values. I haven’t found a way to do this without modifying the crate interface. Is there a way to update the raw DCB from outside the crate library - from a client application?

From: Maarten de Vries @.> Sent: Tuesday, October 10, 2023 10:53 AM To: de-vri-es/serial2-rs @.> Cc: JWR_FABNexus @.>; Author @.> Subject: Re: [de-vri-es/serial2-rs] Need simple example showing how to apply dcb settings from the application (Issue #16)

Is there anything from https://docs.rs/serial2/latest/serial2/struct.Settings.html Settings yuo're missing? Do you want access to the raw DCB structure?

— Reply to this email directly, view it on GitHub https://github.com/de-vri-es/serial2-rs/issues/16#issuecomment-1755948028 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AEHOLCQQKVO4KJX5NW3UTULX6WDOFAVCNFSM6AAAAAA5XJA76WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJVHE2DQMBSHA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AEHOLCUGG265SJWZ5SSCTP3X6WDOFA5CNFSM6AAAAAA5XJA76WWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTIVGR7Y.gif Message ID: @. @.> >

de-vri-es commented 9 months ago

Hey! Currently there is indeed no way to access the raw DCB fields or the timeouts. Do note that the timeouts are not in the DCB struct, they're in the _COMMTIMEOUTS struct, which requires a separate set of syscalls to manipulate.

I am interested in exposing platform specific configuration parameters, but there are some challenges with that. Would it suffice for your application to just set the read/write timeout (ReadTotalTimeoutConstant)? Because that is already exposed through set_read_timeout().

Note that setting ReadIntervalTimeout and ReadTotalTimeoutMultiplier will cause read() to return no data if the timeout is reached, not even whatever data has been received so far. This is normally a big problem, so you should be careful when using these settings.

jerrywrice commented 9 months ago

Maarten,

Yes, I'm familiar with those Windows data structures. I was a bit rushed with I formulated my earlier email.

I recently collaborated and volunteered time/effort to supplying updates to those setting fields for the ‘serialport-rs’ crate. Unfortunately that crate’s support team is very preoccupied with other things besides that crate – something I’m sure you must contend with as well (we’re all volunteers!). But after almost six months of roughly 20 hours per week assisting that crate’s support team I concluded things were moving too slow. Recently someone referred me to your crate, which is why I began experimenting with it about a week or so back.

Let me know if you have a need/interest in adding to your open source volunteer support team – I have some time as I’m semi-retired. Regarding my background, I’ve been using rust for some in-house projects for about a year now. IMO it’s a great system’s development language, one of the best I’ve encountered in my career. You can check out my technical resume on my web-site (URL below).

From: Maarten de Vries @.> Sent: Wednesday, October 11, 2023 12:34 AM To: de-vri-es/serial2-rs @.> Cc: JWR_FABNexus @.>; Author @.> Subject: Re: [de-vri-es/serial2-rs] Need simple example showing how to apply dcb settings from the application (Issue #16)

Hey! Currently there is indeed no way to access the raw DCB fields or the timeouts. Do note that the timeouts are not in the DCB struct, they're in the _COMMTIMEOUTS struct, which requires a separate set of syscalls to manipulate.

I am interested in exposing platform specific configuration parameters, but there are some challenges with that. Would it suffice for your application to just set the read/write timeout (ReadTotalTimeoutConstant)? Because that is already exposed through https://docs.rs/serial2/latest/serial2/struct.SerialPort.html#method.set_read_timeout set_read_timeout().

Note that setting ReadIntervalTimeout and ReadTotalTimeoutMultiplier will cause read() to return no data if the timeout is reached, not even whatever data has been received so far. This is normally a big problem, so you should be careful when using these settings.

— Reply to this email directly, view it on GitHub https://github.com/de-vri-es/serial2-rs/issues/16#issuecomment-1757023230 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AEHOLCX7JRETDY3WEL5QWS3X6ZDX3ANCNFSM6AAAAAA5XJA76U . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AEHOLCU676XV7CCUB43YFNDX6ZDX3A5CNFSM6AAAAAA5XJA76WWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTIXIF74.gif Message ID: @. @.> >

de-vri-es commented 9 months ago

Hey! As mentioned, I do want to support access to platform specific features.

It's currently open in #18. Could you have a look to see if it fits your needs?

jerrywrice commented 8 months ago

Your latest merge of pr #18 into main resolves my request. Thx.