def idle_task(self):
        '''called on idle'''
        if self.sock is None:
            return
        try:
            pkt = self.sock.recv(10240)
        except Exception:
            return
        try:
            if pkt.startswith(b'PICKLED:'):
                pkt = pkt[8:]
                # pickled packet
                try:
                    amsg = [pickle.loads(pkt)]
                except pickle.UnpicklingError:
                    amsg = asterix.parse(pkt)
            else:
                amsg = asterix.parse(pkt)
            self.pkt_count += 1
            self.console.set_status('ASTX', 'ASTX %u/%u' % (self.pkt_count, self.adsb_packets_sent), row=6)
        except Exception:
            print("bad packet")
            return
        try:
            logpkt = b'AST:' + struct.pack('<dI', time.time(), len(pkt)) + pkt
            self.logfile.write(logpkt)
        except Exception:
            pass
        
        for m in amsg:
            if self.asterix_settings.debug > 1:
                print(m)
            lat = m['I105']['Lat']['val']
            lon = m['I105']['Lon']['val']
            alt_f = m['I130']['Alt']['val']
            climb_rate_fps = m['I220']['RoC']['val']
            sac = m['I010']['SAC']['val']
            sic = m['I010']['SIC']['val']
            trkn = m['I040']['TrkN']['val']
            # fake ICAO_address
            icao_address = trkn & 0xFFFF

            # use squawk for time in 0.1 second increments. This allows for old msgs to be discarded on vehicle
            # when using more than one link to vehicle
            squawk = (int(self.mpstate.attitude_time_s * 10) & 0xFFFF)

            alt_m = alt_f * 0.3048

            # asterix is WGS84, ArduPilot uses AMSL, which is EGM96
            alt_m += self.asterix_settings.wgs84_to_AMSL

            # consider filtering this packet out; if it's not close to
            # either home or the vehicle position don't send it
            adsb_pkt = self.master.mav.adsb_vehicle_encode(icao_address,
                                                           int(lat*1e7),
                                                           int(lon*1e7),
                                                           mavutil.mavlink.ADSB_ALTITUDE_TYPE_GEOMETRIC,
                                                           int(alt_m*1000), # mm
                                                           0, # heading
                                                           0, # hor vel
                                                           int(climb_rate_fps * 0.3048 * 100), # cm/s
                                                           "%08x" % icao_address,
                                                           100 + (trkn // 10000),
                                                           1.0,
                                                           (mavutil.mavlink.ADSB_FLAGS_VALID_COORDS |
                                                            mavutil.mavlink.ADSB_FLAGS_VALID_ALTITUDE |
                                                            mavutil.mavlink.ADSB_FLAGS_VALID_VELOCITY |
                                                            mavutil.mavlink.ADSB_FLAGS_VALID_HEADING),
                                                           squawk)
            if icao_address in self.tracks:
                self.tracks[icao_address].update(adsb_pkt, self.get_time())
            else:
                self.tracks[icao_address] = Track(adsb_pkt)
            if self.asterix_settings.debug > 0:
                print(adsb_pkt)
            # send on all links
            if self.should_send_adsb_pkt(adsb_pkt):
                self.adsb_packets_sent += 1
                for i in range(len(self.mpstate.mav_master)):
                    conn = self.mpstate.mav_master[i]
                    #if adsb_pkt.hor_velocity < 1:
                    #    print(adsb_pkt)
                    conn.mav.send(adsb_pkt)
            else:
                self.adsb_packets_not_sent += 1

            adsb_mod = self.module('adsb')
            if adsb_mod:
                # the adsb module is loaded, display on the map
                adsb_mod.mavlink_packet(adsb_pkt)

            try:
                for sysid in self.mpstate.sysid_outputs:
                    # fwd to sysid clients
                    adsb_pkt.pack(self.mpstate.sysid_outputs[sysid].mav)
                    self.mpstate.sysid_outputs[sysid].write(adsb_pkt.get_msgbuf())
            except Exception:
                pass
                
        now = time.time()
        delta = now - self.adsb_byterate_update_timestamp
        if delta > 5:
            self.adsb_byterate_update_timestamp = now
            bytes_per_adsb_packet = 38 # FIXME: find constant
            self.adsb_byterate = (self.adsb_packets_sent - self.adsb_last_packets_sent)/delta * bytes_per_adsb_packet
            self.adsb_last_packets_sent = self.adsb_packets_sent