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

rest() from Iec6205621Client #12

Closed
youserj opened this issue Jun 12, 2020 · 4 comments
Closed

rest() from Iec6205621Client #12

youserj opened this issue Jun 12, 2020 · 4 comments

Comments

@youserj
Copy link

youserj commented Jun 12, 2020

def rest(self, duration=None):
    """
    The protocol needs some timeouts between reads and writes to enable the device
    to properly parse a message and return the result.
    """

    _duration = duration or (self.reaction_time * 1.25)
    logger.debug(f"Resting for {_duration} seconds")
    time.sleep(_duration)

For self.use_short_reaction_time = True dont work. At first need decide time of writing message:

def time_write(self, msg):
    """
    return need time of write
    """
    return (1 / self.port.get_settings()['baudrate'] * len(msg)) 
    #or return (1 / self._current_baudrate * len(msg)*10) 

where msg is the ack_message.to_bytes() or 6

After self.rest(self.reaction_time +self.transport.time_write(ack_message.to_bytes()))
or

@Krolken
Copy link
Contributor

Krolken commented Jun 12, 2020

Hi.

Are you proposing a change? I don't have any devices that uses short reaction time and cannot test against it.
Do you have one?

@youserj
Copy link
Author

youserj commented Jun 12, 2020

yes. I develop soft and powermeter at the moment.
And more one problem:
(Acknowledgement/option select message = 20ms) + (short_reaction_time = 20ms) = 40ms
however - self.port.flush() - give delay about 50ms(in windows 10).
can I remove flush?
and make delay use time.time() into rest method

@Krolken
Copy link
Contributor

Krolken commented Jun 14, 2020

If you want to try out some differnet settings i sugest you subclass and override.
I don't see how flush should be a problem since it returns when all data is sent. You don't want to close the port while stil having data in the outbuffer.

Also the timings are mostly not a problem, since you write and then do a blocking read. So the only time you have to make sure to wait is when you receive something and then send it back.

What meter are you using?

@Krolken
Copy link
Contributor

Krolken commented Jul 3, 2020

Closing due to inactivity. Please open again if needed.

@Krolken Krolken closed this as completed Jul 3, 2020
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