X-Git-Url: https://git.ao2.it/SaveMySugar/python3-savemysugar.git/blobdiff_plain/88fce7811221c360966eb3af691a719930a2514d..0b31892f76d8add07b5635d65eff6d7c99983411:/src/savemysugar/CallDistanceTransceiver.py diff --git a/src/savemysugar/CallDistanceTransceiver.py b/src/savemysugar/CallDistanceTransceiver.py index fd60a1f..7662b68 100755 --- a/src/savemysugar/CallDistanceTransceiver.py +++ b/src/savemysugar/CallDistanceTransceiver.py @@ -50,7 +50,6 @@ class CallDistanceTransceiver(object): fine. Plus, supporting communications between analog modems is cool :) - """ def __init__(self, modem, @@ -103,23 +102,28 @@ class CallDistanceTransceiver(object): self.ring_uncertainty = ring_uncertainty self.symbol_uncertainty = symbol_distance / 2. - logging.debug("dot time: transmit: %.2f receive: (%.2f, %.2f)", + logging.debug("dot ---------> transmit time: %.2f " + "receive time: between %.2f and %.2f", self.dot_time, (self.dot_time - self.symbol_uncertainty), (self.dot_time + self.symbol_uncertainty)) - logging.debug("dash time: transmit: %.2f receive: (%.2f, %.2f)", + logging.debug("dash --------> transmit time: %.2f " + "receive time: between %.2f and %.2f", self.dash_time, (self.dash_time - self.symbol_uncertainty), (self.dash_time + self.symbol_uncertainty)) - logging.debug("signalspace time: transmit: %.2f receive: (%.2f, %.2f)", + logging.debug("singalspace -> transmit time: %.2f " + "receive time: between %.2f and %.2f", self.signalspace_time, (self.signalspace_time - self.symbol_uncertainty), (self.signalspace_time + self.symbol_uncertainty)) - logging.debug("wordspace time: transmit: %.2f receive: (%.2f, %.2f)", + logging.debug("wordspace ---> transmit time: %.2f " + "receive time: between %.2f and %.2f", self.wordspace_time, (self.wordspace_time - self.symbol_uncertainty), (self.wordspace_time + self.symbol_uncertainty)) - logging.debug("EOM time: transmit: %.2f receive: (%.2f, +inf)", + logging.debug("EOM ---------> transmit time: %.2f " + "receive time: between %.2f and inf", self.eom_time, (self.eom_time - self.symbol_uncertainty)) @@ -143,10 +147,10 @@ class CallDistanceTransceiver(object): self.previous_call_time = current_ring_time self.log_symbol(0, "", "(The very first ring)") return - else: - ring_distance = current_ring_time - self.previous_ring_time - logging.debug("RINGs distance: %.2f", ring_distance) - self.previous_ring_time = current_ring_time + + ring_distance = current_ring_time - self.previous_ring_time + logging.debug("RINGs distance: %.2f", ring_distance) + self.previous_ring_time = current_ring_time # Ignore multiple rings in the same call if abs(ring_distance - self.rings_distance) < self.ring_uncertainty: @@ -191,7 +195,7 @@ class CallDistanceTransceiver(object): return # if the code made it up to here, something fishy is going on - logging.error("Unexpected distance: %.2f", ring_distance) + logging.error("Unexpected distance: %.2f", call_distance) logging.error("Check the transmitter and receiver parameters") def receive_loop(self): @@ -228,7 +232,7 @@ class CallDistanceTransceiver(object): # Dial, then wait self.call_setup_time to make sure the receiver gets # at least one RING, and then hangup and sleep the remaining time - self.modem.send_command("ATDT" + self.destination_number) + self.modem.send_command("ATDT" + self.destination_number + ";") time.sleep(self.call_setup_time) self.modem.send_command("ATH") self.modem.get_response() @@ -244,7 +248,6 @@ class CallDistanceTransceiver(object): morse_message = self.translator.text_to_morse(message) signals = morse_message.split() - print(signals) logging.debug("Starting the transmission") for i, signal in enumerate(signals): @@ -289,7 +292,7 @@ class CallDistanceTransceiver(object): transmitting_time += self.eom_time - logging.debug("Estimated transmitting time: %d seconds", + logging.debug("Estimated transmitting time: %.2f seconds", transmitting_time)