def setup(self, console=True, copyDongle=None): # setup spi_serial self.recv_mbox = {} self.SpiSerial = spi_serial.SpiSerial() self.SpiSerial.reset() self.getRadioConfig() chip = self.getPartNum() chipstr = CHIPS.get(chip) self.chipnum = chip self.chipstr = chipstr if chip == None: print "Older firmware, consider upgrading." else: self.chipstr = "unrecognized dongle: %s" % chip self._do = chip if self._init_on_reconnect: if self._radio_configured: self.recv_mbox = {} self.setRadioConfig() else: self.setRFparameters() self._radio_configured = True
def __init__(self, serial_port, rtscts=None): if not rtscts: rtscts = int(os.getenv('RFSPY_RTSCTS', 1)) if serial_port.find('spi') >= 0: import spi_serial self.ser = spi_serial.SpiSerial() else: self.ser = serial.Serial(serial_port, 19200, rtscts=rtscts, timeout=1) self.buf = bytearray()
def init_spi_serial(): # invoke same command's as reset_spi_serial.py # https://github.com/scottleibrand/spi_serial/blob/master/scripts/reset_spi_serial.py # this will reset the spi serial connection (if it's used) try: logging.debug("Import spi_serial") import spi_serial logging.debug("Opening spidev serial connection") s = spi_serial.SpiSerial() logging.debug("Issuing spidev serial reset") s.reset() except ImportError: # silence import error by default logging.debug("spi_serial not installed. Assuming not using spidev") except Exception: logging.exception("Exception in oref0-init-pump-comms spi_serial") sys.exit(1)
def open(self): if not self.serial: log.info('{agent} opening serial port'.format( agent=self.__class__.__name__)) if fuser.in_use(self.device): raise AlreadyInUseException("%s already in use" % self.device) if self.device.find('spi') >= 0: import spi_serial self.serial = spi_serial.SpiSerial() self.check_setup() else: self.serial = serial.Serial(self.device, self.speed) self.clear_receive_buffer('New port open') self.check_setup() return True
#!/usr/bin/python import spi_serial s = spi_serial.SpiSerial() s.reset()