Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

All the interface logic will be isolated in a class called USBInterface/UARTInterface. The class is described below.

USBInterface/UARTInterface

+read(endpointId): Issues a read command in either serial (UART) or pyusb (USB). EndpointId can be the specific serial port to use or the usb endpoint to be used.

+write(endpointId, data): Issues a write command in either serial or pyusb. Data parameter should be a buffer.

+create_endpoint_FC(): Returns a new endpoint, either a Serial object (UART) or Endpoint object (USB), that points to our flightcontroller.

-endpoints: Dictionary {endpointId: endpoint object (Serial object or Endpoint object)}. The first one is populated by calling the create_endpoint_FC() function in the constructor.

TODO: Data logic in FltConn module

Perform any data processing required to turn the return of read(…) or write(…) into the appropriate python object. Implemented as a set of functions in the FltConn modules. PIGOs and POGIs are constructed at this stage.

TODO: API logic in FltConn module

Exposes functionality to the worker function. Should just have get_pogi() and get_pigo() functionsA similar version of this will be used for the XBee Interface

XBee Interface

+read_callback(): Sets up a callback that is executed when a message is recieved. self.function_dict is a dictionary of functions which are called when a message is receieved. When you get a message, decode it then call self.functionDict['main'](data).

+write(deviceId, data): Issues a send command to that device_id

+create_device(read_function_dict): This function should perform steps 2-3 from the tutorial, then call use add_data_recieved_callback, like in this tutorial to register read_callback as the callback function, then store the created xbee device in a dictionary with the ID as the key, {0: device, …}. Then it should set self.functionDict = read_function_dict. Return ID.

-endpoints: Dictionary {deviceId: device object}. The first one is populated by calling the create_endpoint in the constructor.

-functionDict: Dictionary{name: function}, a dictionary of functions that the read callback can call once it recieves a message. The default will just be {'main': main_read(…)} where main_read is whatever function is used in the GroundConnRecieve module.

Reference

Exchanged Data

USB Protocol Overview

...

https://pyserial.readthedocs.io/en/latest/pyserial.html#overview

XBee Python