libftdi Archives

Subject: Re: ftdi_setflowctrl() incorrectly sets XON and XOFF character values

From: Pawel Jewstafjew <pawel.jewstafjew@xxxxxxxxx>
To: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Cc: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 20 Sep 2017 19:53:14 +0100
Hi Thomas,

> Do I understand the existing code correctly: It allows you do
> enable XON/XOFF mode like it is documented, but misconfigures
> the actual XON/XOFF characters?

Yes
XON/XOFF mode is enabled, but both XOFF (pause) and XON (resume)
character codes are set to zero.
So: '\x00' is sent by FTDI chip (when the internal buffer is close to
becoming full) to pause transmission, and '\x00' is sent by FTDI chip
(when the internal buffer level drops) to resume transmission.

After the change XON and XOFF character values can be freely
configured (this is similar to "official" FTDI driver API)

> Please send a proper git patch and I'll include it.

Please find patch attached.


Thanks,
Pawel



On 15/09/2017, Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> wrote:
> Hi Pawel,
>
> On Sunday, 10 September 2017 17:02:54 CEST Pawel Jewstafjew wrote:
>> Or, to preserve backward compatibility of the libftdi ABI, this can be
>> also done by adding a new function, for example:
>>
>> int ftdi_setflowctrl_xonxoff(struct ftdi_context *ftdi, uint8_t xon,
>> uint8_t xoff)
>> {
>> […]
>> uint16_t value = (xoff_char << 8) | xon_char;
>> if (usb_control_msg(ftdi->usb_dev, FTDI_DEVICE_OUT_REQTYPE,
>>                         SIO_SET_FLOW_CTRL_REQUEST, value,
>> (SIO_XON_XOFF_HS | ftdi->index),
>>                         NULL, 0, ftdi->usb_write_timeout) != 0)
>> […]
>
> I would prefer the second approach since it will be API compatible, the ABI
> is not so important as we can just increase the .so number. Breaking
> existing
> source code would be more of a pain for distributions and users.
>
> Do I understand the existing code correctly: It allows you do
> enable XON/XOFF mode like it is documented, but misconfigures
> the actual XON/XOFF characters?
>
> Please send a proper git patch and I'll include it.
>
> Thank you,
> Thomas
>
>


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

Attachment: fix_xonxoff.patch
Description: Text Data

Current Thread