Skip to content

Commit

Permalink
Merge pull request #264 from Windham-High-School/release-1.6.1
Browse files Browse the repository at this point in the history
Release 1.6.1
  • Loading branch information
snorklerjoe authored May 9, 2023
2 parents 47760eb + b189d6c commit 751a13d
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/CubeServer-api/cubeserver_api/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.0"
__version__ = "1.6.1"
2 changes: 1 addition & 1 deletion src/CubeServer-app/cubeserver_app/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.0"
__version__ = "1.6.1"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.0"
__version__ = "1.6.1"
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def connect_hook(client_socket):
# Send the request to the appropriate reference server
with routing_id_map[req.routing_id].lock:
routing_id_map[req.routing_id].tx_bytes(req.dump())
if routing_id_map[req.routing_id].rx_bytes(1) != protocol.ReferenceSignal.ACK.value:
logging.warn("Reference server did not acknowledge request")
return
response = protocol.ReferenceResponse.from_socket(routing_id_map[req.routing_id].sock)

# Log the response
Expand Down
2 changes: 1 addition & 1 deletion src/CubeServer-common/cubeserver_common/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.0"
__version__ = "1.6.1"
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def request(self, req: protocol.ReferenceRequest) -> protocol.ReferenceResponse:
"""Sends a request to the reference server and returns the response"""
self.sock.setblocking(True)
self.sock.send(req.dump())
# if self.sock.rx_bytes(1) != protocol.ReferenceSignal.ACK.value:
# logging.warn("Reference server did not acknowledge request")
# return
return protocol.ReferenceResponse.from_socket(self.sock)

def close(self):
Expand Down
29 changes: 25 additions & 4 deletions src/CubeServer-common/cubeserver_common/reference_api/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ def dump(self) -> bytes:
"""Dumps the response to a byte string"""
return b''.join([
REFERENCECOM_VERSION,
self.signal.value,
self.signal.value if isinstance(self.signal, ReferenceSignal) else self.signal,
self.length,
self.struct_type,
self.response,
ReferenceSignal.EOT
ReferenceSignal.EOT.value
])

def get_value(self) -> bytes | int | bool | float:
Expand All @@ -154,26 +154,47 @@ def set_value(self, format: str | bytes, value: bytes | int | bool | float) -> N
def from_socket(self, socket: socket.socket) -> 'ReferenceResponse':
"""Reads a response from the given socket"""
# <version><signal><length><struct_type><response><EOT>
logging.debug("Reading response from socket")
version = socket.recv(1)
if version == ReferenceSignal.ACK.value:
logging.debug("Received ACK")
version = socket.recv(1)
elif version == ReferenceSignal.NAK.value:
logging.debug("Received NAK")
return None
logging.debug(f"Version: {version}")
if version != REFERENCECOM_VERSION:
logging.warning(f"Invalid response - wrong version")
socket.sendall(ReferenceSignal.NAK.value)
return
signal = socket.recv(1)
logging.debug(f"Signal: {signal}")
if signal != ReferenceSignal.ACK.value:
logging.warning(f"Invalid Did not get ACK")
socket.sendall(ReferenceSignal.NAK.value)
return
length = int.from_bytes(self.rx_bytes(1), 'big')
length = int.from_bytes(socket.recv(1), 'big')
logging.debug(f"Length: {length}")
struct_type = socket.recv(1)
logging.debug(f"Struct Type: {struct_type}")
response = socket.recv(length)
logging.debug(f"Response: {response}")
eot = socket.recv(1)
if eot != ReferenceSignal.EOT.value:
logging.warning(f"Invalid response - missing EOT")
socket.sendall(ReferenceSignal.NAK.value)
return

logging.debug(f"Signal: {signal}")
logging.debug(f"Length: {bytes([length])}")
logging.debug(f"Struct Type: {struct_type}")
logging.debug(f"Response: {response}")
logging.debug(f"EOT: {eot}")

# Package response
return ReferenceResponse(
signal=signal,
length=length,
length=bytes([length]),
struct_type=struct_type,
response=response
)
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.0
1.6.1

0 comments on commit 751a13d

Please sign in to comment.