libftdi Archives

Subject: Re: Modem status callback function patch

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 17 Sep 2012 09:57:46 +0200
Hi Dimitry,

On Saturday, 15. September 2012 06:31:14 Dmitry Lysenko wrote:
> In attached file reworked and slightly cleaned  patch.
> Now do not needed exactly call ftdi_poll_modem_status().
> And now if your callback function will be called and it returned
> NON ZERO value at time of async reading, then this async transfer will be
> canceled.

thanks for the updated patch!

I took a look at it and overall it looks good.
Here are some small things we should discuss:

- It changes the transfer handling (_CANCEL stuff,
  replaces libusb_handle_events() with libusb_handle_events_completed)
  This could have side effects.

- Change the "invalid modem status" magic value of 0xffff into a constant
  since we already use it in two places

- Does the "cancel" logic have to be tied to
  the modem status handling / callback?

- Should we update ftdi->last_modem_status before
  calling the registered callback or afterwards?

- Does "register_callback" really need to poll the current status?
  I would call this a "side effect", so we should either document it
  or do nothing USB related at all.

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread