diff --git a/data/inno.iss b/data/inno.iss index d3263ab6d9..e19c203b3b 100644 --- a/data/inno.iss +++ b/data/inno.iss @@ -12,7 +12,7 @@ AppPublisher=Johannes Pohl AppPublisherURL=https://github.com/jopohl/urh AppSupportURL=https://github.com/jopohl/urh AppUpdatesURL=https://github.com/jopohl/urh -DefaultDirName={pf}\Universal Radio Hacker +DefaultDirName={commonpf}\Universal Radio Hacker DisableProgramGroupPage=yes LicenseFile=..\LICENSE OutputDir=..\dist diff --git a/src/urh/dev/native/ExtensionHelper.py b/src/urh/dev/native/ExtensionHelper.py index 0cd59b6c0e..d82248dd7c 100644 --- a/src/urh/dev/native/ExtensionHelper.py +++ b/src/urh/dev/native/ExtensionHelper.py @@ -57,11 +57,13 @@ def compiler_has_function(compiler, function_name, libraries, library_dirs, incl try: try: file_name = os.path.join(tmp_dir, '{}.c'.format(function_name)) - f = open(file_name, 'w') - f.write('int main(void) {\n') - f.write(' %s();\n' % function_name) - f.write('}\n') - f.close() + with open(file_name, 'w') as f: + # declare function in order to prevent Clang 12 error (https://github.com/jopohl/urh/issues/811) + f.write('void %s();\n' % function_name) + f.write('int main(void) {\n') + f.write(' %s();\n' % function_name) + f.write('}\n') + # Redirect stderr to /dev/null to hide any error messages from the compiler. devnull = open(os.devnull, 'w') old_stderr = os.dup(sys.stderr.fileno()) diff --git a/src/urh/signalprocessing/ContinuousModulator.py b/src/urh/signalprocessing/ContinuousModulator.py index 339949f2ea..e9947f8e31 100644 --- a/src/urh/signalprocessing/ContinuousModulator.py +++ b/src/urh/signalprocessing/ContinuousModulator.py @@ -25,13 +25,12 @@ def __init__(self, messages, modulators, num_repeats=-1): self.modulators = modulators self.num_repeats = num_repeats # -1 or 0 = infinite - self.ring_buffer = RingBuffer(int(settings.CONTINUOUS_BUFFER_SIZE_MB * 10 ** 6) // 8, dtype=Modulator.get_dtype()) + self.ring_buffer = RingBuffer(int(settings.CONTINUOUS_BUFFER_SIZE_MB * 1e6) // 8, dtype=Modulator.get_dtype()) self.current_message_index = Value("L", 0) self.abort = Value("i", 0) - self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, )) - self.process.daemon = True + self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, ), daemon=True) @property def is_running(self): @@ -40,34 +39,34 @@ def is_running(self): def start(self): self.abort.value = 0 try: - self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, )) - self.process.daemon = True + self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, ), daemon=True) self.process.start() except RuntimeError as e: - logger.debug(str(e)) + logger.exception(e) def stop(self, clear_buffer=True): self.abort.value = 1 - if clear_buffer: - self.ring_buffer.clear() - if not self.process.is_alive(): - return - - try: - self.process.join(0.1) - except RuntimeError as e: - logger.debug(str(e)) if self.process.is_alive(): - self.process.terminate() - self.process.join() + try: + self.process.join(1.5) + except RuntimeError as e: + logger.exception(e) + self.process.terminate() + + if clear_buffer: + self.ring_buffer.clear() logger.debug("Stopped continuous modulation") def modulate_continuously(self, num_repeats): rng = iter(int, 1) if num_repeats <= 0 else range(0, num_repeats) # <= 0 = forever for _ in rng: + if self.abort.value: + return + start = self.current_message_index.value + for i in range(start, len(self.messages)): if self.abort.value: return @@ -82,5 +81,7 @@ def modulate_continuously(self, num_repeats): # Wait till there is space in buffer time.sleep(self.WAIT_TIMEOUT) + self.ring_buffer.push(modulated) + self.current_message_index.value = 0 diff --git a/src/urh/simulator/Simulator.py b/src/urh/simulator/Simulator.py index 75638cb4fe..d9467a75a6 100644 --- a/src/urh/simulator/Simulator.py +++ b/src/urh/simulator/Simulator.py @@ -353,6 +353,7 @@ def process_message(self): received_msg.decoder = new_message.decoder received_msg.message_type = new_message.message_type + self.log_message("Message {}: Check whether received data matches".format(msg.index())) check_result, error_msg = self.check_message(received_msg, new_message, retry=retry, msg_index=msg.index()) diff --git a/tests/test_continuous_modulator.py b/tests/test_continuous_modulator.py index 5b7eb86de3..053c4f2928 100644 --- a/tests/test_continuous_modulator.py +++ b/tests/test_continuous_modulator.py @@ -20,7 +20,7 @@ def test_modulate_continuously(self): self.assertTrue(continuous_modulator.ring_buffer.is_empty) continuous_modulator.start() self.assertTrue(continuous_modulator.process.is_alive()) - time.sleep(1.5) + time.sleep(2) self.assertFalse(continuous_modulator.ring_buffer.is_empty) continuous_modulator.stop() self.assertFalse(continuous_modulator.process.is_alive())