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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9014af9ae76 libc/crc: Add crc8rohcincr for incremental CRC8 ROHC 
calculation
9014af9ae76 is described below

commit 9014af9ae76fee333bd15529b19bdb0a51d7cf2d
Author: Halysson <[email protected]>
AuthorDate: Tue Sep 30 12:50:14 2025 -0300

    libc/crc: Add crc8rohcincr for incremental CRC8 ROHC calculation
    
    Add crc8rohcincr() function to support byte-by-byte CRC8 calculation
    using the ROHC polynomial (0x07) without XOR inversions. This is
    useful for protocols that require incremental CRC accumulation,
    such as GSM 07.10 (CMUX), where the CRC must be computed as frames
    are parsed from circular buffers.
    
    Changes include:
    - New crc8rohcincr() function for single-byte incremental CRC
    - Function takes current CRC value and returns updated CRC
    - Uses same g_crc8_tab table as other ROHC functions
    - No XOR inversions applied for proper accumulation
    
    This allows protocols like CMUX to replace local CRC table
    implementations with standard libc CRC functions while maintaining
    correct incremental calculation behavior.
    
    Signed-off-by: Halysson <[email protected]>
---
 include/nuttx/crc8.h          | 6 ++++++
 libs/libc/misc/lib_crc8rohc.c | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/nuttx/crc8.h b/include/nuttx/crc8.h
index 98c5e2d6dc2..81c7e957596 100644
--- a/include/nuttx/crc8.h
+++ b/include/nuttx/crc8.h
@@ -118,6 +118,12 @@ uint8_t crc8rohcpart(FAR const uint8_t *src, size_t len, 
uint8_t crc8val);
 
 uint8_t crc8rohc(FAR const uint8_t *src, size_t len);
 
+/****************************************************************************
+ * Name: crc8rohcincr
+ ****************************************************************************/
+
+uint8_t crc8rohcincr(uint8_t data_byte, uint8_t crc8val);
+
 #undef EXTERN
 #ifdef __cplusplus
 }
diff --git a/libs/libc/misc/lib_crc8rohc.c b/libs/libc/misc/lib_crc8rohc.c
index 890cece4566..274c6e43d57 100644
--- a/libs/libc/misc/lib_crc8rohc.c
+++ b/libs/libc/misc/lib_crc8rohc.c
@@ -88,3 +88,12 @@ uint8_t crc8rohc(FAR const uint8_t *src, size_t len)
 {
   return crc8rohcpart(src, len, 0xff);
 }
+
+/****************************************************************************
+ * Name: crc8rohcincr
+ ****************************************************************************/
+
+uint8_t crc8rohcincr(uint8_t data_byte, uint8_t crc8val)
+{
+  return g_crc8_tab[crc8val ^ data_byte];
+}

Reply via email to