Python LT8900 via SPI

Diff
Login

Diff

Differences From Artifact [df06239930]:

To Artifact [640dc549d5]:


540
541
542
543
544
545
546

547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563




564
565
566
567
568
569
570
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575







+

















+
+
+
+








			self.start_listening(channel)

		message = []

		while True:
			radio_status = self.get_register_bits('status')
			self._debug("radio_status={}".format(radio_status))
			if radio_status['packet_flag'] == 0:
				if wait:
					time.sleep(wait_time)
					continue
				else:
					return None

			if radio_status['crc_error'] == 1:
				# Handle invalid packet ?
				self.start_listening(channel)
				continue

			# Data is available, read it from the FIFO register
			# The first result will include the length
			# XXX *IF* length encoding is enabled ?
			fifo_data = self.get_register('fifo')
			message_length = fifo_data >> 8

			if message_length == 0:
				self.start_listening(channel)
				continue

			# Keep track of the total message length to truncate it
			final_message_length = message_length

			message += [fifo_data & 0xff]
			message_length -= 1