text
stringlengths 0
828
|
|---|
'the following ports: %s' % ports)
|
name = self.name()
|
version = self.hardware_version()
|
firmware = self.software_version()
|
serial_number_string = """"
|
try:
|
serial_number_string = "", S/N %03d"" % self.serial_number
|
except:
|
# Firmware does not support `serial_number` attribute.
|
pass
|
logger.info(""Connected to %s v%s (Firmware: %s%s)"" %
|
(name, version, firmware, serial_number_string))
|
logger.info(""Poll control board for series resistors and ""
|
""capacitance values."")
|
self._read_calibration_data()
|
try:
|
self.__aref__ = self._aref()
|
logger.info(""Analog reference = %.2f V"" % self.__aref__)
|
except:
|
# Firmware does not support `__aref__` attribute.
|
pass
|
# Check VGND for both analog channels
|
expected = 2 ** 10/2
|
v = {}
|
channels = [0, 1]
|
damaged = []
|
for channel in channels:
|
try:
|
v[channel] = np.mean(self.analog_reads(channel, 10))
|
logger.info(""A%d VGND = %.2f V (%.2f%% of Aref)"", channel,
|
self.__aref__ * v[channel] / (2 ** 10), 100.0 *
|
v[channel] / (2 ** 10))
|
# Make sure that the VGND is close to the expected value;
|
# otherwise, the op-amp may be damaged (expected error
|
# is <= 10%).
|
if np.abs(v[channel] - expected) / expected > .1:
|
damaged.append(channel)
|
except:
|
# Firmware does not support `__aref__` attribute.
|
break
|
# Scan I2C bus to generate list of connected devices.
|
self._i2c_scan()
|
if damaged:
|
# At least one of the analog input channels appears to be damaged.
|
if len(damaged) == 1:
|
msg = ""Analog channel %d appears"" % damaged[0]
|
else:
|
msg = ""Analog channels %s appear"" % damaged
|
raise BadVGND(msg + "" to be damaged. You may need to replace the ""
|
""op-amp on the control board."")
|
return self.RETURN_OK"
|
964,"def persistent_write(self, address, byte, refresh_config=False):
|
'''
|
Write a single byte to an address in persistent memory.
|
Parameters
|
----------
|
address : int
|
Address in persistent memory (e.g., EEPROM).
|
byte : int
|
Value to write to address.
|
refresh_config : bool, optional
|
Is ``True``, :meth:`load_config()` is called afterward to refresh
|
the configuration settings.
|
'''
|
self._persistent_write(address, byte)
|
if refresh_config:
|
self.load_config(False)"
|
965,"def persistent_read_multibyte(self, address, count=None, dtype=np.uint8):
|
'''
|
Read a chunk of data from persistent memory.
|
Parameters
|
----------
|
address : int
|
Address in persistent memory (e.g., EEPROM).
|
count : int, optional
|
Number of values to read.
|
If not set, read a single value of the specified :data:`dtype`.
|
dtype : numpy.dtype, optional
|
The type of the value(s) to read.
|
Returns
|
-------
|
dtype or numpy.array(dtype=dtype)
|
If :data:`count` is ``None``, return single value.
|
Otherwise, return array of values.
|
'''
|
nbytes = np.dtype(dtype).itemsize
|
if count is not None:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.