Пример #1
0
	def getOrbPosFromNit(self, currentProcess):
		if self.DVB_type.value != "DVB-S" or not dvbreader_available or self.frontend is None or self.demux < 0:
			return

		adapter = 0
		demuxer_device = "/dev/dvb/adapter%d/demux%d" % (adapter, self.demux)

		nit_current_pid = 0x10
		nit_current_table_id = 0x40
		nit_other_table_id = 0x00 # don't read other table
		if nit_other_table_id == 0x00:
			mask = 0xff
		else:
			mask = nit_current_table_id ^ nit_other_table_id ^ 0xff
		nit_current_timeout = 60 # maximum time allowed to read the network information table (seconds)

		nit_current_version_number = -1
		nit_current_sections_read = []
		nit_current_sections_count = 0
		nit_current_content = []
		nit_current_completed = False

		fd = dvbreader.open(demuxer_device, nit_current_pid, nit_current_table_id, mask, self.feid)
		if fd < 0:
			print "[Satfinder][getOrbPosFromNit] Cannot open the demuxer"
			return

		timeout = datetime.datetime.now()
		timeout += datetime.timedelta(0, nit_current_timeout)

		while True:
			if datetime.datetime.now() > timeout:
				print "[Satfinder][getOrbPosFromNit] Timed out reading NIT"
				break

			if self.currentProcess != currentProcess or not self.tunerLock():
				dvbreader.close(fd)
				return

			section = dvbreader.read_nit(fd, nit_current_table_id, nit_other_table_id)
			if section is None:
				time.sleep(0.1)	# no data.. so we wait a bit
				continue

			if section["header"]["table_id"] == nit_current_table_id and not nit_current_completed:
				if section["header"]["version_number"] != nit_current_version_number:
					nit_current_version_number = section["header"]["version_number"]
					nit_current_sections_read = []
					nit_current_sections_count = section["header"]["last_section_number"] + 1
					nit_current_content = []

				if section["header"]["section_number"] not in nit_current_sections_read:
					nit_current_sections_read.append(section["header"]["section_number"])
					nit_current_content += section["content"]

					if len(nit_current_sections_read) == nit_current_sections_count:
						nit_current_completed = True

			if nit_current_completed:
				break

		dvbreader.close(fd)

		if not nit_current_content:
			print "[Satfinder][getOrbPosFromNit] current transponder not found"
			return

		transponders = [t for t in nit_current_content if "descriptor_tag" in t and t["descriptor_tag"] == 0x43 and t["original_network_id"] == self.onid and t["transport_stream_id"] == self.tsid]
		transponders2 = [t for t in nit_current_content if "descriptor_tag" in t and t["descriptor_tag"] == 0x43 and t["transport_stream_id"] == self.tsid]
		if transponders and "orbital_position" in transponders[0]:
			orb_pos = self.getOrbitalPosition(transponders[0]["orbital_position"], transponders[0]["west_east_flag"])
			self["pos"].setText(_("%s") % orb_pos)
			print "[satfinder][getOrbPosFromNit] orb_pos", orb_pos
		elif transponders2 and "orbital_position" in transponders2[0]:
			orb_pos = self.getOrbitalPosition(transponders2[0]["orbital_position"], transponders2[0]["west_east_flag"])
			self["pos"].setText(_("%s?") % orb_pos)
			print "[satfinder][getOrbPosFromNit] orb_pos tentative, tsid match, onid mismatch between NIT and SDT", orb_pos
		else:
			print "[satfinder][getOrbPosFromNit] no orbital position found"
Пример #2
0
    def getOrbPosFromNit(self, currentProcess):
        if not dvbreader_available:
            return

        print "[Satfinder][getOrbPosFromNit] starting"

        if self.demux < 0:
            print "[Satfinder][getOrbPosFromNit] Demux not allocated"
            return

        self.orb_pos = ''
        adapter = 0
        demuxer_device = "/dev/dvb/adapter%d/demux%d" % (adapter, self.demux)

        nit_current_pid = 0x10
        nit_current_table_id = 0x40
        nit_other_table_id = 0x00  # don't read other table
        if nit_other_table_id == 0x00:
            mask = 0xff
        else:
            mask = nit_current_table_id ^ nit_other_table_id ^ 0xff
        nit_current_timeout = 60  # time allowed to get table data

        nit_current_version_number = -1
        nit_current_sections_read = []
        nit_current_sections_count = 0
        nit_current_content = []
        nit_current_completed = False

        fd = dvbreader.open(demuxer_device, nit_current_pid,
                            nit_current_table_id, mask, self.feid)
        if fd < 0:
            print "[Satfinder][getOrbPosFromNit] Cannot open the demuxer"
            return

        timeout = datetime.datetime.now()
        timeout += datetime.timedelta(0, nit_current_timeout)

        while True:
            if datetime.datetime.now() > timeout:
                print "[Satfinder][getOrbPosFromNit] Timed out reading NIT"
                break

            if self.currentProcess != currentProcess:
                print "[satfinder][getOrbPosFromNit] killed: %s, currentProcess: %s" % (
                    currentProcess, self.currentProcess)
                dvbreader.close(fd)
                return

            section = dvbreader.read_nit(fd, nit_current_table_id,
                                         nit_other_table_id)
            if section is None:
                time.sleep(0.1)  # no data.. so we wait a bit
                continue

            if section["header"][
                    "table_id"] == nit_current_table_id and not nit_current_completed:
                if section["header"][
                        "version_number"] != nit_current_version_number:
                    nit_current_version_number = section["header"][
                        "version_number"]
                    nit_current_sections_read = []
                    nit_current_sections_count = section["header"][
                        "last_section_number"] + 1
                    nit_current_content = []

                if section["header"][
                        "section_number"] not in nit_current_sections_read:
                    nit_current_sections_read.append(
                        section["header"]["section_number"])
                    nit_current_content += section["content"]

                    if len(nit_current_sections_read
                           ) == nit_current_sections_count:
                        nit_current_completed = True

            if nit_current_completed:
                break

        dvbreader.close(fd)

        if not nit_current_content:
            print "[Satfinder][getOrbPosFromNit] current transponder not found"
            return

        transponders = [
            t for t in nit_current_content
            if "descriptor_tag" in t and t["descriptor_tag"] == 0x43
            and t["original_network_id"] == self.onid
            and t["transport_stream_id"] == self.tsid
        ]
        if transponders and "orbital_position" in transponders[0]:
            self.orb_pos = self.getOrbitalPosition(
                transponders[0]["orbital_position"],
                transponders[0]["west_east_flag"])
            print "[satfinder][getOrbPosFromNit] self.orb_pos", self.orb_pos
        else:
            print "[satfinder][getOrbPosFromNit] no orbital position found"