• Home
  • History
  • Annotate
  • Raw
  • Download

Lines Matching refs:self

75   def __init__(self, device=None, serialno=None, wait=1):  argument
84 self._coarse_ref = self._fine_ref = self._coarse_zero = self._fine_zero = 0
85 self._coarse_scale = self._fine_scale = 0
86 self._last_seq = 0
87 self.start_voltage = 0
90 self.ser = serial.Serial(device, timeout=1)
97 self._tempfile = open(tmpname, "w")
103 fcntl.lockf(self._tempfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
109 self.ser = serial.Serial("/dev/%s" % dev, timeout=1)
110 self.StopDataCollection() # just in case
111 self._FlushInput() # discard stale input
112 status = self.GetStatus()
123 self.start_voltage = status["voltage1"]
126 self._tempfile = None
132 def GetStatus(self): argument
153 self._SendStruct("BBB", 0x01, 0x00, 0x00)
155 bytes = self._ReadPacket()
180 def RampVoltage(self, start, end): argument
184 self.SetVoltage(v)
187 self.SetVoltage(end)
189 def SetVoltage(self, v): argument
192 self._SendStruct("BBB", 0x01, 0x01, 0x00)
194 self._SendStruct("BBB", 0x01, 0x01, int((v - 2.0) * 100))
197 def SetMaxCurrent(self, i): argument
202 self._SendStruct("BBB", 0x01, 0x0a, val & 0xff)
203 self._SendStruct("BBB", 0x01, 0x0b, val >> 8)
205 def SetUsbPassthrough(self, val): argument
207 self._SendStruct("BBB", 0x01, 0x10, val)
210 def StartDataCollection(self): argument
212 self._SendStruct("BBB", 0x01, 0x1b, 0x01) # Mystery command
213 self._SendStruct("BBBBBBB", 0x02, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8)
216 def StopDataCollection(self): argument
218 self._SendStruct("BB", 0x03, 0x00) # stop
221 def CollectData(self): argument
224 bytes = self._ReadPacket()
235 if self._last_seq and seq & 0xF != (self._last_seq + 1) & 0xF:
237 self._last_seq = seq
240 if not self._coarse_scale or not self._fine_scale:
246 return ((val & ~1) - self._coarse_zero) * self._coarse_scale
248 return (val - self._fine_zero) * self._fine_scale
258 self._fine_zero = data[0][0]
259 self._coarse_zero = data[1][0]
264 self._fine_ref = data[0][0]
265 self._coarse_ref = data[1][0]
273 if self._coarse_ref != self._coarse_zero:
274 self._coarse_scale = 2.88 / (self._coarse_ref - self._coarse_zero)
275 if self._fine_ref != self._fine_zero:
276 self._fine_scale = 0.0332 / (self._fine_ref - self._fine_zero)
279 def _SendStruct(self, fmt, *args): argument
285 self.ser.write(out)
288 def _ReadPacket(self): argument
290 len_char = self.ser.read(1)
299 result = self.ser.read(data_len)
308 def _FlushInput(self): argument
310 self.ser.flush()
313 ready_r, ready_w, ready_x = select.select([self.ser], [], [self.ser], 0)
319 self.ser.read(1) # This may cause underlying buffering.
320 self.ser.flush() # Flush the underlying buffer too.