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

Don't modify register addresses #16

Open
phibos opened this issue Nov 11, 2016 · 3 comments
Open

Don't modify register addresses #16

phibos opened this issue Nov 11, 2016 · 3 comments

Comments

@phibos
Copy link
Contributor

phibos commented Nov 11, 2016

In the file command_line.c you decrease the given register address by 1.

case 'a':
	rc = parse_int_param(optarg, &params->sad);
	if (params->sad <= 0) {
		ERR("Address should be greater than zero: %s\n", optarg);
		rc = RESULT_WRONG_ARG;
	}
	params->sad--; /* register/bit address starts from 0 */
break;

Is there any reason to modify the register address instead of using the given value? The start address of the devices I use is 1. That's why I have to set the address to 2 on the commandline. This might be very confusing for people comparing the device documentation with my check configuration.

@AndreySV
Copy link
Owner

Real register and bit addresses start in Modbus protocol from 0.

But unfortunately device manufactures use very different address schemes.
Sometimes registers start from 0, sometimes manufactures think that it's confusing that the first address is zero and start registers from 1.
There are address schemes that include register type (input/holding) in the address. For example, 30001 (first input register), 40001 (first holding register).

The real address is stored internally in params->sad. There is a short description about that in the man page .

@phibos
Copy link
Contributor Author

phibos commented Nov 17, 2016

Sure. But I think it is a bit confusing. Might be a better idea to add a command line option like --fix-address and decrease the address if set or to keep compatibility add a command line option like --use-raw-address and don't decrease the address if set.

@AndreySV
Copy link
Owner

What about introducing different addressing schemes as additional parameter: "start from 0", "start from 1", "address space and register number together"? By default, address will be interpreted as before: "start from 1".

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

2 participants