-
Notifications
You must be signed in to change notification settings - Fork 3
Backplane Software Reference and Driver
For a general overview of how the backplane integrates with the AUV system, please refer to the [Backplane General Overview]("Backplane General Overview.md") guide in the wiki documentation.
Communication from the main computer to the backplane works through a single serial communication port. Since the backplane has the ability to send data (such as critical interrupts) without any requests being performed, requests and responses to the backplane are done in separate threads. One of the threads handles collecting, unpacking, and queuing responses received from the backplane. The main backplane handler thread will perform request for actuator control and request for sensor data, pop available data from the backplane_data_queue, and route any data for processing to other threads for processing.
![](Backplane Handler.png)
This class is responsible for requesting data or sending actions from/to the backplane for various sensors and actuators such as pressure transducers and weapon controls.
**Backplane.Backplane_Requests(backplane_serial_obj) **
Example Usage:
import serial
ser_obj = serial.Serial('COM1', 9600)
backplane_req = Backplane_Requests(ser_obj)
#Make a request for pressure data
backplane_req.request_pressure_transducer_data()
#Read serial response next
__init__(self, backplane_serial_obj)
Initializes connection with the backplane through serial communication.
Parameters:
backplane_serial_obj: An already initialized serial communication object
to the backplane.
Returns:
N/A
request_pressure_transducer_data(self)
Request pressure data from transducers.
Note: The request for pressure data is given by
byte_1: self.header_byte
byte_2: 0x41
byte_3: self.termination_byte
Parameters:
N/A
Returns:
true: If request for transducer data is successful
false: If request for transducer data is unsuccessful
The class is a thread that reads all the responses from the backplane and places the data into a backplane data Queue continuously.
Backplane.Backplane_Responses(backplane_serial_obj)
Example Usage:
import serial
ser_obj = serial.Serial('COM1', 9600)
backplane_resp_thread = Backplane_Responses(ser_obj)
#Start backplane response thread
backplane_resp_thread.start()
while(True):
#As the thread is receiving and queuing data, you will want to pop that data for use.
data = backplane_resp_thread.backplane_data_queue.pop(0)
print(data)
__init__(self, backplane_serial_obj)
Initialize the backplane response thread to connect through serial to
backplane.
Parameters:
backplane_serial_obj: An already initialized serial communication object
to the backplane.
Returns:
N/A
run(self)
Run the tread to continually receive data from the backplane and store
in backplane_data queue.
Parameters:
N/A
Returns:
N/A
__unpack(self)
Read in the transmission from the backplane and extract the data from it.
Parameter:
N/A
Returns:
message: The backplane data after the raw bytes have been unpacked.
This will be in the form of a dictionary were the key is
an abbreviation for the type of data
This class is the main thread that should be run to process both requests and responses to the backplane.
Backplane.Backplane_Responses(backplane_serial_obj)
Example Usage:
backplane_handler = Backplane_Handler("COM6")
backplane_handler.run()
__init__(self, com_port)
Initialize serial connection to the backplane, start the backplane response
thread.
Parameters:
com_port: The serial communication port that the backplane is connected
to.
Returns:
N/A
run(self)
Continually receive data from the backplane and perform any necessary
processing or directing of that data.
Parameters:
N/A
Returns:
N/A