mirror of
https://github.com/romanz/amodem.git
synced 2026-03-30 23:57:54 +08:00
recv: split sampler update
This commit is contained in:
@@ -26,7 +26,7 @@ class Receiver(object):
|
|||||||
self.omegas = 2 * np.pi * self.frequencies / config.Fs
|
self.omegas = 2 * np.pi * self.frequencies / config.Fs
|
||||||
self.Nsym = config.Nsym
|
self.Nsym = config.Nsym
|
||||||
self.Tsym = config.Tsym
|
self.Tsym = config.Tsym
|
||||||
self.iters_per_report = config.baud # report once per second
|
self.iters_per_update = config.baud # update sampler once per second
|
||||||
self.modem_bitrate = config.modem_bps
|
self.modem_bitrate = config.modem_bps
|
||||||
self.equalizer = equalizer.Equalizer(config)
|
self.equalizer = equalizer.Equalizer(config)
|
||||||
self.carrier_index = config.carrier_index
|
self.carrier_index = config.carrier_index
|
||||||
@@ -138,20 +138,23 @@ class Receiver(object):
|
|||||||
self.stats['rx_bits'] = self.stats['rx_bits'] + len(bits)
|
self.stats['rx_bits'] = self.stats['rx_bits'] + len(bits)
|
||||||
yield bits
|
yield bits
|
||||||
|
|
||||||
if i % self.iters_per_report == 0:
|
if i % self.iters_per_update == 0:
|
||||||
err = np.array([e for v in errors.values() for e in v])
|
self._update_sampler(i, errors, sampler)
|
||||||
err = np.mean(np.angle(err))/(2*np.pi) if len(err) else 0
|
|
||||||
errors.clear()
|
|
||||||
|
|
||||||
duration = time.time() - self.stats['rx_start']
|
def _update_sampler(self, iter_index, errors, sampler):
|
||||||
sampler.freq -= 0.01 * err * self.Tsym
|
err = np.array([e for v in errors.values() for e in v])
|
||||||
sampler.offset -= err
|
err = np.mean(np.angle(err))/(2*np.pi) if len(err) else 0
|
||||||
log.debug(
|
errors.clear()
|
||||||
'Got %8.1f kB, realtime: %6.2f%%, drift: %+5.2f ppm',
|
|
||||||
self.stats['rx_bits'] / 8e3,
|
duration = time.time() - self.stats['rx_start']
|
||||||
duration * 100.0 / (i*self.Tsym),
|
sampler.freq -= 0.01 * err * self.Tsym
|
||||||
(1.0 - sampler.freq) * 1e6
|
sampler.offset -= err
|
||||||
)
|
log.debug(
|
||||||
|
'Got %8.1f kB, realtime: %6.2f%%, drift: %+5.2f ppm',
|
||||||
|
self.stats['rx_bits'] / 8e3,
|
||||||
|
duration * 100.0 / (iter_index * self.Tsym),
|
||||||
|
(1.0 - sampler.freq) * 1e6
|
||||||
|
)
|
||||||
|
|
||||||
def start(self, signal, gain=1.0):
|
def start(self, signal, gain=1.0):
|
||||||
sampler = sampling.Sampler(signal, sampling.Interpolator())
|
sampler = sampling.Sampler(signal, sampling.Interpolator())
|
||||||
|
|||||||
Reference in New Issue
Block a user