We will create the following missileControl.py script, which will include two classes and a default main() function to test it:
- Import the required modules as follows:
#!/usr/bin/python3 # missileControl.py import time import usb.core
- Define the SamMissile() class, which provides the specific commands for the USB device, as follows:
class SamMissile(): idVendor=0x1130 idProduct=0x0202 idName="Tenx Technology SAM Missile" # Protocol control bytes bmRequestType=0x21 bmRequest=0x09 wValue=0x02 wIndex=0x01 # Protocol command bytes INITA = [ord('U'), ord('S'), ord('B'), ord('C'), 0, 0, 4, 0] INITB = [ord('U'), ord('S'), ord('B'), ord('C'), 0, 64, 2, 0] CMDFILL = [ 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...