Skip to content

Commit

Permalink
Don't reset the buffer if an invalid pulse length occurs
Browse files Browse the repository at this point in the history
This allows compatibility with some aftermarket transmitters.
  • Loading branch information
argilo committed Jan 16, 2024
1 parent 602269b commit 17ca0a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 9 additions & 10 deletions secplus_rx.grc
Original file line number Diff line number Diff line change
Expand Up @@ -743,16 +743,15 @@ blocks:
\ self.process_buffer(current_sample)\n self.buffer\
\ = []\n self.last_sample = sample\n return len(input_items[0])\n\
\n def process_edge(self, rising, samples):\n if samples < 0.125e-3\
\ * self.samp_rate:\n self.buffer = []\n elif samples < 0.375e-3\
\ * self.samp_rate:\n self.buffer.append(0 if rising else 1)\n \
\ elif samples < 0.625e-3 * self.samp_rate:\n self.buffer.append(0\
\ if rising else 1)\n self.buffer.append(0 if rising else 1)\n \
\ else:\n self.buffer = []\n\n def process_buffer(self, current_sample):\n\
\ manchester = \"\".join(str(b) for b in self.buffer)\n start\
\ = manchester.find(\"1010101001010101\")\n if start == -1:\n \
\ return\n\n if manchester[start+20:start+24] == \"1010\":\n \
\ packet_length = 40\n elif manchester[start+20:start+24] == \"\
1001\":\n packet_length = 64\n else:\n return\n\
\ * self.samp_rate:\n pass\n elif samples < 0.375e-3 * self.samp_rate:\n\
\ self.buffer.append(0 if rising else 1)\n elif samples <\
\ 0.625e-3 * self.samp_rate:\n self.buffer.append(0 if rising else\
\ 1)\n self.buffer.append(0 if rising else 1)\n\n def process_buffer(self,\
\ current_sample):\n manchester = \"\".join(str(b) for b in self.buffer)\n\
\ start = manchester.find(\"1010101001010101\")\n if start ==\
\ -1:\n return\n\n if manchester[start+20:start+24] == \"\
1010\":\n packet_length = 40\n elif manchester[start+20:start+24]\
\ == \"1001\":\n packet_length = 64\n else:\n return\n\
\n manchester = manchester[start+16:start+20+(packet_length*2)]\n \
\ baseband = []\n for i in range(0, len(manchester), 2):\n \
\ if manchester[i:i+2] == \"01\":\n baseband.append(1)\n\
Expand Down
4 changes: 1 addition & 3 deletions secplus_rx_secplus_v2_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ def work(self, input_items, output_items):

def process_edge(self, rising, samples):
if samples < 0.125e-3 * self.samp_rate:
self.buffer = []
pass
elif samples < 0.375e-3 * self.samp_rate:
self.buffer.append(0 if rising else 1)
elif samples < 0.625e-3 * self.samp_rate:
self.buffer.append(0 if rising else 1)
self.buffer.append(0 if rising else 1)
else:
self.buffer = []

def process_buffer(self, current_sample):
manchester = "".join(str(b) for b in self.buffer)
Expand Down

0 comments on commit 17ca0a3

Please sign in to comment.