mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 10:46:02 +08:00
Fix packet size calculation in CDC/ACM and PL2303 USB serial drivers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4771 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+11
-2
@@ -318,6 +318,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
FAR struct usbdev_ep_s *ep;
|
||||
FAR struct usbdev_req_s *req;
|
||||
FAR struct cdcacm_req_s *reqcontainer;
|
||||
uint16_t reqlen;
|
||||
irqstate_t flags;
|
||||
int len;
|
||||
int ret = OK;
|
||||
@@ -337,7 +338,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
ep = priv->epbulkin;
|
||||
|
||||
/* Loop until either (1) we run out or write requests, or (2) cdcacm_fillrequest()
|
||||
* is unable to fill the request with data (i.e., untilthere is no more data
|
||||
* is unable to fill the request with data (i.e., until there is no more data
|
||||
* to be sent).
|
||||
*/
|
||||
|
||||
@@ -345,6 +346,14 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
priv->serdev.xmit.head, priv->serdev.xmit.tail,
|
||||
priv->nwrq, sq_empty(&priv->reqlist));
|
||||
|
||||
/* Get the maximum number of bytes that will fit into one bulk IN request */
|
||||
|
||||
#ifdef CONFIG_CDCACM_BULKREQLEN
|
||||
reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, ep->maxpacket);
|
||||
#else
|
||||
reqlen = ep->maxpacket;
|
||||
#endif
|
||||
|
||||
while (!sq_empty(&priv->reqlist))
|
||||
{
|
||||
/* Peek at the request in the container at the head of the list */
|
||||
@@ -354,7 +363,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
|
||||
/* Fill the request with serial TX data */
|
||||
|
||||
len = cdcacm_fillrequest(priv, req->buf, req->len);
|
||||
len = cdcacm_fillrequest(priv, req->buf, reqlen);
|
||||
if (len > 0)
|
||||
{
|
||||
/* Remove the empty container from the request list */
|
||||
|
||||
+11
-2
@@ -567,6 +567,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
||||
FAR struct usbdev_ep_s *ep;
|
||||
FAR struct usbdev_req_s *req;
|
||||
FAR struct pl2303_req_s *reqcontainer;
|
||||
uint16_t reqlen;
|
||||
irqstate_t flags;
|
||||
int len;
|
||||
int ret = OK;
|
||||
@@ -586,7 +587,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
||||
ep = priv->epbulkin;
|
||||
|
||||
/* Loop until either (1) we run out or write requests, or (2) usbclass_fillrequest()
|
||||
* is unable to fill the request with data (i.e., untilthere is no more data
|
||||
* is unable to fill the request with data (i.e., until there is no more data
|
||||
* to be sent).
|
||||
*/
|
||||
|
||||
@@ -594,6 +595,14 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
||||
priv->serdev.xmit.head, priv->serdev.xmit.tail,
|
||||
priv->nwrq, sq_empty(&priv->reqlist));
|
||||
|
||||
/* Get the maximum number of bytes that will fit into one bulk IN request */
|
||||
|
||||
#ifdef CONFIG_PL2303_BULKREQLEN
|
||||
reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, ep->maxpacket);
|
||||
#else
|
||||
reqlen = ep->maxpacket;
|
||||
#endif
|
||||
|
||||
while (!sq_empty(&priv->reqlist))
|
||||
{
|
||||
/* Peek at the request in the container at the head of the list */
|
||||
@@ -603,7 +612,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv)
|
||||
|
||||
/* Fill the request with serial TX data */
|
||||
|
||||
len = usbclass_fillrequest(priv, req->buf, req->len);
|
||||
len = usbclass_fillrequest(priv, req->buf, reqlen);
|
||||
if (len > 0)
|
||||
{
|
||||
/* Remove the empty container from the request list */
|
||||
|
||||
Reference in New Issue
Block a user