Skip to content

Commit

Permalink
final datastreamer touches
Browse files Browse the repository at this point in the history
  • Loading branch information
mpkarpov-ui committed Nov 8, 2023
1 parent 1432c00 commit a15f07b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions Test-Rack-Software/tars_rack/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ def detect(self) -> bool:
ignore_ports = []
# We should ignore the server's comport if the chosen server communication channel is serial..
if type(self.server.server_comm_channel) == serial_interface.SerialChannel:
print("(detect_avionics) Server is using Serial Channel interface")
ignore_ports = [self.server.server_comm_channel]

for comport in server.connected_comports:
if not (comport in ignore_ports):
print("(detect_avionics) Detected viable avionics target @ " + comport.name)
self.TARS_port = comport
print("(detect_avionics) Detected viable avionics target @ " + comport.serial_port.name)
self.TARS_port = comport.serial_port
self.ready = True
return True

Expand Down Expand Up @@ -141,10 +142,14 @@ def job_setup(self):
return False, "Abort signal recieved"

try:
if(self.av_interface.TARS_port.is_open):
return True, "Setup Complete"
self.av_interface.TARS_port.open()
print("\n(job_setup) Successfully re-opened TARS port (" + self.av_interface.TARS_port.name + ")")
print("\n(job_setup) Successfully re-opened TARS port (" + self.av_interface.TARS_port.serial_port.name + ")")
return True, "Setup Complete"
except:
except Exception as e:
print(e)
print("")
time_left = abs((start + 10) - time.time())
print(f"(job_setup) attempting to re-open tars port.. ({time_left:.1f}s)", end="\r")
return False, "Unable to re-open avionics COM Port"
Expand Down
4 changes: 4 additions & 0 deletions Test-Rack-Software/util/datastreamer_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ class DatastreamerServer:
state: ServerStateController = ServerStateController()
"""Datastreamer server's state machine reference"""
board_type: str = ""

# COMMUNICATION
server_comm_channel: communication_interface.CommunicationChannel = None
"""Serial port reference to the serial port that connects to the Kamaji server."""
server_preferred_comm_method: communication_interface.CommunicationChannelType = communication_interface.CommunicationChannelType.SERIAL
"""The preferred method for datastreamer boards to communicate to Kamaji. Defaults to `SERIAL`"""
board_id = -1
"""Board ID assigned by the Kamaji server"""

Expand Down
2 changes: 1 addition & 1 deletion Test-Rack-Software/util/handle_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def handle_server_packets(Server: Datastreamer.DatastreamerServer):
Server.packet_buffer.add(pkt.CL_PONG())
case pkt.DataPacketType.ACKNOWLEDGE:
# For an invalid ACK, we send back an invalid packet.
if(Server.server_port != None):
if(Server.server_comm_channel != None):
Server.packet_buffer.add(pkt.CL_INVALID(packet))
case pkt.DataPacketType.REASSIGN:
# For REASSIGN, we check if the command is valid, reassign if yes, INVALID if no.
Expand Down

0 comments on commit a15f07b

Please sign in to comment.