Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Modbus not usable with USB serial

Open
#321 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
embedded-iot

Research direction

Start with apps/nshlib/nsh_usbconsole.c and the nsh_waitusbready() function to understand how USB serial removal and reconnection are handled. Then inspect Modbus handling around select() and read(), including its error handling. Done means a lost USB serial connection no longer causes an infinite loop and the serial driver can be reopened after reconnection.

Written by the indexing model from the issue text.

Description

Type: Enhancement

Modbus can be used with USB serial, however, if the USB serial connection is lost, Modbus will hang in an infinite loop.

This is a problem in the handling of select() and read() and could probably resolved by studying the Modbus error handling.

A more USB-friendly solution would be to: (1) Re-connect and (2) re-open the serial drivers. That is what is done is NSH: When the serial USB device is removed, this terminates the session and NSH will then try to re-open the USB device. See the function nsh_waitusbready() in the file apps/nshlib/nsh_usbconsole.c. When the USB serial is reconnected the open() in the function will succeed and a new session will be started.

This is really an enhancement request: Modbus was never designed to work with removable serial devices.

Dominant language
C
Stars
465
Forks
782
Avg merge
4d 4h
Merged PRs (30d)
42

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/nuttx-apps

All issues in apache/nuttx-apps

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.