Skip to content

Instantly share code, notes, and snippets.

@7m4mon
Created October 1, 2019 14:55
Show Gist options
  • Save 7m4mon/719972b21c9aa9328204010cd82bc3a2 to your computer and use it in GitHub Desktop.
Save 7m4mon/719972b21c9aa9328204010cd82bc3a2 to your computer and use it in GitHub Desktop.
"""=================================================="""
""" Super Hikari Mascon Decoder """
""" 2019.Sep.30 7M4MON """
"""=================================================="""
import numpy
import math
from gnuradio import gr
class masdec_ii(gr.sync_block):
def __init__(self, thres_duration):
gr.sync_block.__init__(self,
name="masdec_ii",
in_sig=[numpy.int32],
out_sig=[numpy.int32])
self.on_counter = 0
self.last_count = 0
self.last_bit = 0
self.thres_duration = thres_duration
def work(self, input_items, output_items):
in0 = input_items[0]
out = output_items[0]
for det_bit in in0:
if det_bit == 1 :
self.on_counter += 1
else :
if self.last_bit == 1 : # edge 1 -> 0
self.last_count = self.on_counter
self.on_counter = 0 # clear counter
self.last_bit = det_bit
out[:] = math.floor(self.last_count / self.thres_duration)
return len(output_items[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment