Beispiel #1
0
def main():
    """
    Main function.
    """
    # initialise objects
    serial_port = serial.Serial(port='COM4', baudrate=57600)
    ble_builder = BLEBuilder(serial_port)
    ble_parser = BLEParser(serial_port, callback=analyse_packet)

    # initialise the device
    print("COMMAND: Initialising device")
    print(print_output(ble_builder.send("fe00")))

    # get an operating parameter value
    print("COMMAND: Getting operating parameter value")
    print(print_output(ble_builder.send("fe31", param_id="\x15")))

    # start a device discovery scan
    print("COMMAND: Starting device scan")
    print(print_output(ble_builder.send("fe04", mode="\x03")))

    # sleep main thread for 15 seconds - allow results of device scan to return
    time.sleep(15)

    #close device
    ble_parser.stop()
Beispiel #2
0
def main():
    """
    Main function.
    """
    # initialise objects
    serial_port = serial.Serial(port='COM4', baudrate=57600)
    ble_builder = BLEBuilder(serial_port)
    ble_parser = BLEParser(serial_port, callback=analyse_packet)

    # initialise the device
    print("COMMAND: Initialising device")
    print(print_output(ble_builder.send("fe00")))

    # get an operating parameter value
    print("COMMAND: Getting operating parameter value")
    print(print_output(ble_builder.send("fe31", param_id="\x15")))

    # start a device discovery scan
    print("COMMAND: Starting device scan")
    print(print_output(ble_builder.send("fe04", mode="\x03")))

    # sleep main thread for 15 seconds - allow results of device scan to return
    time.sleep(15)

    #close device
    ble_parser.stop()
Beispiel #3
0
def executeTestSequence(dut_parameters, log_queue):
    global current_state
    global output

    output = 0
    current_state = 0
    setupSuccess = False
    overallPass = False
    logentry = {}

    if not MDapi.internet_on():
        resetState()
        return -2

    #reset globals
    resetState()

    #SET UP KEITHLEY POWER
    worked = powerSetup()

    if not worked:
        return -3

    #INSTALL CORRECT FIRMWARE ON DEVICE FOR TESTING
    results = programmingSequence(dut_parameters, log_queue)
    stationOneTests = []

    if 'programEFM' in results:
        unlockEFM = results['unlock']
        programCC = results['programCC']
        programEFM = results['programEFM']
        setupSuccess = (unlockEFM.is_passed and programCC.is_passed
                        and programEFM.is_passed)
        stationOneTests.append(unlockEFM)
        stationOneTests.append(programCC)
        stationOneTests.append(programEFM)
    else:
        unlockEFM = results['unlock']
        logentry['unlocked'] = unlockEFM.is_passed
        if 'programCC' in results:
            programCC = results['programCC']
            logentry['ieee_read'] = programCC.is_passed
            if programCC.is_passed:
                logentry['ieee'] = results['ieee'].translate(None, '.')

    #DEVICE CORRECTLY SET UP FOR TESTING
    if setupSuccess:
        ieee = results['ieee']
        logentry['unlocked'] = True
        logentry['ieee_read'] = True
        logentry['test_began'] = True
        logentry['ieee'] = ieee.translate(None, '.')

        powerCycle()

        ledTests = singleLEDCurrentTests()
        stationOneTests.append(ledTests['mcu'])
        stationOneTests.append(ledTests['led'])

        sixLEDTest = sixLEDCurrentTest()
        stationOneTests.append(sixLEDTest)

        accelSelf = accelerometerSelfTest()
        stationOneTests.append(accelSelf)

        lowPower = lowPowerTest()
        stationOneTests.append(lowPower)

        flashFinal = flashFinalFirmware(dut_parameters, log_queue)
        stationOneTests.append(flashFinal)

        #initialise BT module and USB Dongle
        serial_port = serial.Serial(port=COM_PORT, baudrate=57600)
        ble_builder = BLEBuilder(serial_port)
        ble_parser = BLEParser(serial_port, callback=__analysePacket)

        timeout1 = connectToShineDUT(ble_builder, ieee)
        timeout2 = False

        if not timeout1:
            btTests = measureAverageRSSI(ble_builder)
            timeout2 = btTests['timeout']
            #if we timed out, we didn't complete these tests, so don't include them.
            if not timeout2:
                if 'rssi' in btTests:  #check to make sure we completed the rssi test
                    stationOneTests.append(btTests['rssi'])
                stationOneTests.append(
                    btTests['invalid']
                )  #this one will always be in there if there wasn't a timeout

        #close link
        ble_builder.send("fe0a")

        #close device
        ble_parser.stop()
        serial_port.close()
        ieee = ieee.translate(None, '.')

        timeoutPass = True
        if timeout1 or timeout2:
            timeoutPass = False

        map_timeout = {'True': 1, 'False': 0}

        timeoutTest = StationOneTimeoutTest(
            isPassed=timeoutPass,
            timestamp=time.time(),
            timeouts=[map_timeout[str(timeout1)], map_timeout[str(timeout2)]])
        stationOneTests.append(timeoutTest)

        #TEST DONE
        #create the overall station test object
        overallPass = True
        for each in stationOneTests:
            if not each.is_passed:
                overallPass = False

        #CREATED STATION ONE TEST OBJECT
        stationOneTest = StationTest("1." + str(ATE_ID), overallPass,
                                     "log_format_7", "0.0.21.ht03",
                                     stationOneTests, time.time())

        #CREATE MISFIT DEVICE OBJECT
        misfitDevice = Device(serial_number="",
                              ieee=ieee,
                              manufacturer='MisfitVS',
                              creation_time=time.time())
        misfitDevice.physical['mechanical_revision'] = "1.0"
        misfitDevice.physical['pcb_revision'] = "0.9"
        misfitDevice.physical['pcba_revision'] = "0.9"
        misfitDevice.physical['color'] = "TBD"
        misfitDevice.physical['model_number'] = "TBD"
        misfitDevice.addStationTest(stationOneTest)

        #ADD ENTRY TO MFG DATABASE
        post_success = postTestEntryToMFGdb(stationOneTest, misfitDevice)

        # if this is false, it failed 5 times so ostensibly the internet is down.  do we fail the unit?  or pass and wait to import later?
        st = my_dict(stationOneTest)
        logentry['station_test'] = st
        logentry['mfg_db_post_success'] = post_success
    else:
        logentry['test_began'] = False
        logentry['station_test'] = {}
        logentry['mfg_db_post_success'] = False

    logentry['station_one_log_format'] = 'log_format_7'

    if logentry['mfg_db_post_success'] == True:
        logPostedEntry(logentry)
    else:
        logUnpostedEntry(logentry)

    #return UI to show operator
    if overallPass:
        return 0
    else:
        return 1