Exemple #1
0
 def __init__(self, objectPath, trace=None):
     super(Si446xDbus, self).__init__(objectPath)
     self.uuid = binascii.hexlify(os.urandom(16))
     self.status = 'OFF'
     self.control_event = None
     self.obj_handler = objects.DBusObjectHandler(self)
     self.trace = trace if (trace) else si446xtrace.Trace(100)
Exemple #2
0
    def __init__(self,
                 device=0,
                 callback=None,
                 trace=None,
                 spi_clock=None,
                 nirq=GPIO_NIRQ,
                 cts=GPIO_CTS,
                 sdn=GPIO_SDN):
        """
        Initialize Si446x Radio Device API

        RPi defines a single SPI interface with two chip selects. This
        allows for two devices (0 and 1) to be connected and separately
        accessed. A SpiInterface object is created for one of these devices.

        The callback function handles the RPi interrupt from the GPIO
        pin which should be wired to the radio interrupt pin. See
        """
        self.trace = trace if (trace) else si446xtrace.Trace(100)
        self.channel = 0
        self.callback = callback if (callback) else self._gpio_callback
        self.config_strings = ''
        self.dump_strings = {}
        self.spi = SpiInterface(device, cts, trace=self.trace, clock=spi_clock)
        self.gpio_nirq = nirq
        self.gpio_cts = cts
        self.gpio_sdn = sdn
        result = set_real_time()
        if (result):
            print('failure to initialize si446x radio realtime: {}'.format(
                result))
Exemple #3
0
def setup_driver():
    """
    Instantiate all of the driver components

    includes the following objects:
    trace, dbus, radio, state machine actions, finite state machine.

    Returns list of [fsm, radio, dbus] object references.
    """
    trace = si446xtrace.Trace(1000)
    dbus = Si446xDbus(OBJECT_PATH, trace=trace)
    radio = Si446xRadio(device=0, callback=dbus.async_interrupt, trace=trace)
    print('init radio done')
    actions = Si446xFsmActionHandlers(radio, dbus)
    machine = constructFiniteStateMachine(
        inputs=Events,
        outputs=Actions,
        states=States,
        table=table,
        initial=States.S_SDN,
        richInputs=[],
        inputContext={},
        world=MethodSuffixOutputer(actions),
    )
    fsm = {'actions': actions, 'machine': machine, 'trace': trace}
    dbus.marry(fsm, radio)
    return [fsm, radio, dbus]
Exemple #4
0
def si446xradio_test():
    import si446xtrace
    trace = si446xtrace.Trace(100)
    radio = Si446xRadio(device=0,
                        callback=si446xtrace_test_callback,
                        trace=trace)
    test_radio(radio, trace)
    test_trace(radio, trace)
    return trace, radio
Exemple #5
0
 def __init__(self, device, trace=None):
     try:
         self.trace = trace if (trace) else si446xtrace.Trace(100)
         self.spi = spidev.SpiDev()
         self.spi.open(0, device)  # port=0, device(CS)=device_num
         #self.spi.max_speed_hz=600000
         self.trace.add('RADIO_CHIP',
                        'spi max speed: {}'.format(self.spi.max_speed_hz),
                        level=2)
     except IOError as e:
         self.trace.add('RADIO_INIT_ERROR', e, level=2)
Exemple #6
0
    def __init__(self, device=0, callback=None, trace=None):
        """
        Initialize Si446x Radio Device API

        RPi defines a single SPI interface with two chip selects. This
        allows for two devices (0 and 1) to be connected and separately
        accessed. A SpiInterface object is created for one of these devices.

        The callback function handles the RPi interrupt from the GPIO
        pin which should be wired to the radio interrupt pin. See
        """
        self.trace = trace if (trace) else si446xtrace.Trace(100)
        self.channel = 0
        self.callback = callback if (callback) else self._gpio_callback
        self.dump_strings = {}
        self.spi = SpiInterface(device, trace=self.trace)
Exemple #7
0
    def __init__(self, device, trace=None):
        """
        Initialize the SPI interface

        Establish connection to device provided by spidev and RPi and
        set speed
        """
        try:
            self.trace = trace if (trace) else si446xtrace.Trace(100)
            self.device = device
            self.spi = spidev.SpiDev()
            self.spi.open(0, device)  # port=0, device(CS)=device_num
            #self.spi.max_speed_hz=600000
            self.trace.add('RADIO_CHIP',
                           'spi max speed: {}'.format(self.spi.max_speed_hz),
                           level=2)
        except IOError as e:
            self.trace.add('RADIO_INIT_ERROR', e, level=2)
Exemple #8
0
    def __init__(self, device, cts, trace=None, clock=None):
        """
        Initialize the SPI interface

        Establish connection to device provided by spidev and RPi and
        set speed
        """
        try:
            self.trace = trace if (trace) else si446xtrace.Trace(100)
            self.device = device
            self.spi = spidev.SpiDev()
            self.spi.open(0, device)  # port=0, device(CS)=device_num
            self.spi.max_speed_hz = (4000000)
            if clock:
                self.spi.max_speed_hz = clock
            self.gpio_cts = cts
            self.hard_cts = False
            print('si446xradio', self.spi.max_speed_hz)
            self.trace.add('RADIO_CHIP',
                           'spi max speed: {}'.format(self.spi.max_speed_hz),
                           level=2)
        except IOError as e:
            self.trace.add('RADIO_INIT_ERROR', e, level=2)
Exemple #9
0
 def __init__(self, device=0, callback=None, trace=None):
     self.trace = trace if (trace) else si446xtrace.Trace(100)
     self.channel = 0
     self.callback = callback if (callback) else self._gpio_callback
     self.dump_strings = {}
     self.spi = SpiInterface(device, trace=self.trace)