Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create more than one slave under a TCP connection #78

Open
Fhui opened this issue Jul 16, 2022 · 4 comments
Open

Cannot create more than one slave under a TCP connection #78

Fhui opened this issue Jul 16, 2022 · 4 comments

Comments

@Fhui
Copy link

Fhui commented Jul 16, 2022

I want to create multiple slaves after establishing a TCP connection, but the slave object is bound to the parameters of the TCP connection. If you continue to create it, there will be an exception that the port has been occupied, so is there any other way?

@Fhui
Copy link
Author

Fhui commented Jul 16, 2022

I don't want to establish multiple TCP connections. I just want to create multiple slaveids after establishing a TCP connection

@mastera74
Copy link

Did you manage to resolve this issue?

@halimselim
Copy link
Contributor

I developed a dirty solution for myself. I forwarded slaveid to dataholder.
Disabled slave id filter in [RequestHandlerTCP.java] to catch all request

If you like my solution I would create a pull request.

master...halimselim:jlibmodbus:master

public class MyDataHolder extends DataHolder {

    @Override
    public int[] readHoldingRegisterRange(int slaveid, int offset, int quantity) throws IllegalDataAddressException {

    }
}

@Fhui
Copy link
Author

Fhui commented Nov 8, 2022

我为自己开发了一个肮脏的解决方案。 在 [RequestHandler.java] 中禁止slaveid过滤器以请求所有请求

如果您喜欢我的解决方案,我会创建一个拉取请求。

主... halimselim:jlibmodbus:master

public class MyDataHolder extends DataHolder {

    @Override
    public int[] readHoldingRegisterRange(int slaveid, int offset, int quantity) throws IllegalDataAddressException {

    }
}

thanks

I'm going to use another library, modbus4j, it's good

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

No branches or pull requests

3 participants