def __init__(self, address): cmd.Cmd.__init__(self) self.signalKiller = GracefulKiller() self.bigLine = '-------------------------------------------------------------------\n' self.prompt = '>>' self.intro = "Welcome to the Neblina Streaming Menu!" self.api = NeblinaAPI(Interface.UART) print( "Setting up the connection..." ) # initial delay needed for the device to synchronize its processors time.sleep(1) print('.') time.sleep(1) print('.') time.sleep(1) print('.') self.api.open(address) global initialmotionstate # the global variable that stores the initial motion engine state initialmotionstate = self.api.getMotionStatus( ) # get the initial motion engine state self.api.streamDisableAll( ) # disable all streaming options after storing the initial state self.api.setDataPortState( Interface.BLE, False) # Close BLE streaming to prevent slowed streaming self.api.setDataPortState(Interface.UART, True) # Open UART streaming
def setUp(self): if not self.comPort: raise unittest.SkipTest("No COM port specified.") # Give it a break between each test time.sleep(1) if not self.setupHasAlreadyRun: self.api = NeblinaAPI(Interface.UART) self.api.open(self.comPort) if not self.api.isOpened(): self.fail("Unable to connect to COM port.") self.api.streamDisableAll() self.api.sessionRecord(False) self.api.setDataPortState(Interface.UART, True)
def setUp(self): if not self.deviceAddress: logging.warn("No Device Address specified. Skipping.") raise unittest.SkipTest # Give it a break between each test time.sleep(2) self.api = NeblinaAPI(Interface.BLE) self.api.open(self.deviceAddress) if not self.api.isOpened(): self.fail("Unable to connect to BLE device.") self.api.streamDisableAll() self.api.sessionRecord(False) self.api.setDataPortState(Interface.BLE, True)
def main(address): signalKiller = GracefulKiller() print("Initialize NeblinaAPI") api = NeblinaAPI(Interface.BLE) print("Opening device: {0}".format(address)) api.open(address) if not api.isOpened(): exit("Unable to connect to device.") print("Opening BLE streaming port") api.setDataPortState(Interface.BLE, True) # It is required to downsample streaming rate to 25Hz (40ms delay) or more to ensure # reception of all incoming streaming packet and other packet when using BLE on Python. api.setDownsample(40) print("Starting EulerAngle Streaming") api.streamEulerAngle(True) while not signalKiller.isKilled: print(api.getEulerAngle()) print("Stopping EulerAngle Streaming") api.streamEulerAngle(False)