kopia lustrzana https://github.com/projecthorus/radiosonde_auto_rx
Fix bit_to_samples for python 3.7
rodzic
1f1e43f8a0
commit
e10dc43bc7
|
@ -1,22 +1,40 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Convert one-byte-per-bit representation (i.e. from fsk_demod) to a pseudo-FM-demod representation.
|
||||
#
|
||||
import sys
|
||||
|
||||
# Check if we are running in Python 2 or 3
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
_sample_rate = int(sys.argv[1])
|
||||
_symbol_rate = int(sys.argv[2])
|
||||
|
||||
_bit_length = _sample_rate // _symbol_rate
|
||||
|
||||
_zero = '\x00'*_bit_length
|
||||
_one = '\xFF'*_bit_length
|
||||
if PY3:
|
||||
_zero = b'\x00'*_bit_length
|
||||
_one = b'\xFF'*_bit_length
|
||||
|
||||
_in = sys.stdin.read
|
||||
_out = sys.stdout.buffer.write
|
||||
|
||||
else:
|
||||
_zero = '\x00'*_bit_length
|
||||
_one = '\xFF'*_bit_length
|
||||
|
||||
_in = sys.stdin.read
|
||||
_out = sys.stdout.write
|
||||
|
||||
while True:
|
||||
_char = sys.stdin.read(1)
|
||||
if _char == '':
|
||||
_char = _in(1)
|
||||
|
||||
if _char == '' or _char == b'':
|
||||
sys.exit(0)
|
||||
|
||||
if _char == '\x00':
|
||||
sys.stdout.write(_zero)
|
||||
_out(_zero)
|
||||
else:
|
||||
sys.stdout.write(_one)
|
||||
_out(_one)
|
||||
|
||||
sys.stdout.flush()
|
||||
|
|
Ładowanie…
Reference in New Issue