src/app/host-serial/libftdi/ftdi.c
int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status)
{
    char usb_val[2];

    if (ftdi == NULL || ftdi->usb_dev == NULL)
        ftdi_error_return(-2, "USB device unavailable");

    if (libusb_control_transfer(ftdi->usb_dev, FTDI_DEVICE_IN_REQTYPE, SIO_POLL_MODEM_STATUS_REQUEST, 0, ftdi->index, (unsigned char *)usb_val, 2, ftdi->usb_read_timeout) != 2)
        ftdi_error_return(-1, "getting modem status failed");

    *status = (usb_val[1] << 8) | (usb_val[0] & 0xFF);

    return 0;
}
/**
    Poll modem status information

    This function allows the retrieve the two status bytes of the device.
    The device sends these bytes also as a header for each read access
    where they are discarded by ftdi_read_data(). The chip generates
    the two stripped status bytes in the absence of data every 40 ms.

    Layout of the first byte:
    - B0..B3 - must be 0
    - B4       Clear to send (CTS)
                 0 = inactive
                 1 = active
    - B5       Data set ready (DTS)
                 0 = inactive
                 1 = active
    - B6       Ring indicator (RI)
                 0 = inactive
                 1 = active
    - B7       Receive line signal detect (RLSD)
                 0 = inactive
                 1 = active

    Layout of the second byte:
    - B0       Data ready (DR)
    - B1       Overrun error (OE)
    - B2       Parity error (PE)
    - B3       Framing error (FE)
    - B4       Break interrupt (BI)
    - B5       Transmitter holding register (THRE)
    - B6       Transmitter empty (TEMT)
    - B7       Error in RCVR FIFO

    \param ftdi pointer to ftdi_context
    \param status Pointer to store status information in. Must be two bytes.

    \retval  0: all fine
    \retval -1: unable to retrieve status information
    \retval -2: USB device unavailable
*/
Poll modem status information
This function allows the retrieve the two status bytes of the device.
The device sends these bytes also as a header for each read access
where they are discarded by ftdi_read_data(). The chip generates
the two stripped status bytes in the absence of data every 40 ms.





\param ftdi pointer to ftdi_context
\param status Pointer to store status information in. Must be two bytes.

\retval  0: all fine
\retval -1: unable to retrieve status information
\retval -2: USB device unavailable
Poll modem status information This function allows the retrieve the two status bytes of the device . The device sends these bytes also as a header for each read access where they are discarded by ftdi_read_data () . The chip generates the two stripped status bytes in the absence of data every 40 ms . \ param ftdi pointer to ftdi_context \ param status Pointer to store status information in . Must be two bytes . \ retval 0 : all fine \ retval - 1 : unable to retrieve status information \ retval - 2 : USB device unavailable
int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status)
{
    char usb_val[2];
    if (ftdi == NULL || ftdi->usb_dev == NULL)
        ftdi_error_return(-2, "USB device unavailable");
    if (libusb_control_transfer(ftdi->usb_dev, FTDI_DEVICE_IN_REQTYPE, SIO_POLL_MODEM_STATUS_REQUEST, 0, ftdi->index, (unsigned char *)usb_val, 2, ftdi->usb_read_timeout) != 2)
        ftdi_error_return(-1, "getting modem status failed");
    *status = (usb_val[1] << 8) | (usb_val[0] & 0xFF);
    return 0;
}
int ftdi_poll_modem_status ( struct ftdi_context * ftdi , unsigned short * status ) { char usb_val [ 2 ] ; if ( ftdi == NULL || ftdi -> usb_dev == NULL ) ftdi_error_return ( -2 , " " ) ; if ( libusb_control_transfer ( ftdi -> usb_dev , FTDI_DEVICE_IN_REQTYPE , SIO_POLL_MODEM_STATUS_REQUEST , 0 , ftdi -> index , ( unsigned char * ) usb_val , 2 , ftdi -> usb_read_timeout ) != 2 ) ftdi_error_return ( -1 , " " ) ; * status = ( usb_val [ 1 ] << 8 ) | ( usb_val [ 0 ] & 0xFF ) ; return 0 ; }
Poll modem status information
This function allows the retrieve the two status bytes of the device.
Poll modem status information This function allows the retrieve the two status bytes of the device .