Skip to content

Conversation

@chr1shung
Copy link
Contributor

No description provided.

@chr1shung chr1shung marked this pull request as draft December 13, 2022 04:57
@janiversen
Copy link
Collaborator

Let’s see what CI thinks

@chr1shung
Copy link
Contributor Author

Sry just fixed on of the CI error, can you trigger again ?

@janiversen
Copy link
Collaborator

if you have the newest dev, you can run the checks locally with ./check_ci.sh

I am off for the next 8-10 hours.

@chr1shung
Copy link
Contributor Author

chr1shung commented Dec 13, 2022

any idea why the CI / black is failing ?
I ran check_ci.sh and it said it's ready to push

@janiversen
Copy link
Collaborator

janiversen commented Dec 13, 2022 via email

@chr1shung chr1shung marked this pull request as ready for review December 13, 2022 10:26
Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave it to @dhoomakethu to decide, which help is better.

0,
"--change-rate",
"-c",
help="Chance of randomizing reads. 0=never, 100=always, 1=1%"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
help="Chance of randomizing reads. 0=never, 100=always, 1=1%"
help="Rate in % of registers to change. 0=none, 100=all, 12=12% of registers"

I believe this is a better help.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, --change-rate ,--probability or simply --likely are all OK.

@chr1shung chr1shung requested review from dhoomakethu and janiversen and removed request for dhoomakethu and janiversen December 14, 2022 03:08
Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change !

max_register_value = kwargs.get("max_register_value", 65535)
self._randomize = randomize
self._change_rate = change_rate
if self._randomize > 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will potentially confuse a user, please add a logger message so the user knows why -r did not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the new commit, do you have any suggestion on how to handle the case that user provide both flags ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference is to terminate with an error message, but at the very least the user needs to be aware that the -c is voided.

self._read_counter[_block_type] += 1
elif self._change_rate > 0 and _block_type in {"d", "i"}:
for offset in range(count):
if random.randint(1, 100) <= self._change_rate:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work but not with the effect you described. E.g. -r 50, and 100 registers….randint will be called 100 times but potentially deliver no value below 50.

Please either correct or correct help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I push a new commit per @dhoomakethu's suggestion and I think that solved the problem

:param unit: Unit id for the slave
:param single: To run as a single slave
:param randomize: Randomize every <n> reads for DI and IR.
:param change_rate: Rate in % of registers to change for DI and IR.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code do not work in % but random, that is every run will change a different number of registers some will change more registers than -r % and others fewer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I push a new commit per @dhoomakethu's suggestion and I think that solved the problem

@janiversen
Copy link
Collaborator

The failing test is not due to your code, it is a CI problem.

I merge this now, please make a new PR for what you decide to do with overwriting -r

@janiversen janiversen merged commit 8b38047 into pymodbus-dev:dev Dec 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants