mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
Fix readline return value; Add support for removable serial devices
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5589 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+37
-8
@@ -983,6 +983,14 @@ static void usbclass_resetconfig(FAR struct pl2303_dev_s *priv)
|
||||
|
||||
priv->config = PL2303_CONFIGIDNONE;
|
||||
|
||||
/* Inform the "upper half" driver that there is no (functional) USB
|
||||
* connection.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||
uart_connected(&priv->serdev, false);
|
||||
#endif
|
||||
|
||||
/* Disable endpoints. This should force completion of all pending
|
||||
* transfers.
|
||||
*/
|
||||
@@ -1112,10 +1120,20 @@ static int usbclass_setconfig(FAR struct pl2303_dev_s *priv, uint8_t config)
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
priv->nrdq++;
|
||||
}
|
||||
|
||||
/* We are successfully configured */
|
||||
|
||||
priv->config = config;
|
||||
|
||||
/* Inform the "upper half" driver that we are "open for business" */
|
||||
|
||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||
uart_connected(&priv->serdev, true);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
@@ -1844,12 +1862,20 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Reset the configuration */
|
||||
/* Inform the "upper half serial driver that we have lost the USB serial
|
||||
* connection.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||
uart_connected(&priv->serdev, false);
|
||||
#endif
|
||||
|
||||
/* Reset the configuration */
|
||||
|
||||
usbclass_resetconfig(priv);
|
||||
|
||||
/* Clear out all data in the circular buffer */
|
||||
/* Clear out all outgoing data in the circular buffer */
|
||||
|
||||
priv->serdev.xmit.head = 0;
|
||||
priv->serdev.xmit.tail = 0;
|
||||
@@ -2185,12 +2211,15 @@ int usbdev_serialinitialize(int minor)
|
||||
|
||||
/* Initialize the serial driver sub-structure */
|
||||
|
||||
priv->serdev.recv.size = CONFIG_PL2303_RXBUFSIZE;
|
||||
priv->serdev.recv.buffer = priv->rxbuffer;
|
||||
priv->serdev.xmit.size = CONFIG_PL2303_TXBUFSIZE;
|
||||
priv->serdev.xmit.buffer = priv->txbuffer;
|
||||
priv->serdev.ops = &g_uartops;
|
||||
priv->serdev.priv = priv;
|
||||
#ifdef CONFIG_SERIAL_REMOVABLE
|
||||
priv->serdev.disconnected = true;
|
||||
#endif
|
||||
priv->serdev.recv.size = CONFIG_PL2303_RXBUFSIZE;
|
||||
priv->serdev.recv.buffer = priv->rxbuffer;
|
||||
priv->serdev.xmit.size = CONFIG_PL2303_TXBUFSIZE;
|
||||
priv->serdev.xmit.buffer = priv->txbuffer;
|
||||
priv->serdev.ops = &g_uartops;
|
||||
priv->serdev.priv = priv;
|
||||
|
||||
/* Initialize the USB class driver structure */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user