mirror of
https://github.com/jopohl/urh.git
synced 2026-03-04 07:24:00 +01:00
* add argument parser for CLI * add pause to cli * parse messages to send * add send function * use while loop instead of hard sleep * use logger for error msg * use tabulator for progress bar * prepare rx mode * use Thread for Protocol Sniffer instead of qt signals * adapt tests * fix thread can only be started once error * enable receiving from command line * support send from file * save gain correctly * enable rx into file * remove unused signal * enable raw rx and file mode * add support for device identifier * add support for default pause * enable abort sending witt ctrl c * support encodings * make logging multiprocessing aware and add autobuild extensions to cli * move place * fix sniffer when receiving multiple messages at once * add test for modulator cli parsing and fix some bugs * extend modulator test and fix another bug * add unittests and reorder urh_cli structure * add tests * adapt CI to CLI tests * force osx * fix osx * adapt close dialog method * remove close dialog method * test read messages to send * centralize read messages method * increase timeout for ci * support loading of project files to load cli values * add sleep for ci * add cli to deployment * replace static calls with ProjectManager Class * use time sleep instead of qwait * disable gc collect call * disable gc collect for python 3.4 only * gc collect only for osx * simplify cleanup * simplify cleanup * advanced cleanup only for windows * cleanup also for osx * gc collect for osx * add unittests * consider frozen app path * init multiprocessing first * enable logging on cli for windows * use log file handler for log * add missing import
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import unittest
|
|
|
|
from urh.cli import urh_cli
|
|
from urh.signalprocessing.Message import Message
|
|
from urh.signalprocessing.Modulator import Modulator
|
|
from urh.signalprocessing.ProtocolAnalyzer import ProtocolAnalyzer
|
|
from urh.signalprocessing.Signal import Signal
|
|
|
|
|
|
class TestCLILogic(unittest.TestCase):
|
|
def test_cli_modulate_messages(self):
|
|
modulator = Modulator("test")
|
|
modulator.sample_rate = 2e3
|
|
modulator.samples_per_bit = 100
|
|
modulator.modulation_type_str = "ASK"
|
|
modulator.param_for_zero = 0
|
|
modulator.param_for_one = 100
|
|
|
|
bits = "1010111100001"
|
|
|
|
self.assertIsNone(urh_cli.modulate_messages([], modulator))
|
|
|
|
message = Message.from_plain_bits_str(bits, pause=1000)
|
|
|
|
modulated = urh_cli.modulate_messages([message], modulator)
|
|
|
|
# Demodulate for testing
|
|
s = Signal("", "", modulation="ASK", sample_rate=2e6)
|
|
s.bit_len = 100
|
|
s.noise_threshold = 0
|
|
s._fulldata = modulated
|
|
|
|
pa = ProtocolAnalyzer(s)
|
|
pa.get_protocol_from_signal()
|
|
self.assertEqual(len(pa.messages), 1)
|
|
self.assertEqual(pa.messages[0].plain_bits_str, bits) |