Skip to content

Conversation

halyssonJr
Copy link
Contributor

@halyssonJr halyssonJr commented Sep 29, 2025

Note: Please adhere to Contributing Guidelines.

Summary

The PR aims to add support for the CMUX Protocol used in cellular modems. This net utils use a pseudo-terminal to communicate directly to each virtual channel created, e.g, channel 1 is /dev/pts/1.

Also, it's worth noting that I use this project: gsmmux as a reference for submitting this PR, an old project for Linux applications that was adapted and improved for NuttX RTOS.

Huge thanks : Eugene (a.k.a @ya-jeks) and Vitalii Vokhmin - (a.k.a @vit-)

Impact

Adds support for CMUX Protocol used in cellular modems over virtual pts channels.

Testing

This service was tested using the pppd example.

Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffb3b30,len:2868
load:0x40080000,len:22464
entry 0x40082634
*** Booting NuttX ***
dram: lma 0x00001020 vma 0x3ffb3b30 len 0xb34    (2868)
iram: lma 0x00001b5c vma 0x40080000 len 0x57c0   (22464)
padd: lma 0x00007328 vma 0x00000000 len 0x8cd0   (36048)
imap: lma 0x00010000 vma 0x400e0000 len 0x1c3d0  (115664)
padd: lma 0x0002c3d8 vma 0x00000000 len 0x3c20   (15392)
dmap: lma 0x00030000 vma 0x3f410000 len 0x3bc4   (15300)
total segments stored 6

NuttShell (NSH) NuttX-12.10.0
nsh> cmux
ATE0
OK

OK

OK

OK
chat:  ATZ

chat: OK 


OK

chat: cmd 1, arg ON

chat: cmd 4, arg 30

chat:  AT+CGDCONT=1,"IP","teal"

chat: OK ATD*99***1#

AT+CGDCONT=1,"IP","teal"


OK

chat: CONNECT 
ATD*99***1#


CONNECT 150000000


@cederom
Copy link
Contributor

cederom commented Sep 30, 2025

ci detected some typos and formatting, please fix @halyssonJr, tanks! :-)

@xiaoxiang781216
Copy link
Contributor

we made a similar thing, but in the kernel side by implementing a cmux serial driver. The major difference is that the kernel driver could work in the interrupt context and more fast.

@simbit18
Copy link
Contributor

simbit18 commented Sep 30, 2025

Hi @halyssonJr, Please add build with CMake

if(CONFIG_NETUTILS_CMUX)
  target_sources(apps PRIVATE cmux.c)
endif()

@acassis
Copy link
Contributor

acassis commented Sep 30, 2025

we made a similar thing, but in the kernel side by implementing a cmux serial driver. The major difference is that the kernel driver could work in the interrupt context and more fast.

CMUX is something that NuttX is missing for a long time, why only now that someone contributed it you say: "we have a better and faster implementation?" It is not fair! Hehehe

This commit adds CMUX (GSM 07.10) protocol support to netutils.
CMUX allows multiplexing multiple virtual serial connections
over a single physical serial link.

Changes include:
- CMUX protocol implementation
- CRC table for frame validation
- Basic frame handling

Signed-off-by: Halysson <[email protected]>
@xiaoxiang781216
Copy link
Contributor

we made a similar thing, but in the kernel side by implementing a cmux serial driver. The major difference is that the kernel driver could work in the interrupt context and more fast.

CMUX is something that NuttX is missing for a long time, why only now that someone contributed it you say: "we have a better

The first version done one year ago, but it isn't perfect, that's why we just upstream host side tool in Feb: apache/nuttx#14823.

Until the last month, @Gary-Hobson finish a major refactor, the new version is under the testing.

and faster implementation?" It is not fair! Hehehe

Anyway, the implementation is totally different(kernel v.s. userspace), so both can coexist without conflict.

@acassis
Copy link
Contributor

acassis commented Oct 1, 2025

we made a similar thing, but in the kernel side by implementing a cmux serial driver. The major difference is that the kernel driver could work in the interrupt context and more fast.

CMUX is something that NuttX is missing for a long time, why only now that someone contributed it you say: "we have a better

The first version done one year ago, but it isn't perfect, that's why we just upstream host side tool in Feb: apache/nuttx#14823.

Until the last month, @Gary-Hobson finish a major refactor, the new version is under the testing.

and faster implementation?" It is not fair! Hehehe

Anyway, the implementation is totally different(kernel v.s. userspace), so both can coexist without conflict.

True, and the userspace implemented can just be copied to older NuttX version without dependence on kernel code

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @halyssonJr :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants