You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2020/12/28 09:38:10 UTC

[incubator-nuttx] branch master updated (f992ff3 -> d85cf99)

This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from f992ff3  Fix nxstyle warning
     new 6a30d7a  bt_uart: Remove static variables in btuart_rxwork
     new ca5d8d8  bt_uart: Fix the minor typo in bt_uart driver
     new 1d8397a  bt_uart: Don't call rxdrain in the successful path
     new d85cf99  bt_uart: Retry the lower half operation if -EINTR is returned

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 drivers/wireless/bluetooth/bt_uart.c | 56 ++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 32 deletions(-)


[incubator-nuttx] 01/04: bt_uart: Remove static variables in btuart_rxwork

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 6a30d7ad6b94e28518f96dd22c6fae1f3196ae0e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Dec 27 15:34:36 2020 +0800

    bt_uart: Remove static variables in btuart_rxwork
    
    to support mulitple bluetooth controllers
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index dae18e6..87c3905 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -184,9 +184,9 @@ static void btuart_rxwork(FAR void *arg)
 {
   FAR struct btuart_upperhalf_s *upper;
   FAR const struct btuart_lowerhalf_s *lower;
-  static FAR struct bt_buf_s *buf;
-  static unsigned int hdrlen;
-  static int remaining;
+  FAR struct bt_buf_s *buf;
+  unsigned int hdrlen;
+  int remaining;
   ssize_t nread;
   uint8_t type;
 
@@ -198,9 +198,6 @@ static void btuart_rxwork(FAR void *arg)
    * Read the first byte to get the packet type.
    */
 
-  buf    = NULL;
-  hdrlen = 0;
-
   nread = btuart_read(upper, &type, 1, 0);
   if (nread != 1)
     {


[incubator-nuttx] 03/04: bt_uart: Don't call rxdrain in the successful path

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 1d8397a36d4fc18541626bab6b8afc98733103b6
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Dec 27 15:48:31 2020 +0800

    bt_uart: Don't call rxdrain in the successful path
    
    because the physical uart bus may receive the next packet asynchronously
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index 3cb1ed7..57b5dca 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -255,14 +255,6 @@ static void btuart_rxwork(FAR void *arg)
 
   wlinfo("Full packet received\n");
 
-  /* Drain any un-read bytes from the Rx buffer */
-
-  nread = lower->rxdrain(lower);
-  if (nread > 0)
-    {
-      wlwarn("WARNING: Discarded %ld bytes\n", (long)nread);
-    }
-
   /* Pass buffer to the stack */
 
   BT_DUMP("Received", buf->data, buf->len);


[incubator-nuttx] 02/04: bt_uart: Fix the minor typo in bt_uart driver

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ca5d8d86606671280e58e710c945cdd55eac0aff
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Dec 27 15:40:30 2020 +0800

    bt_uart: Fix the minor typo in bt_uart driver
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index 87c3905..3cb1ed7 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -66,8 +66,8 @@ static ssize_t btuart_read(FAR struct btuart_upperhalf_s *upper,
                            size_t minread)
 {
   FAR const struct btuart_lowerhalf_s *lower;
-  ssize_t nread;
   ssize_t ntotal = 0;
+  ssize_t nread;
 
   wlinfo("buflen %lu minread %lu\n",
          (unsigned long)buflen, (unsigned long)minread);
@@ -91,7 +91,7 @@ static ssize_t btuart_read(FAR struct btuart_upperhalf_s *upper,
         }
       else if (nread < 0)
         {
-          wlwarn("Returned error %d\n", nread);
+          wlwarn("Returned error %d\n", (int)nread);
           return nread;
         }
 
@@ -137,7 +137,7 @@ btuart_evt_recv(FAR struct btuart_upperhalf_s *upper,
       wlerr("ERROR: No available event buffers!\n");
     }
 
-  *hdrlen = (int)hdr.len;
+  *hdrlen = hdr.len;
 
   wlinfo("hdrlen %u\n", hdr.len);
   return buf;
@@ -229,7 +229,7 @@ static void btuart_rxwork(FAR void *arg)
       wlwarn("WARNING: Discarded %ld bytes\n", (long)nread);
       goto errout_with_busy;
     }
-  else if ((hdrlen - 1) > bt_buf_tailroom(buf))
+  else if (hdrlen > bt_buf_tailroom(buf))
     {
       wlerr("ERROR: Not enough space in buffer\n");
       goto errout_with_buf;
@@ -243,7 +243,7 @@ static void btuart_rxwork(FAR void *arg)
       nread = btuart_read(upper, bt_buf_tail(buf), remaining, 0);
       if (nread < 0)
         {
-          wlerr("ERROR: Read returned error %d\n", nread);
+          wlerr("ERROR: Read returned error %d\n", (int)nread);
           goto errout_with_buf;
         }
 
@@ -265,7 +265,7 @@ static void btuart_rxwork(FAR void *arg)
 
   /* Pass buffer to the stack */
 
-  BT_DUMP("Received",  buf->data, buf->len);
+  BT_DUMP("Received", buf->data, buf->len);
   upper->busy = false;
   bt_hci_receive(buf);
   return;
@@ -275,7 +275,6 @@ errout_with_buf:
 
 errout_with_busy:
   upper->busy = false;
-  return;
 }
 
 static void btuart_rxcallback(FAR const struct btuart_lowerhalf_s *lower,
@@ -319,7 +318,7 @@ int btuart_send(FAR const struct bt_driver_s *dev, FAR struct bt_buf_s *buf)
       return -EINVAL;
     }
 
-  type = bt_buf_provide(buf, 1);
+  type = bt_buf_provide(buf, H4_HEADER_SIZE);
 
   switch (buf->type)
     {
@@ -350,7 +349,7 @@ int btuart_send(FAR const struct bt_driver_s *dev, FAR struct bt_buf_s *buf)
 
   if (nwritten < 0)
     {
-      return (int)nwritten;
+      return nwritten;
     }
 
   return -EIO;


[incubator-nuttx] 04/04: bt_uart: Retry the lower half operation if -EINTR is returned

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit d85cf99a6598bc5eee1fb15facf03226d5308641
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Dec 27 19:57:16 2020 +0800

    bt_uart: Retry the lower half operation if -EINTR is returned
    
    to handle the partial write and read gracefully
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index 57b5dca..b75d3d4 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -79,7 +79,7 @@ static ssize_t btuart_read(FAR struct btuart_upperhalf_s *upper,
   while (buflen > 0)
     {
       nread = lower->read(lower, buffer, buflen);
-      if (nread == 0)
+      if (nread == 0 || nread == -EINTR)
         {
           wlwarn("Got zero bytes from UART\n");
           if (ntotal < minread)
@@ -298,7 +298,7 @@ int btuart_send(FAR const struct bt_driver_s *dev, FAR struct bt_buf_s *buf)
   FAR struct btuart_upperhalf_s *upper;
   FAR const struct btuart_lowerhalf_s *lower;
   FAR uint8_t *type;
-  ssize_t nwritten;
+  ssize_t ntotal = 0;
 
   upper = (FAR struct btuart_upperhalf_s *)dev;
   DEBUGASSERT(upper != NULL && upper->lower != NULL);
@@ -333,18 +333,22 @@ int btuart_send(FAR const struct bt_driver_s *dev, FAR struct bt_buf_s *buf)
 
   BT_DUMP("Sending",  buf->data, buf->len);
 
-  nwritten = lower->write(lower, buf->data, buf->len);
-  if (nwritten == buf->len)
+  while (ntotal < buf->len)
     {
-      return OK;
-    }
+      ssize_t nwritten;
 
-  if (nwritten < 0)
-    {
-      return nwritten;
+      nwritten = lower->write(lower, buf->data + ntotal, buf->len - ntotal);
+      if (nwritten >= 0)
+        {
+          ntotal += nwritten;
+        }
+      else if (nwritten != -EINTR)
+        {
+          return nwritten;
+        }
     }
 
-  return -EIO;
+  return OK;
 }
 
 int btuart_open(FAR const struct bt_driver_s *dev)