text stringlengths 0 828 |
|---|
return self._set_series_capacitance(channel, value)" |
962,"def set_series_resistance(self, channel, value, resistor_index=None): |
''' |
Set the current series resistance value for the specified channel. |
Parameters |
---------- |
channel : int |
Analog channel index. |
value : float |
Series resistance value. |
resistor_index : int, optional |
Series resistor channel index. |
If :data:`resistor_index` is not specified, the resistor-index from |
the current context _(i.e., the result of |
:attr:`series_resistor_index`)_ is used. |
Otherwise, the series-resistor is temporarily set to the value of |
:data:`resistor_index` to set the resistance before restoring back |
to the original value. |
See definition of :meth:`safe_series_resistor_index_read` |
decorator. |
Returns |
------- |
int |
Return code from embedded call. |
''' |
if resistor_index is None: |
resistor_index = self.series_resistor_index(channel) |
try: |
if channel == 0: |
self.calibration.R_hv[resistor_index] = value |
else: |
self.calibration.R_fb[resistor_index] = value |
except: |
pass |
return self._set_series_resistance(channel, value)" |
963,"def connect(self, port=None, baud_rate=115200): |
''' |
Parameters |
---------- |
port : str or list-like, optional |
Port (or list of ports) to try to connect to as a DMF Control |
Board. |
baud_rate : int, optional |
Returns |
------- |
str |
Port DMF control board was connected on. |
Raises |
------ |
RuntimeError |
If connection could not be established. |
IOError |
If no ports were specified and Arduino Mega2560 not found on any |
port. |
''' |
if isinstance(port, types.StringTypes): |
ports = [port] |
else: |
ports = port |
if not ports: |
# No port was specified. |
# |
# Try ports matching Mega2560 USB vendor/product ID. |
ports = serial_ports().index.tolist() |
if not ports: |
raise IOError(""Arduino Mega2560 not found on any port."") |
for comport_i in ports: |
if self.connected(): |
self.disconnect() |
self.port = None |
self._i2c_devices = {} |
# Try to connect to control board on available ports. |
try: |
logger.debug('Try to connect to: %s', comport_i) |
# Explicitly cast `comport_i` to string since `Base.connect` |
# Boost Python binding does not support unicode strings. |
# |
# Fixes [issue 8][issue-8]. |
# |
# [issue-8]: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/8 |
Base.connect(self, str(comport_i), baud_rate) |
self.port = comport_i |
break |
except BadVGND, exception: |
logger.warning(exception) |
break |
except RuntimeError, exception: |
continue |
else: |
raise RuntimeError('Could not connect to control board on any of ' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.