From 320044f4b844defd5355fcdb209e66ae135b8869 Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Sun, 16 Feb 2025 21:59:59 +0100 Subject: [PATCH] Minor fixes for protocol specification --- src/bank_node/bank_worker.py | 11 +---------- src/bank_protocol/bank_scanner.py | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/bank_node/bank_worker.py b/src/bank_node/bank_worker.py index c2c00ba..115a73c 100644 --- a/src/bank_node/bank_worker.py +++ b/src/bank_node/bank_worker.py @@ -79,17 +79,8 @@ class BankWorker(multiprocessing.Process): elif "\r" in buffer: ending = "\r" self.logger.debug("CR detected") - - elif len(buffer) == 2 or len(buffer) >= 16: - # If no line ending is provided, make an assumption - # Either a 2 character command was sent without any line ending - # or the shorted valid command with arguments has to be 16 or more - # characters long - ending = "\n" - self.logger.debug("Messages appear to be missing line ending, proceeding with processing") - if ending is None: - self.logger.debug("No line ending found, and messages don't look complete. Assuming another part will come") + self.logger.debug("No line ending found. Assuming another part will come") continue response = self.process_request(buffer, ending) diff --git a/src/bank_protocol/bank_scanner.py b/src/bank_protocol/bank_scanner.py index 9c66acb..68dcdc9 100644 --- a/src/bank_protocol/bank_scanner.py +++ b/src/bank_protocol/bank_scanner.py @@ -38,7 +38,7 @@ class BankScanner(threading.Thread): self.logger.debug("Unknown error occurred when probing port: %s", e) def __scan_for_bank(self, connection: socket.socket): - ping_command = "BC" + ping_command = "BC\r\n" connection.sendall(ping_command.encode("utf-8")) response = connection.recv(1024).decode("utf-8")