- if packet.type == sr.PacketType.ANALOG:
- self.measured.emit(device, packet.payload)
+ if not sr:
+ # In rare cases it can happen that the callback fires while
+ # the interpreter is shutting down. Then the sigrok module
+ # is already set to 'None'.
+ return
+
+ if packet.type != sr.PacketType.ANALOG:
+ return
+
+ if not len(packet.payload.channels):
+ return
+
+ # TODO: find a device with multiple channels in one packet
+ channel = packet.payload.channels[0]
+
+ # the most recent value
+ value = packet.payload.data[0][-1]