Преглед изворни кода

gw: Fix flux->bitcell conversion when a final long flux is missing.
We should generate extra 0s rather than terminating the bitstring.

Keir Fraser пре 4 година
родитељ
комит
8f0a033938
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      scripts/greaseweazle/bitcell.py

+ 4 - 2
scripts/greaseweazle/bitcell.py

@@ -5,7 +5,7 @@
 # This is free and unencumbered software released into the public domain.
 # See the file COPYING for more details, or visit <http://unlicense.org>.
 
-import binascii
+import binascii, itertools
 from bitarray import bitarray
 
 class Bitcell:
@@ -42,7 +42,9 @@ class Bitcell:
         to_index = index_list[0] / freq
         index_list = index_list[1:]
 
-        for x in flux.list:
+        # Make sure there's enough time in the flux list to cover all
+        # revolutions by appending a "large enough" final flux value.
+        for x in itertools.chain(flux.list, [sum(flux.index_list)]):
 
             # Gather enough ticks to generate at least one bitcell.
             ticks += x / freq