summaryrefslogtreecommitdiff
path: root/nuttx/drivers/usbdev
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-25 22:10:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-25 22:10:40 +0000
commit7678a8287c4a198ba6811f45b9bba934b2a5716b (patch)
treefa1aaf27248cfc57d4bc9c9f1f066b98e93d0191 /nuttx/drivers/usbdev
parent385b0fd6504ea1cb35b52cb425b5c37a62afa91d (diff)
downloadpx4-nuttx-7678a8287c4a198ba6811f45b9bba934b2a5716b.tar.gz
px4-nuttx-7678a8287c4a198ba6811f45b9bba934b2a5716b.tar.bz2
px4-nuttx-7678a8287c4a198ba6811f45b9bba934b2a5716b.zip
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
Diffstat (limited to 'nuttx/drivers/usbdev')
-rw-r--r--nuttx/drivers/usbdev/cdcacm.c13
-rw-r--r--nuttx/drivers/usbdev/pl2303.c13
2 files changed, 22 insertions, 4 deletions
diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c
index 24903b504..97c9d7c77 100644
--- a/nuttx/drivers/usbdev/cdcacm.c
+++ b/nuttx/drivers/usbdev/cdcacm.c
@@ -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 */
diff --git a/nuttx/drivers/usbdev/pl2303.c b/nuttx/drivers/usbdev/pl2303.c
index a1ba667f5..8bd94ddd0 100644
--- a/nuttx/drivers/usbdev/pl2303.c
+++ b/nuttx/drivers/usbdev/pl2303.c
@@ -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 */