Skip to content

Commit 217a814

Browse files
authored
improve sdr check fix #811 (#812)
1 parent 611ef15 commit 217a814

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

data/inno.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AppPublisher=Johannes Pohl
1212
AppPublisherURL=https://github.com/jopohl/urh
1313
AppSupportURL=https://github.com/jopohl/urh
1414
AppUpdatesURL=https://github.com/jopohl/urh
15-
DefaultDirName={pf}\Universal Radio Hacker
15+
DefaultDirName={commonpf}\Universal Radio Hacker
1616
DisableProgramGroupPage=yes
1717
LicenseFile=..\LICENSE
1818
OutputDir=..\dist

src/urh/dev/native/ExtensionHelper.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ def compiler_has_function(compiler, function_name, libraries, library_dirs, incl
5757
try:
5858
try:
5959
file_name = os.path.join(tmp_dir, '{}.c'.format(function_name))
60-
f = open(file_name, 'w')
61-
f.write('int main(void) {\n')
62-
f.write(' %s();\n' % function_name)
63-
f.write('}\n')
64-
f.close()
60+
with open(file_name, 'w') as f:
61+
# declare function in order to prevent Clang 12 error (https://github.com/jopohl/urh/issues/811)
62+
f.write('void %s();\n' % function_name)
63+
f.write('int main(void) {\n')
64+
f.write(' %s();\n' % function_name)
65+
f.write('}\n')
66+
6567
# Redirect stderr to /dev/null to hide any error messages from the compiler.
6668
devnull = open(os.devnull, 'w')
6769
old_stderr = os.dup(sys.stderr.fileno())

src/urh/signalprocessing/ContinuousModulator.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ def __init__(self, messages, modulators, num_repeats=-1):
2525
self.modulators = modulators
2626
self.num_repeats = num_repeats # -1 or 0 = infinite
2727

28-
self.ring_buffer = RingBuffer(int(settings.CONTINUOUS_BUFFER_SIZE_MB * 10 ** 6) // 8, dtype=Modulator.get_dtype())
28+
self.ring_buffer = RingBuffer(int(settings.CONTINUOUS_BUFFER_SIZE_MB * 1e6) // 8, dtype=Modulator.get_dtype())
2929

3030
self.current_message_index = Value("L", 0)
3131

3232
self.abort = Value("i", 0)
33-
self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, ))
34-
self.process.daemon = True
33+
self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, ), daemon=True)
3534

3635
@property
3736
def is_running(self):
@@ -40,34 +39,34 @@ def is_running(self):
4039
def start(self):
4140
self.abort.value = 0
4241
try:
43-
self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, ))
44-
self.process.daemon = True
42+
self.process = Process(target=self.modulate_continuously, args=(self.num_repeats, ), daemon=True)
4543
self.process.start()
4644
except RuntimeError as e:
47-
logger.debug(str(e))
45+
logger.exception(e)
4846

4947
def stop(self, clear_buffer=True):
5048
self.abort.value = 1
51-
if clear_buffer:
52-
self.ring_buffer.clear()
53-
if not self.process.is_alive():
54-
return
55-
56-
try:
57-
self.process.join(0.1)
58-
except RuntimeError as e:
59-
logger.debug(str(e))
6049

6150
if self.process.is_alive():
62-
self.process.terminate()
63-
self.process.join()
51+
try:
52+
self.process.join(1.5)
53+
except RuntimeError as e:
54+
logger.exception(e)
55+
self.process.terminate()
56+
57+
if clear_buffer:
58+
self.ring_buffer.clear()
6459

6560
logger.debug("Stopped continuous modulation")
6661

6762
def modulate_continuously(self, num_repeats):
6863
rng = iter(int, 1) if num_repeats <= 0 else range(0, num_repeats) # <= 0 = forever
6964
for _ in rng:
65+
if self.abort.value:
66+
return
67+
7068
start = self.current_message_index.value
69+
7170
for i in range(start, len(self.messages)):
7271
if self.abort.value:
7372
return
@@ -82,5 +81,7 @@ def modulate_continuously(self, num_repeats):
8281

8382
# Wait till there is space in buffer
8483
time.sleep(self.WAIT_TIMEOUT)
84+
8585
self.ring_buffer.push(modulated)
86+
8687
self.current_message_index.value = 0

src/urh/simulator/Simulator.py

+1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ def process_message(self):
353353
received_msg.decoder = new_message.decoder
354354
received_msg.message_type = new_message.message_type
355355

356+
self.log_message("Message {}: Check whether received data matches".format(msg.index()))
356357
check_result, error_msg = self.check_message(received_msg, new_message, retry=retry,
357358
msg_index=msg.index())
358359

tests/test_continuous_modulator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_modulate_continuously(self):
2020
self.assertTrue(continuous_modulator.ring_buffer.is_empty)
2121
continuous_modulator.start()
2222
self.assertTrue(continuous_modulator.process.is_alive())
23-
time.sleep(1.5)
23+
time.sleep(2)
2424
self.assertFalse(continuous_modulator.ring_buffer.is_empty)
2525
continuous_modulator.stop()
2626
self.assertFalse(continuous_modulator.process.is_alive())

0 commit comments

Comments
 (0)