fix(emulator): CLI --port for TCP fails with 'TCP transport requires port'

Open Beginner friendly
#772 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
cli, networking

Research direction

Start in packages/emulator/src/cli.ts and trace how --port is parsed and passed to ModbusEmulator; check how the TCP transport exposes getTcpPort(). Find the CLI tests and add coverage for numeric, invalid, and zero ports. Done when TCP starts on the requested port, rejects abc clearly, and reports the actual bound port.

Written by the indexing model from the issue text.

Description

codex-ok type:bug

Found while working on #705.

ya-modbus-emulator --transport tcp --host 127.0.0.1 --port 5020 --slave-id 1 passes --port as the string '5020' (packages/emulator/src/cli.ts). ModbusEmulator needs a number for TCP, so the CLI cannot start a TCP emulator. Before #705 the message was TCP transport requires port (a port was given); after #705 it says the port must be a whole number.

Also, the start message prints the configured port, so with --port 0 it would print 0 and not the real port (getTcpPort()).

Done when

  • --port 5020 with --transport tcp starts the emulator on port 5020 (a number string from the CLI becomes a number for TCP).
  • --port abc with TCP gives a clear error.
  • The start message shows the real TCP port (getTcpPort()), also for --port 0.
  • A CLI test covers these.
Dominant language
TypeScript
Stars
3
Forks
0
Avg merge
13h 46m
Merged PRs (30d)
58

Getting set up

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 groupsky/ya-modbus

All issues in groupsky/ya-modbus

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.