Skip to content

Bug/Unclear Information when configuring a tcp device as "1:192.168.1.1:502" (IDFGH-15558) #128

@cosmicKev

Description

@cosmicKev

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

When configure a TCP device with "1:192.168.1.1:502" the device wont be found and does not initialize
Instead if you configure as "1;192.168.1.1;502" the device actually works. Either the comment is wrong or the implementation is wrong.

Actual behavior (suspected bug)

Scanning searches for ";" instead ":" to retrieve information.

 // Configuration format:
    // "1:192.168.1.1:502"
    ret = sscanf(buffer, "%" PRIu16 ";"IPSTR";%" PRIu16, &index, &a[0], &a[1], &a[2], &a[3], &port);
    if ((ret == MB_STR_LEN_IDX_IP4_PORT) || (ret == MB_STR_LEN_IDX_IP4)) {
        if (-1 == asprintf(&phost_str, IPSTR, a[0], a[1], a[2], a[3])) {
            abort();
        }
        pinfo->node_name_str = phost_str;
        pinfo->ip_addr_str = phost_str;
        pinfo->uid = index;
        pinfo->fd = UNDEF_FD;
        pinfo->port = (ret == MB_STR_LEN_IDX_IP4_PORT) ? port : CONFIG_FMB_TCP_PORT_DEFAULT;
        pinfo->addr_type = MB_IPV4;
        pinfo->proto = MB_TCP;
        return ret;
    }

Error logs or terminal output

Steps to reproduce the behavior

Add a modbus tcp slave device to the IP table on V2.0.2 with formatt: "1:192.168.1.1:502"
and it wont be found. Add with ";" and will be found.

Project release version

V2.0.2

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Linux

Operating system version

Ubuntu 25.04

Shell

Bash

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions