Esempio n. 1
0
def dec_fs_com1():
    lgt = 2
    dat = pyuipc.prepare_data([(0x311A, lgt)])
    val = pyuipc.read(dat)
    freq = decode_freq(decode_bcd(val[0]))
    new  = encode_bcd(encode_freq(dec_com(freq)))
    pyuipc.write(dat, [new])
Esempio n. 2
0
def dec_fs_com1():
    lgt = 2
    dat = pyuipc.prepare_data([(0x311A, lgt)])
    val = pyuipc.read(dat)
    freq = decode_freq(decode_bcd(val[0]))
    new = encode_bcd(encode_freq(dec_com(freq)))
    pyuipc.write(dat, [new])
Esempio n. 3
0
def loop():
    global pyuipcOffsets, oldActMode, actMode, client, alivetime, hasAP, oldAPStatus, panel, APStatus

    results = pyuipc.read(pyuipcOffsets)
    APStatus = results[0]
    hasAP = results[1]

    if (oldActMode != actMode):
        # Instanciate panel class child, specific to each panel
        logging.info("Changing mode to " + actMode)

        if actMode == "Home":
            panel = Home(client)
        if actMode == "RtuCom":
            panel = RtuCom(client)
        if actMode == "RtuNav":
            panel = RtuNav(client)
        if actMode == "Audio":
            panel = Audio(client)
        if actMode == "AP":
            panel = AP(client)
        if actMode == "Perfs":
            panel = Perfs(client)
        if actMode == "Trim":
            panel = Trim(client)
        oldActMode = actMode

    # loop that updates panel
    panel.run(event)
    if event.getPayload() == str(Const.BTMAIN):  #return to home
        actMode = "Home"
        event.clear()
    if event.getPayload() == str(Const.BTAP):  # AP
        APStatus = APStatus ^ 1
        event.clear()

    # de/activate autopilot
    if (APStatus != oldAPStatus):
        if (APStatus == 0):
            client.publish(Config.topic_display, "X")
            client.publish(Config.topic_display, "L,0")
            # Beep when AP is disabled
            client.publish(Config.topic_display, "X")
        else:
            client.publish(Config.topic_display, "L,1")
        pyuipc.write([(OFFSETS[0][0], OFFSETS[0][1], APStatus)])
        oldAPStatus = APStatus

    # keepalive to esp32 module every 2 seconds, just say "i'm here"

    if ((time.time() - alivetime) > 2):
        logging.debug("Send keep alive to esp32 module")
        client.publish(Config.topic_prefix + "/c/reqstatus", "1")
        alivetime = time.time()
Esempio n. 4
0
    def update_fuel(self):
        # Initialise list for data writing.
        data_out = []

        # Get fuel level in % and add to out data.
        fuel_levels = [0.0] * self.N_TANKS
        for lvl in range(self.N_TANKS):
            if self.fuel_capacity_kg[lvl] > 0.1:
                fuel_levels[lvl] = int(self.fuel_levels_kg[lvl] /
                                       self.fuel_capacity_kg[lvl] * 8388608)
            else:
                fuel_levels[lvl] = 0
            lvl_offsets = self.OFFSETS[2 + lvl * 2]
            data_out.append((lvl_offsets[0], lvl_offsets[1], fuel_levels[lvl]))

        # Write data to simulator.
        pyuipc.write(data_out)
Esempio n. 5
0
def requestMETAR(ICAOid):
    """
    Returns a METAR string given the 4 code ICAO. The METAR is
    in FSX enanched format.
    """
    # Writing both signature ('05FC'+ICAO) as 8 byte. Signature is the
    # required trigger.
    data = [ (WRITE_ICAO_FOR_METAR, byte[WRITE_ICAO_FOR_METAR]) ]
    signature = '05FC'
    pdata = fsuipc.prepare_data(data)
    fsuipc.write(pdata, [signature+ICAOid])

    time_delay = 250e-3 # ms. Required for FSX reading.
    time.sleep(time_delay)

    data = [ (METAR, byte[METAR]) ]
    pdata = fsuipc.prepare_data(data)
    metar = fsuipc.read(pdata)

    return metar[0].rstrip('\x00')
Esempio n. 6
0
def requestMETAR(ICAOid):
    """
    Returns a METAR string given the 4 code ICAO. The METAR is
    in FSX enanched format.
    """
    # Writing both signature ('05FC'+ICAO) as 8 byte. Signature is the
    # required trigger.
    data = [(WRITE_ICAO_FOR_METAR, byte[WRITE_ICAO_FOR_METAR])]
    signature = '05FC'
    pdata = fsuipc.prepare_data(data)
    fsuipc.write(pdata, [signature + ICAOid])

    time_delay = 250e-3  # ms. Required for FSX reading.
    time.sleep(time_delay)

    data = [(METAR, byte[METAR])]
    pdata = fsuipc.prepare_data(data)
    metar = fsuipc.read(pdata)

    return metar[0].rstrip('\x00')
Esempio n. 7
0
def set_value(offset, typ, value):
    lgt = struct.calcsize(typ)
    dat = pyuipc.prepare_data([(offset, lgt)])
    pyuipc.write(dat, [struct.pack(typ, value)])
Esempio n. 8
0
def switch_one_bit(offset):
    lgt = 1
    dat = pyuipc.prepare_data([(offset, lgt)])
    val_ist = pyuipc.read(dat)
    val_sol = chr(not (ord(val_ist[0])))
    pyuipc.write(dat, [val_sol])
Esempio n. 9
0
def set_value(offset, typ, value):
    lgt = struct.calcsize(typ)
    dat = pyuipc.prepare_data([(offset, lgt)])
    pyuipc.write(dat, [struct.pack(typ, value)])
Esempio n. 10
0
    def run(self, event):

        if (self.__editCur != self.__oldEditCur):
            self.draw()
            self.__oldEditCur = self.__editCur

        pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS)
        results = pyuipc.read(pyuipcOffsets)
        actFreq1 = vhf_bcd2float(results[0])
        stbFreq1 = vhf_bcd2float(results[1])
        actFreq2 = vhf_bcd2float(results[2])
        stbFreq2 = vhf_bcd2float(results[3])
        adfFreq = adf_bcd2float(results[4], results[5])
        xpdrCode = int(str(xpdr_bcd2int(results[6])), 8)

        # COM1 Active at LSK3
        if actFreq1 != self.__oldActFreq1:
            self.mqttpublish(Config.topic_display,
                             "T,03,99,0,3," + str('{0:.3f}'.format(actFreq1)))
            self.__oldActFreq1 = actFreq1

        # COM1 Stand by at LSK4
        if stbFreq1 != self.__oldStbFreq1:
            if (self.__editCur == "COM1"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,04,98,0,3," + str('{0:.3f}'.format(stbFreq1)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,Com1StbFq/Psh SW>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,04,99,1,3," + str('{0:.3f}'.format(stbFreq1)))
            self.__oldStbFreq1 = stbFreq1

        # COM2 Active at RSK3
        if actFreq2 != self.__oldActFreq2:
            self.mqttpublish(Config.topic_display,
                             "T,33,99,0,3," + str('{0:.3f}'.format(actFreq2)))
            self.__oldActFreq2 = actFreq2

        # COM2 Stand by at RSK4
        if stbFreq2 != self.__oldStbFreq2:
            if (self.__editCur == "COM2"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,34,98,0,3," + str('{0:.3f}'.format(stbFreq2)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,Com2StbFq/Psh SW>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,34,99,1,3," + str('{0:.3f}'.format(stbFreq2)))
            self.__oldStbFreq2 = stbFreq2

        # ADF at LSK7
        if adfFreq != self.__oldAdfFreq:
            if (self.__editCur == "ADF"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,07,98,0,3," + str('{0:0>6.1f}'.format(adfFreq)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,           ADFFq>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,07,99,1,3," + str('{0:0>6.1f}'.format(adfFreq)))
            self.__oldAdfFreq = adfFreq

        # XPDR at RSK7
        if xpdrCode != self.__oldXpdrCode:
            if (self.__editCur == "XPDR"):
                self.mqttpublish(
                    Config.topic_display, "T,37,98,0,3," +
                    str('{0:0>4.0f}'.format(int(oct(xpdrCode)))))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,       XPDR code>")
            else:
                self.mqttpublish(
                    Config.topic_display, "T,37,99,1,3," +
                    str('{0:0>4.0f}'.format(int(oct(xpdrCode)))))
            self.__oldXpdrCode = xpdrCode

        if (not (event.isEmpty())):

            if (event.getTopic() == "j/npanel/e/s"
                    and event.getPayload() == "1"):
                self.draw()
                logger.debug("Redraw")

            if event.getTopic() == Config.topic_keys:

                if event.getPayload() == str(Const.ENC1DN):  # INC1 DN
                    if (self.__editCur == "COM1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 - 0.025))])
                    if (self.__editCur == "COM2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 - 0.025))])
                    if (self.__editCur == "ADF"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       adf_float2bcd(adfFreq - 0.5)[0])])
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[5][1],
                                       adf_float2bcd(adfFreq - 0.5)[1])])
                    if (self.__editCur == "XPDR"):
                        pyuipc.write([(self.__OFFSETS[6][0],
                                       self.__OFFSETS[6][1],
                                       xpdr_int2bcd(int(oct(xpdrCode - 1))))])

                if event.getPayload() == str(Const.ENC1UP):  # INC1 UP
                    if (self.__editCur == "COM1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 + 0.025))])
                    if (self.__editCur == "COM2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 + 0.025))])
                    if (self.__editCur == "ADF"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       adf_float2bcd(adfFreq + 0.5)[0])])
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[5][1],
                                       adf_float2bcd(adfFreq + 0.5)[1])])
                    if (self.__editCur == "XPDR"):
                        pyuipc.write([(self.__OFFSETS[6][0],
                                       self.__OFFSETS[6][1],
                                       xpdr_int2bcd(int(oct(xpdrCode + 1))))])
                    event.clear()

                if event.getPayload() == str(Const.BTENC):  # SW
                    if (self.__editCur == "COM1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(actFreq1))])
                        pyuipc.write([(self.__OFFSETS[0][0],
                                       self.__OFFSETS[0][1],
                                       vhf_float2bcd(stbFreq1))])
                    if (self.__editCur == "COM2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(actFreq2))])
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1],
                                       vhf_float2bcd(stbFreq2))])
                    event.clear()

                if event.getPayload() == str(Const.ENC2DN):  # INC2 DN
                    if (self.__editCur == "COM1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 - 1))])
                    if (self.__editCur == "COM2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 - 1))])
                    if (self.__editCur == "ADF"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       adf_float2bcd(adfFreq - 10)[0])])
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[5][1],
                                       adf_float2bcd(adfFreq - 10)[1])])
                    if (self.__editCur == "XPDR"):
                        pyuipc.write([(self.__OFFSETS[6][0],
                                       self.__OFFSETS[6][1],
                                       xpdr_int2bcd(int(oct(xpdrCode - 64))))])
                    event.clear()

                if event.getPayload() == str(Const.ENC2UP):  # INC2 UP
                    if (self.__editCur == "COM1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 + 1))])
                    if (self.__editCur == "COM2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 + 1))])
                    if (self.__editCur == "ADF"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       adf_float2bcd(adfFreq + 10)[0])])
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[5][1],
                                       adf_float2bcd(adfFreq + 10)[1])])
                    if (self.__editCur == "XPDR"):
                        pyuipc.write([(self.__OFFSETS[6][0],
                                       self.__OFFSETS[6][1],
                                       xpdr_int2bcd(int(oct(xpdrCode + 64))))])
                    event.clear()

                if event.getPayload() == str(Const.RSK4):  #COM2
                    self.__editCur = "COM2"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.LSK4):  #COM1
                    self.__editCur = "COM1"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.LSK7):  #ADF
                    self.__editCur = "ADF"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RSK7):  #XPDR
                    self.__editCur = "XPDR"
                    self.draw()
                    event.clear()
Esempio n. 11
0
    def run(self, event):
        global actMode, APStatus

        if (self.__editCur != self.__oldEditCur):
            self.draw()
            self.__oldEditCur = self.__editCur

        pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS)
        results = pyuipc.read(pyuipcOffsets)
        actFreq1 = vhf_bcd2float(results[0])
        stbFreq1 = vhf_bcd2float(results[1])
        actFreq2 = vhf_bcd2float(results[2])
        stbFreq2 = vhf_bcd2float(results[3])
        HdgNav1 = results[4]
        HdgNav2 = results[5]

        # NAV1 Active at LSK3
        if actFreq1 != self.__oldActFreq1:
            self.mqttpublish(Config.topic_display,
                             "T,03,99,0,3," + str('{0:.3f}'.format(actFreq1)))
            self.__oldActFreq1 = actFreq1

        # NAV1 Stand by  at LSK4
        if stbFreq1 != self.__oldStbFreq1:
            if (self.__editCur == "NAV1"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,04,98,0,3," + str('{0:.3f}'.format(stbFreq1)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,Nav1StbFq/Psh SW>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,04,99,1,3," + str('{0:.3f}'.format(stbFreq1)))
            self.__oldStbFreq1 = stbFreq1

        # NAV2 Active at RSK3
        if actFreq2 != self.__oldActFreq2:
            self.mqttpublish(Config.topic_display,
                             "T,33,99,0,3," + str('{0:.3f}'.format(actFreq2)))
            self.__oldActFreq2 = actFreq2

        # NAV2 Stand by at RSK4
        if stbFreq2 != self.__oldStbFreq2:
            if (self.__editCur == "NAV2"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,34,98,0,3," + str('{0:.3f}'.format(stbFreq2)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,Nav2StbFq/Psh SW>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,34,99,1,3," + str('{0:.3f}'.format(stbFreq2)))
            self.__oldStbFreq2 = stbFreq2

        # NAV1 HDG at LSK7
        if HdgNav1 != self.__oldHdgNav1:
            if (self.__editCur == "HDG1"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,07,98,0,3," + str('{0:0>3.0f}'.format(HdgNav1)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,           OBS1Hdg>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,07,99,1,3," + str('{0:0>3.0f}'.format(HdgNav1)))
            self.__oldHdgNav1 = HdgNav1

        # NAV2 HDG at RSK17
        if HdgNav2 != self.__oldHdgNav2:
            if (self.__editCur == "HDG2"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,37,98,0,3," + str('{0:0>3.0f}'.format(HdgNav2)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,           OBS2Hdb>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,37,99,1,3," + str('{0:0>3.0f}'.format(HdgNav2)))
            self.__oldHdgNav2 = HdgNav2

        if (not (event.isEmpty())):

            if (event.getTopic() == "j/npanel/e/s"
                    and event.getPayload() == "1"):
                self.draw()
                logger.debug("Redraw")

            if event.getTopic() == Config.topic_keys:

                if event.getPayload() == str(Const.ENC1DN):  # INC1 DN
                    if (self.__editCur == "NAV1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 - 0.025))])
                    if (self.__editCur == "NAV2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 - 0.025))])
                    if (self.__editCur == "HDG1"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 - 1))])
                    if (self.__editCur == "HDG2"):
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 - 1))])
                    event.clear()

                if event.getPayload() == str(Const.ENC1UP):  # INC1 UP
                    if (self.__editCur == "NAV1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 + 0.025))])
                    if (self.__editCur == "NAV2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 + 0.025))])
                    if (self.__editCur == "HDG1"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 + 1))])
                    if (self.__editCur == "HDG2"):
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 + 1))])
                    event.clear()

                if event.getPayload() == str(Const.BTENC):  # SW
                    if (self.__editCur == "NAV1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(actFreq1))])
                        pyuipc.write([(self.__OFFSETS[0][0],
                                       self.__OFFSETS[0][1],
                                       vhf_float2bcd(stbFreq1))])
                    if (self.__editCur == "NAV2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(actFreq2))])
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1],
                                       vhf_float2bcd(stbFreq2))])
                    event.clear()

                if event.getPayload() == str(Const.ENC2DN):  # INC2 DN
                    if (self.__editCur == "NAV1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 - 1))])
                    if (self.__editCur == "NAV2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 - 1))])
                    if (self.__editCur == "HDG1"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 - 10))])
                    if (self.__editCur == "HDG2"):
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 - 10))])
                    event.clear()

                if event.getPayload() == str(Const.ENC2UP):  # INC2 UP
                    if (self.__editCur == "NAV1"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       vhf_float2bcd(stbFreq1 + 1))])
                    if (self.__editCur == "NAV2"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       vhf_float2bcd(stbFreq2 + 1))])
                    if (self.__editCur == "HDG1"):
                        pyuipc.write([(self.__OFFSETS[4][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 + 10))])
                    if (self.__editCur == "HDG2"):
                        pyuipc.write([(self.__OFFSETS[5][0],
                                       self.__OFFSETS[4][1],
                                       bearing(HdgNav1 + 10))])
                    event.clear()

                if event.getPayload() == str(Const.RSK4):  #NAV2
                    self.__editCur = "NAV2"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.LSK1):  #NAV1
                    self.__editCur = "NAV1"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.LSK7):  #HDG1
                    self.__editCur = "HDG1"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RSK7):  #HDG2
                    self.__editCur = "HDG2"
                    self.draw()
                    event.clear()
Esempio n. 12
0
def switch_one_of_many_bit(offset, bitNr):
    lgt = 1
    dat = pyuipc.prepare_data([(offset, 1)])
    val_ist = pyuipc.read(dat)
    val_sol = chr(toggleBit(ord(val_ist[0]), bitNr))
    pyuipc.write(dat, [val_sol])
Esempio n. 13
0
    def run(self, event):
        global actMode, APStatus

        pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS)
        results = pyuipc.read(pyuipcOffsets)
        com1=results[0]&128
        com2=results[0]&64
        both=results[0]&32
        nav1=results[0]&16
        nav2=results[0]&8
        marker=results[0]&4
        dme=results[0]&2
        adf1=results[0]&1

        # com1 select
        if com1!=self.__oldCom1:
            if (com1==0):
                self.mqttpublish(Config.topic_display, "T,02,97,1,4,CM1")
            else:
                self.mqttpublish(Config.topic_display, "T,02,97,1,5,CM1")
            self.__oldCom1=com1

        # com2 select
        if com2!=self.__oldCom2:
            if (com2==0):
                self.mqttpublish(Config.topic_display, "T,12,97,1,4,CM2")
            else:
                self.mqttpublish(Config.topic_display, "T,12,97,1,5,CM2")
            self.__oldCom2=com2

        # receive both com1 and com1
        if both!=self.__oldBoth:
            if (both==0):
                self.mqttpublish(Config.topic_display, "T,22,97,1,4,BTH")
            else:
                self.mqttpublish(Config.topic_display, "T,22,97,1,5,BTH")
            self.__oldBoth=both

        # nav1
        if nav1!=self.__oldNav1:
            if (nav1==0):
                self.mqttpublish(Config.topic_display, "T,04,97,1,4,NV1")
            else:
                self.mqttpublish(Config.topic_display, "T,04,97,1,5,NV1")
            self.__oldNav1=nav1

        # nav1
        if nav2!=self.__oldNav2:
            if (nav2==0):
                self.mqttpublish(Config.topic_display, "T,14,97,1,4,NV2")
            else:
                self.mqttpublish(Config.topic_display, "T,14,97,1,5,NV2")
            self.__oldNav2=nav2

        # marker
        if marker!=self.__oldMarker:
            if (marker==0):
                self.mqttpublish(Config.topic_display, "T,24,97,1,4,MKR")
            else:
                self.mqttpublish(Config.topic_display, "T,24,97,1,5,MKR")
            self.__oldMarker=marker

        # dme
        if dme!=self.__oldDme:
            if (dme==0):
                self.mqttpublish(Config.topic_display, "T,34,97,1,4,DME")
            else:
                self.mqttpublish(Config.topic_display, "T,34,97,1,5,DME")
            self.__oldDme=dme

        # adf1
        if adf1!=self.__oldAdf1:
            if (adf1==0):
                self.mqttpublish(Config.topic_display, "T,06,97,1,4,ADF")
            else:
                self.mqttpublish(Config.topic_display, "T,06,97,1,5,ADF")
            self.__oldAdf1=adf1

        if (not(event.isEmpty())):

            if (event.getTopic()=="j/npanel/e/s" and event.getPayload()=="1"):
                self.draw();
                logging.debug("Redraw")

            if event.getTopic()==Config.topic_keys:
                if event.getPayload()==str(Const.LSK2): # com1
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^192)])
                    event.clear()

                if event.getPayload()==str(Const.LCK2): # com2
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^192)])
                    event.clear()

                if event.getPayload()==str(Const.RCK2): # both
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^32)])
                    event.clear()

                if event.getPayload()==str(Const.LSK4): # nav1
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^16)])
                    event.clear()

                if event.getPayload()==str(Const.LCK4): # nav2
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^8)])
                    event.clear()

                if event.getPayload()==str(Const.RCK4): # marker
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^4)])
                    event.clear()

                if event.getPayload()==str(Const.RSK4): # dme
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^2)])
                    event.clear()

                if event.getPayload()==str(Const.LSK6): # adf
                    pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^1)])
                    event.clear()
Esempio n. 14
0
def switch_one_of_many_bit(offset, bitNr):
    lgt = 1
    dat = pyuipc.prepare_data([(offset, 1)])
    val_ist = pyuipc.read(dat)
    val_sol = chr(toggleBit(ord(val_ist[0]), bitNr))
    pyuipc.write(dat, [val_sol])
Esempio n. 15
0
 def write(self, offset, value):
     offset_raw = self.offsets[offset]
     pyuipc.write([(offset_raw[0], offset_raw[1], value)])
Esempio n. 16
0
    def run(self, event):
        if (self.__editCur != self.__oldEditCur):
            self.draw()
            self.__oldEditCur = self.__editCur

        pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS)
        results = pyuipc.read(pyuipcOffsets)
        eTrim = results[0]
        aTrim = results[1]
        rTrim = results[2]

        # ELEVATOR at RSK3
        if eTrim != self.__oldETrim:
            if (self.__editCur == "ELEV"):
                self.mqttpublish(Config.topic_display,
                                 "S,33,98,0," + str(round(eTrim / 280)))
            else:
                self.mqttpublish(Config.topic_display,
                                 "S,33,99,1," + str(round(eTrim / 280)))
            self.__oldETrim = eTrim

        # AILERON at RSK5
        if aTrim != self.__oldATrim:
            if (self.__editCur == "AIL"):
                self.mqttpublish(Config.topic_display,
                                 "S,35,98,0," + str(round(aTrim / 280)))
            else:
                self.mqttpublish(Config.topic_display,
                                 "S,35,99,1," + str(round(aTrim / 280)))
            self.__oldATrim = aTrim

        # RUDDER at RSK7
        if rTrim != self.__oldRTrim:
            if (self.__editCur == "RUD"):
                self.mqttpublish(Config.topic_display,
                                 "S,37,98,0," + str(round(rTrim / 280)))
            else:
                self.mqttpublish(Config.topic_display,
                                 "S,37,99,1," + str(round(rTrim / 280)))
            self.__oldRTrim = rTrim

        if (not (event.isEmpty())):

            if (event.getTopic() == "j/npanel/e/s"
                    and event.getPayload() == "1"):
                self.draw()
                logging.debug("Redraw")

            if event.getTopic() == Config.topic_keys:

                if event.getPayload() == str(Const.ENC1DN):  # INC1 DN
                    if (self.__editCur == "ELEV"):
                        pyuipc.write([(self.__OFFSETS[0][0],
                                       self.__OFFSETS[0][1], eTrim - 100)])
                    if (self.__editCur == "AIL"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1], aTrim - 100)])
                    if (self.__editCur == "RUD"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], rTrim - 100)])
                    event.clear()

                if event.getPayload() == str(Const.ENC1UP):  # INC1 UP
                    if (self.__editCur == "ELEV"):
                        pyuipc.write([(self.__OFFSETS[0][0],
                                       self.__OFFSETS[0][1], eTrim + 100)])
                    if (self.__editCur == "AIL"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1], aTrim + 100)])
                    if (self.__editCur == "RUD"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], rTrim + 100)])
                    event.clear()

                if event.getPayload() == str(Const.ENC2DN):  # INC2 DN
                    if (self.__editCur == "ELEV"):
                        pyuipc.write([(self.__OFFSETS[0][0],
                                       self.__OFFSETS[0][1], eTrim - 1000)])
                    if (self.__editCur == "AIL"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1], aTrim - 1000)])
                    if (self.__editCur == "RUD"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], rTrim - 1000)])
                    event.clear()

                if event.getPayload() == str(Const.ENC2UP):  # INC2 UP
                    if (self.__editCur == "ELEV"):
                        pyuipc.write([(self.__OFFSETS[0][0],
                                       self.__OFFSETS[0][1], eTrim + 1000)])
                    if (self.__editCur == "AIL"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1], aTrim + 1000)])
                    if (self.__editCur == "RUD"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], rTrim + 1000)])
                    event.clear()

                if event.getPayload() == str(Const.RSK3):  #ELEV
                    self.__editCur = "ELEV"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RSK5):  #AIL
                    self.__editCur = "AIL"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RSK7):  #RUDDER
                    self.__editCur = "RUD"
                    self.draw()
                    event.clear()
Esempio n. 17
0
    def run(self, event):
        if (self.__editCur != self.__oldEditCur):
            self.draw()
            self.__oldEditCur = self.__editCur

        pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS)
        results = pyuipc.read(pyuipcOffsets)
        altitude = results[0] / 19975  # in feet
        heading = results[1] / 182  # in deg
        vertSpeed = results[2]  # in feet/min
        Course = results[3]  # in deg
        IAS = results[4]  # in kts
        lockALT = results[5]
        lockIAS = results[6]
        lockHDG = results[7]
        lockAT = results[8]
        lockNAV = results[9]
        lockBC = results[10]
        lockAPP = results[11]
        lockATT = results[12]
        lockYD = results[13]

        # ALT at LSK3
        if altitude != self.__oldAltitude:
            if (self.__editCur == "ALT"):
                self.mqttpublish(
                    Config.topic_display, "T,03,98,0,2," +
                    str('{0:0>5.0f}'.format(altitude // 100 * 100)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1, Set ALT (x1000 ox100>")
            else:
                self.mqttpublish(
                    Config.topic_display, "T,03,99,1,2," +
                    str('{0:0>5.0f}'.format(altitude // 100 * 100)))
            self.__oldAltitude = altitude

        # IAS at LCK3
        if IAS != self.__oldIAS:
            if (self.__editCur == "IAS"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,13,98,0,3," + str('{0:0>3.0f}'.format(IAS)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1, Set IAS (x10 ox1>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,13,99,1,3," + str('{0:0>3.0f}'.format(IAS)))
            self.__oldIAS = IAS

        # HDG at RSK3
        if heading != self.__oldHeading:
            if (self.__editCur == "HDG"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,23,98,0,3," + str('{0:0>3.0f}'.format(heading)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1, Set HDG (x10 ox1>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,23,99,1,3," + str('{0:0>3.0f}'.format(heading)))
            self.__oldHeading = heading

        # VERTICAL SPEED at LSK6
        if vertSpeed != self.__oldVertSpeed:
            if (self.__editCur == "VERTSPEED"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,06,98,0,2," + str('{0:05.0f}'.format(vertSpeed)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1,Set Vspd (x1000 ox100>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,06,99,1,2," + str('{0:05.0f}'.format(vertSpeed)))
            self.__oldVertSpeed = vertSpeed

        # Course at RSK6
        if Course != self.__oldCourse:
            if (self.__editCur == "COURSE"):
                self.mqttpublish(
                    Config.topic_display,
                    "T,33,98,0,3," + str('{0:0>3.0f}'.format(Course)))
                self.mqttpublish(Config.topic_display,
                                 "T,38,94,0,1, Set CRS  (x10 ox1>")
            else:
                self.mqttpublish(
                    Config.topic_display,
                    "T,33,99,1,3," + str('{0:0>3.0f}'.format(Course)))
            self.__oldCourse = Course

        # LockALT
        if lockALT != self.__oldLockALT:
            if (lockALT == 0):
                self.mqttpublish(Config.topic_display, "T,04,97,1,4,ALT")
            else:
                self.mqttpublish(Config.topic_display, "T,04,97,1,5,ALT")
            self.__oldLockALT = lockALT

        # LockIAS
        if lockIAS != self.__oldLockIAS:
            if (lockIAS == 0):
                self.mqttpublish(Config.topic_display, "T,14,97,1,4,IAS")
            else:
                self.mqttpublish(Config.topic_display, "T,14,97,1,5,IAS")
            self.__oldLockIAS = lockIAS

        # LockAT
        if lockAT != self.__oldLockAT:
            if (lockAT == 0):
                self.mqttpublish(Config.topic_display, "T,15,97,1,4,A/T")
            else:
                self.mqttpublish(Config.topic_display, "T,15,97,1,5,A/T")
            self.__oldLockAT = lockAT

        # LockHDG
        if lockHDG != self.__oldLockHDG:
            if (lockHDG == 0):
                self.mqttpublish(Config.topic_display, "T,24,97,1,4,HDG")
            else:
                self.mqttpublish(Config.topic_display, "T,24,97,1,5,HDG")
            self.__oldLockHDG = lockHDG

        # LockNAV
        if lockNAV != self.__oldLockNAV:
            if (lockNAV == 0):
                self.mqttpublish(Config.topic_display, "T,34,97,1,4,NAV")
            else:
                self.mqttpublish(Config.topic_display, "T,34,97,1,5,NAV")
            self.__oldLockNAV = lockNAV

        # LockBC
        if lockBC != self.__oldLockBC:
            if (lockBC == 0):
                self.mqttpublish(Config.topic_display, "T,35,97,1,4,BC")
            else:
                self.mqttpublish(Config.topic_display, "T,35,97,1,5,BC")
            self.__oldLockBC = lockBC

        # LockAPP
        if lockAPP != self.__oldLockAPP:
            if (lockAPP == 0):
                self.mqttpublish(Config.topic_display, "T,36,97,1,4,APP")
            else:
                self.mqttpublish(Config.topic_display, "T,36,97,1,5,APP")
            self.__oldLockAPP = lockAPP

        # LockATT
        if lockATT != self.__oldLockATT:
            if (lockATT == 0):
                self.mqttpublish(Config.topic_display, "T,17,97,1,4,ATT")
            else:
                self.mqttpublish(Config.topic_display, "T,17,97,1,5,ATT")
            self.__oldLockATT = lockATT

        # LockYD
        if lockYD != self.__oldLockYD:
            if (lockYD == 0):
                self.mqttpublish(Config.topic_display, "T,27,97,1,4,Y/D")
            else:
                self.mqttpublish(Config.topic_display, "T,27,97,1,5,Y/D")
            self.__oldLockYD = lockYD

        if (not (event.isEmpty())):

            if (event.getTopic() == "j/npanel/e/s"
                    and event.getPayload() == "1"):
                self.draw()
                logging.debug("Redraw")

            if event.getTopic() == Config.topic_keys:

                if event.getPayload() == str(Const.ENC1DN):  # INC1 DN
                    if (self.__editCur == "ALT"):
                        pyuipc.write([
                            (self.__OFFSETS[0][0], self.__OFFSETS[0][1],
                             (altitude - 99) * 19975)
                        ])
                    if (self.__editCur == "HDG"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       bearing(heading - 1) * 182)])
                    if (self.__editCur == "VERTSPEED"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], vertSpeed - 100)])
                    if (self.__editCur == "COURSE"):
                        pyuipc.write([
                            (self.__OFFSETS[3][0], self.__OFFSETS[3][1],
                             bearing(Course - 1))
                        ])
                    event.clear()

                if event.getPayload() == str(Const.ENC1UP):  # INC1 UP
                    if (self.__editCur == "ALT"):
                        pyuipc.write([
                            (self.__OFFSETS[0][0], self.__OFFSETS[0][1],
                             (altitude + 101) * 19975)
                        ])
                    if (self.__editCur == "HDG"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       bearing(heading + 1) * 182)])
                    if (self.__editCur == "VERTSPEED"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], vertSpeed + 100)])
                    if (self.__editCur == "COURSE"):
                        pyuipc.write([
                            (self.__OFFSETS[3][0], self.__OFFSETS[3][1],
                             bearing(Course + 1))
                        ])
                    event.clear()

                if event.getPayload() == str(Const.ENC2DN):  # INC2 DN
                    if (self.__editCur == "ALT"):
                        pyuipc.write([
                            (self.__OFFSETS[0][0], self.__OFFSETS[0][1],
                             (altitude - 999) * 19975)
                        ])
                    if (self.__editCur == "HDG"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       bearing(heading - 10) * 182)])
                    if (self.__editCur == "VERTSPEED"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], vertSpeed - 100)])
                    if (self.__editCur == "COURSE"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       bearing(Course - 10))])
                    event.clear()

                if event.getPayload() == str(Const.ENC2UP):  # INC2 UP
                    if (self.__editCur == "ALT"):
                        pyuipc.write([
                            (self.__OFFSETS[0][0], self.__OFFSETS[0][1],
                             (altitude + 1001) * 19975)
                        ])
                    if (self.__editCur == "HDG"):
                        pyuipc.write([(self.__OFFSETS[1][0],
                                       self.__OFFSETS[1][1],
                                       bearing(heading + 10) * 182)])
                    if (self.__editCur == "VERTSPEED"):
                        pyuipc.write([(self.__OFFSETS[2][0],
                                       self.__OFFSETS[2][1], vertSpeed + 100)])
                    if (self.__editCur == "COURSE"):
                        pyuipc.write([(self.__OFFSETS[3][0],
                                       self.__OFFSETS[3][1],
                                       bearing(Course + 10))])
                    event.clear()

                if event.getPayload() == str(Const.LSK3):  #ALT
                    self.__editCur = "ALT"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.LSK4):  # LockAlt
                    lockALT = lockALT ^ 1
                    pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[5][1],
                                   lockALT)])
                    event.clear()

                if event.getPayload() == str(Const.LCK3):  #IAS
                    self.__editCur = "IAS"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.LCK4):  # LockIAS
                    lockIAS = lockIAS ^ 1
                    pyuipc.write([(self.__OFFSETS[6][0], self.__OFFSETS[6][1],
                                   lockIAS)])
                    event.clear()

                if event.getPayload() == str(Const.LCK5):  # LockAT
                    lockAT = lockAT ^ 1
                    pyuipc.write([(self.__OFFSETS[8][0], self.__OFFSETS[8][1],
                                   lockAT)])
                    event.clear()

                if event.getPayload() == str(Const.RCK3):  #HDG
                    self.__editCur = "HDG"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RCK4):  # LockHDG
                    lockHDG = lockHDG ^ 1
                    pyuipc.write([(self.__OFFSETS[7][0], self.__OFFSETS[7][1],
                                   lockHDG)])
                    event.clear()

                if event.getPayload() == str(Const.LSK6):  #VERTSPEED
                    self.__editCur = "VERTSPEED"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RSK3):  #COURSE
                    self.__editCur = "COURSE"
                    self.draw()
                    event.clear()

                if event.getPayload() == str(Const.RSK4):  # LockNAV
                    lockNAV = lockNAV ^ 1
                    pyuipc.write([(self.__OFFSETS[9][0], self.__OFFSETS[9][1],
                                   lockNAV)])
                    event.clear()

                if event.getPayload() == str(Const.RSK5):  # LockBC
                    lockBC = lockBC ^ 1
                    pyuipc.write([(self.__OFFSETS[10][0],
                                   self.__OFFSETS[10][1], lockBC)])
                    event.clear()

                if event.getPayload() == str(Const.RSK6):  # LockAPP
                    lockAPP = lockAPP ^ 1
                    pyuipc.write([(self.__OFFSETS[11][0],
                                   self.__OFFSETS[11][1], lockAPP)])
                    #pyuipc.write([(0x800,'u',lockAPP)]) #Specific to APP offset, must write at two offsets
                    event.clear()

                if event.getPayload() == str(Const.LCK7):  # LockATT
                    lockATT = lockATT ^ 1
                    pyuipc.write([(self.__OFFSETS[12][0],
                                   self.__OFFSETS[12][1], lockATT)])
                    event.clear()

                if event.getPayload() == str(Const.RCK7):  # LockYD
                    lockYD = lockYD ^ 1
                    pyuipc.write([(self.__OFFSETS[13][0],
                                   self.__OFFSETS[13][1], lockYD)])
                    event.clear()
Esempio n. 18
0
print str(chr(batteryState[0]+48))

#arduinoSerial.write(str(0))
arduinoSerial.write(str(batteryState[0]))
#arduinoSerial.write(str(chr(batteryState[0]+48)))
print arduinoSerial.readline()

#batteryToSet = pyuipc.prepare_data([(0x281C, "d", 1),], False)
#batteryToSet = pyuipc.prepare_data([(0x281c, "d")], False)
#pyuipc.write(batteryToSet, [1])
if batteryState[0] == 1:
    newState = 0
else:
    newState = 1

pyuipc.write([(0x028c, "h", newState)])

batteryState = pyuipc.read(batteryToRead)
print batteryState

while True:
    batteryState = pyuipc.read(batteryToRead)
    if batteryState[0] == 1:
        newState = 0
    else:
        newState = 1
    pyuipc.write([(0x028c, "h", newState)])
    batteryState = pyuipc.read(batteryToRead)
    arduinoSerial.write(str(batteryState[0]))
    sleep(1)
    print arduinoSerial.readline()
Esempio n. 19
0
def switch_one_bit(offset):
    lgt = 1
    dat = pyuipc.prepare_data([(offset, lgt)])
    val_ist = pyuipc.read(dat)
    val_sol = chr(not(ord(val_ist[0])))
    pyuipc.write(dat, [val_sol])
Esempio n. 20
0
 * - b: 1 byte unsigned char -> int
 * - c: 1 byte signed char -> int
 * - h: 2 byte signed short -> int
 * - H: 2 byte unsigned short -> int
 * - d: 4 byte signed integer -> int
 * - u: 4 byte unsigned integer -> long
 * - l: 8 byte signed long long -> long
 * - L: 8 byte unsigned long long -> long
 * - f: 8 byte double -> double
 */
 """
offsets = {
    "TIME_HOUR": [0x023B, "b"],
    "TIME_MINUTE": [0x023C, "b"]
}

offsets_to_read = prepare_offsets(offsets)

print("Script will check time every 10 seconds. After first sync you can close this window.")
while True:
    curr_offsets = read_offsets(offsets_to_read)
    now = datetime.utcnow()
    print("Current Time: {}:{}z Simulator Time: {}:{}z".format(now.hour, now.minute, curr_offsets["TIME_HOUR"], curr_offsets["TIME_MINUTE"]))

    if curr_offsets["TIME_HOUR"] != now.hour or curr_offsets["TIME_MINUTE"] > now.minute + 1 or curr_offsets["TIME_MINUTE"] < now.minute - 1:
        print("DOING A ZULU TIME SYNC.")
        pyuipc.write([(offsets["TIME_HOUR"][0], offsets["TIME_HOUR"][1], now.hour)])
        pyuipc.write([(offsets["TIME_MINUTE"][0], offsets["TIME_MINUTE"][1], now.minute)])

    # pyuipc.write([(offsets["RADIOSWAP"][0], offsets["RADIOSWAP"][1],8)])
    time.sleep(10)