diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-01-18 23:28:02 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-01-18 23:28:02 +0000 |
commit | 901cd90faa9354b7cd0017fe9bc719091bee4fd0 (patch) | |
tree | 14b79503021a71d4adb97e8e0ac72087b8521fd4 /nuttx/drivers | |
parent | 0d199a1296adae52e01c1404657e55c34df34283 (diff) | |
download | px4-nuttx-901cd90faa9354b7cd0017fe9bc719091bee4fd0.tar.gz px4-nuttx-901cd90faa9354b7cd0017fe9bc719091bee4fd0.tar.bz2 px4-nuttx-901cd90faa9354b7cd0017fe9bc719091bee4fd0.zip |
Complete HID keyboard test
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3259 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers')
-rw-r--r-- | nuttx/drivers/usbhost/usbhost_hidkbd.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index bf1dd6386..c8d8c419f 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -1698,7 +1698,7 @@ static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer, size_t len { FAR struct inode *inode; FAR struct usbhost_state_s *priv; - size_t remaining; + size_t nbytes; unsigned int tail; int ret; @@ -1729,22 +1729,22 @@ static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer, size_t len { /* Read data from our internal buffer of received characters */ - for (tail = priv->tailndx; - tail != priv->headndx && remaining > 0; - tail++, remaining--) + for (tail = priv->tailndx, nbytes = 0; + tail != priv->headndx && nbytes < len; + nbytes++) { + /* Copy the next keyboard character into the user buffer */ + + *buffer += priv->buffer[tail]; + /* Handle wrap-around of the tail index */ - if (tail >= CONFIG_USBHID_BUFSIZE) + if (++tail >= CONFIG_USBHID_BUFSIZE) { tail = 0; } - - /* Copy the next keyboard character into the user buffer */ - - *buffer += priv->buffer[tail]; - remaining--; } + ret = nbytes; /* Update the tail index (pehaps marking the buffer empty) */ @@ -1752,7 +1752,7 @@ static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer, size_t len } usbhost_givesem(&priv->exclsem); - return 0; /* Return EOF for now */ + return (ssize_t)ret; } /**************************************************************************** |