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
devlib: add monsoon instrument #100
Conversation
Signed-off-by: Joel Fernandes <joelaf@google.com>
This does not implement the http://pythonhosted.org/devlib/instrumentation.html
Also please could you provide more information on what "monsoon" is. How does one get a hold of it, why would someone want to use it, etc? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelagnel the AEP instrument is quite similar to Monsoon, apart from having 3 channels instead of the single one available in the monsoon.
You should have a look at its code:
https://github.com/ARM-software/devlib/blob/master/devlib/instrument/energy_probe.py
and, for the monsoon device, just "hardcode" in its ctor the registration of the single channel available.
The sampling parameters also should probably be part of the InstrumentChannel registration. More details in the inline comments.
from devlib.utils.misc import which | ||
|
||
class MonsoonInstrument(Instrument): | ||
MONSOON_BIN = "./tools/scripts/monsoon.par" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tool/script is not part of the PR, can it be included?
If the license allows it, you should probably place it under:
devlib/bin/scripts
Otherwise, you can just use an additional mandatory monsoon_bin
's __init__
parameter to specify its path.
Client code, e.g. LISA, can provide the path at creation time.
super(MonsoonInstrument, self).__init__(target) | ||
|
||
if not os.path.exists(MonsoonInstrument.MONSOON_BIN): | ||
self.log_error("monsoon.par not found", exception=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, if possible, we should report some tip on how to get this binary.
This is what we did in LISA for the ACME cape:
https://github.com/ARM-software/lisa/blob/master/libs/utils/energy.py#L344
@setrofim: can this work for devlib as well?
print "INFO: " + msg | ||
self.logger.info(msg) | ||
|
||
def __init__(self, target, device_entry=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about s/device_entry/device/
?
This _entry
suffix seems not necessary...
self.device_entry = device_entry | ||
self.process = None | ||
|
||
self.log_info('Found monsoon.par') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not report "it's working" type of comments, let's log only useful information and/or warnings/errors.
In devlib modules are "as much quite as possible". ;-)
self.log_info('Found monsoon.par') | ||
|
||
def reset(self): | ||
self.log_info('Initiailzing MonsoonInstrument') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some as above, not useful information to be reported here.
self.run_monsoon(['--status'], timeout=3) | ||
self.log_info("MonsoonInstrument ready for action") | ||
|
||
def kill_monsoon(self, p): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Monsoon device we can probably support (at least initially) only the CONTINUOUS interface, thus you need to implement only 4 public methods: reset
, start
, stop
and get_data
.
Here is an example:
https://github.com/ARM-software/devlib/blob/master/devlib/instrument/energy_probe.py#L35
|
||
# Returns pandas dataframe for monsoon output (time and current in mA) | ||
def get_samples_sync(self, duration): | ||
txt = self.run_monsoon(['--hz', '5', '--timestamp', '--samples', '2000000'], stream=1, timeout=duration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These params should probably be exported somehow. Perhaps, since we have a single channel, we can specify them in the __init__
?
In that case you can use them to configure the single InstrumentChannel which is going to be registered, as part of the instrument specific attrs
:
https://github.com/ARM-software/devlib/blob/master/devlib/instrument/__init__.py#L142
@setrofim Monsoon is this single channel energy meter: It is thus quite important to have support for this device within devlib and LISA. |
I have a simplified version of this functionality here: https://github.com/bjackman/devlib/blob/monsoon/devlib/instrument/monsoon.py It seems to be working pretty well, not ready for merge though because:
|
The path to the tool can be passed as an argument on This would make the instrument more awkward to use, so including the binary and setting the path in a class attribute would be preferable, but the above approach can be used to unblock the merging of the instrument in the mean time. If/when the IP issues are resolved, and the tool can be included in devlib, the attribute can remain, and simply be made optional, defaulting to the internal version. That way backward compatibility with existing setups will be maintained. |
Some notes on this PR following from out-of-band chat with @joelagnel:
|
Form what I understood from the code, these set voltage/current in the monsoon device, not on the target. If that is the case, then the instrument is the right place for this, as they relate to monsoon device, rather than the target (even if they need to be adjusted to different values for different targets).
Agreed. It would be good to link to the the script in the documentation for this instrument. |
Actually Monsoon is a power supply as well as a measurement tool, so these really do set the voltage and (max?) current on the device. It's designed for testing mobile device prototypes by acting as a "fake battery". |
Right, so these are the configurations of the Monsoon power supply, not of the target. So the |
OK, sounds good. |
Superseded by #119 |
Signed-off-by: Joel Fernandes joelaf@google.com