예제 #1
0
파일: tui_main.py 프로젝트: dwhall/HeyMac
def main():
    # logging.basicConfig(
    #    filename="/home/pi/heymaclog.txt",
    #    format="%(asctime)s %(message)s",
    #    level=logging.DEBUG)

    # Init platform configuration and SX127x radio
    spi_cfg = SpiConfig(port=0, cs=0, freq=10_000_000)
    dio_cfg = DioConfig(4, 23, 24, 6, 5, 22)
    reset_cfg = ResetConfig(17)
    sx127x = SX127x(spi_cfg, dio_cfg, reset_cfg)

    # Init user radio settings
    radio_stngs = (
        ("FLD_RDO_FREQ", 432_550_000),
        ("FLD_LORA_CR", SX127xSettings.STNG_LORA_CR_4TO6),
        ("FLD_LORA_BW", SX127xSettings.STNG_LORA_BW_250K),
        ("FLD_LORA_SF", SX127xSettings.STNG_LORA_SF_128_CPS),
    )

    # Init and start the state machines
    phy_hsm = SX127xHsm(sx127x, True, radio_stngs)
    lnk_hsm = HeymacCsmaHsm(phy_hsm)
    tui_hsm = TxtUiHsm(phy_hsm, lnk_hsm)
    gps_hsm = GpsHsm(pps_pin=26)

    lnk_hsm.start(50)
    phy_hsm.start(40)
    tui_hsm.start(30)
    gps_hsm.start(60)

    gps_hsm.open("/dev/serial0")

    farc.run_forever()
예제 #2
0
def main():
    saddr = utl.get_long_mac_addr("KC4KSU")
    # The hostname is the station ID
    station_id = socket.gethostname().encode()

    # Instantiate state machines
    gpioAhsm = heymac.GpioAhsm()
    spiAhsm = heymac.SX127xSpiAhsm(prj_stngs.spi_stngs, prj_stngs.modem_stngs)
    uartAhsm = heymac.UartAhsm(heymac.parse_nmea)
    macAhsm = heymac.HeyMacCsmaAhsm(saddr, station_id)

    # Register GPIO inputs to emit signals
    for pin_nmbr, pin_edge, sig_name in prj_cfg.gpio_ins:
        gpioAhsm.register_pin_in(pin_nmbr, pin_edge, sig_name)
    for pin_nmbr, pin_initial in prj_cfg.gpio_outs:
        gpioAhsm.register_pin_out(pin_nmbr, pin_initial)

    # Start state machines
    spiAhsm.start(10)
    gpioAhsm.start(20)
    uartAhsm.start(30)
    macAhsm.start(50)

    # Open the UART to process NMEA
    uartAhsm.post_open(prj_cfg.uart_cfg)

    farc.run_forever()
예제 #3
0
def mainFunction():
    # create an flick event.
    farc.Signal.register("FLICK")
    event = farc.Event(farc.Signal.FLICK, None)

    sw = OnOffSwitch()
    sw.start(0)

    loop = asyncio.get_event_loop()
    loop.call_later(2.0, postFlickEvent, sw, event)

    farc.run_forever()
예제 #4
0
파일: dpp.py 프로젝트: bestnike/farc
def main():
    global philo

    table = Table()
    table.start(0)

    philo = []
    for n in range(N_PHILO):
        p = Philo()
        p.start(n + 1)
        philo.append(p)

    farc.run_forever()
예제 #5
0
        elif sig == farc.Signal.EXIT:
            print("_red exit")
            return self.handled(event)

        return self.super(self.top)

    @farc.Hsm.state
    def _green(self, event):
        sig = event.signal
        if sig == farc.Signal.ENTRY:
            print("_green enter")
            return self.handled(event)

        elif sig == farc.Signal.TIME_TICK:
            print("_green next")
            return self.tran(Stoplight._red)

        elif sig == farc.Signal.EXIT:
            print("_green exit")
            return self.handled(event)

        return self.super(self.top)


if __name__ == "__main__":
    sl = Stoplight()
    sl.start(0)

    farc.run_forever()