You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/08/10 06:50:30 UTC

[incubator-nuttx] branch master updated: net/local: Remove the sync preamble from datagram

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 838690fc9f net/local: Remove the sync preamble from datagram
838690fc9f is described below

commit 838690fc9ffa8f8283fc72ab37a0d138fb8b324e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Aug 8 11:08:05 2022 +0800

    net/local: Remove the sync preamble from datagram
    
    since pipe is a reliable transport, the sync just waste the space and time
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 net/local/local.h            | 11 -----------
 net/local/local_recvutils.c  | 39 +--------------------------------------
 net/local/local_sendpacket.c | 26 +-------------------------
 3 files changed, 2 insertions(+), 74 deletions(-)

diff --git a/net/local/local.h b/net/local/local.h
index 909dfc2659..aace9a92b9 100644
--- a/net/local/local.h
+++ b/net/local/local.h
@@ -48,17 +48,6 @@
 #define LOCAL_NPOLLWAITERS 2
 #define LOCAL_NCONTROLFDS  4
 
-/* Packet format in FIFO:
- *
- * 1. Sync bytes (7 at most)
- * 2. End/Start byte
- * 3. 16-bit packet length (in host order)
- * 4. Packet data (in host order)
- */
-
-#define LOCAL_SYNC_BYTE   0x42     /* Byte in sync sequence */
-#define LOCAL_END_BYTE    0xbd     /* End of sync sequence */
-
 /****************************************************************************
  * Public Type Definitions
  ****************************************************************************/
diff --git a/net/local/local_recvutils.c b/net/local/local_recvutils.c
index c9143754e1..30380e893e 100644
--- a/net/local/local_recvutils.c
+++ b/net/local/local_recvutils.c
@@ -142,46 +142,9 @@ int local_sync(FAR struct file *filep)
 {
   size_t readlen;
   uint16_t pktlen;
-  uint8_t sync;
   int ret;
 
-  /* Loop until a valid pre-amble is encountered:  SYNC bytes followed
-   * by one END byte.
-   */
-
-  do
-    {
-      /* Read until we encounter a sync byte */
-
-      do
-        {
-          readlen = sizeof(uint8_t);
-          ret     = local_fifo_read(filep, &sync, &readlen, false);
-          if (ret < 0)
-            {
-              nerr("ERROR: Failed to read sync bytes: %d\n", ret);
-              return ret;
-            }
-        }
-      while (sync != LOCAL_SYNC_BYTE);
-
-      /* Then read to the end of the SYNC sequence */
-
-      do
-        {
-          readlen = sizeof(uint8_t);
-          ret     = local_fifo_read(filep, &sync, &readlen, false);
-          if (ret < 0)
-            {
-              nerr("ERROR: Failed to read sync bytes: %d\n", ret);
-              return ret;
-            }
-        }
-      while (sync == LOCAL_SYNC_BYTE);
-    }
-  while (sync != LOCAL_END_BYTE);
-
-  /* Then read the packet length */
+  /* Read the packet length */
 
   readlen = sizeof(uint16_t);
   ret     = local_fifo_read(filep, (FAR uint8_t *)&pktlen, &readlen, false);
diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c
index 781bf83b7d..1c75d3c24a 100644
--- a/net/local/local_sendpacket.c
+++ b/net/local/local_sendpacket.c
@@ -38,22 +38,6 @@
 
 #if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL)
 
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define LOCAL_PREAMBLE_SIZE 8
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static const uint8_t g_preamble[LOCAL_PREAMBLE_SIZE] =
-{
-  LOCAL_SYNC_BYTE, LOCAL_SYNC_BYTE, LOCAL_SYNC_BYTE, LOCAL_SYNC_BYTE,
-  LOCAL_SYNC_BYTE, LOCAL_SYNC_BYTE, LOCAL_SYNC_BYTE, LOCAL_END_BYTE
-};
-
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
@@ -139,14 +123,6 @@ int local_send_packet(FAR struct file *filep, FAR const struct iovec *buf,
 
   if (preamble)
     {
-      /* Send the packet preamble */
-
-      ret = local_fifo_write(filep, g_preamble, LOCAL_PREAMBLE_SIZE);
-      if (ret != LOCAL_PREAMBLE_SIZE)
-        {
-          return ret;
-        }
-
       /* Send the packet length */
 
       for (len16 = 0, iov = buf; iov != end; iov++)
@@ -180,7 +156,7 @@ int local_send_packet(FAR struct file *filep, FAR const struct iovec *buf,
         }
     }
 
-  return (len16 > 0) ? len16 : ret;
+  return len16 > 0 ? len16 : ret;
 }
 
 #endif /* CONFIG_NET && CONFIG_NET_LOCAL */