Ejemplo n.º 1
0
def main():
    # Create a basic logger
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(
            device='/dev/cu.usbserial-ftE23GYE')

        # Do an handshake
        my312.handshake()

        # Set the power level to low
        my312.setPowerLevel(powerlevel=POWERLEVEL_LOW)
        sleep(2.0)

        # Set the power level to normal
        my312.setPowerLevel(powerlevel=POWERLEVEL_NORMAL)
        sleep(2.0)

        # Set the power level to high
        my312.setPowerLevel(powerlevel=POWERLEVEL_HIGH)
        sleep(2.0)
    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Reset the key
        my312.resetkey()
        my312.closeserialport()
Ejemplo n.º 2
0
def main():
    # Create a basic logger
    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(device='/dev/ttyUSB0')

        # Do an handshake
        my312.handshake()

        # Set the power level to low
        my312.powerLevelSet(powerlevel=POWERLEVEL_LOW)
        sleep(2.0)

        # Set the power level to normal
        my312.powerLevelSet(powerlevel=POWERLEVEL_NORMAL)
        sleep(2.0)

        # Set the power level to high
        my312.powerLevelSet(powerlevel=POWERLEVEL_HIGH)
        sleep(2.0)
    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Close the connection
        my312.close()
Ejemplo n.º 3
0
def main():
    # Create a basic logger
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(
            device='/dev/cu.usbserial-ftE23GYE')

        # Do an handshake
        my312.handshake()

        # Load the favorite mode
        my312.loadFavoriteMode()

        # Get the current selected mode
        current_mode = my312.readaddress(
            address=mk312.constants.ADDRESS_CURRENT_MODE)
        print('Current mode: 0x%0.2X' % current_mode)
    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Reset the key
        my312.resetkey()
        my312.closeserialport()
Ejemplo n.º 4
0
def main():
    # Create a basic logger
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(
            device='/dev/cu.usbserial-ftE23GYE')

        # Do an handshake
        my312.handshake()

        # Disable the ADC
        my312.disableADC()

        # Load intense module
        my312.loadMode(mode=MODE_INTENSE)

        # Set power level
        my312.setPowerLevel(powerlevel=POWERLEVEL_HIGH)

        # Get the possible values of multi adjust
        ma_min, ma_max = my312.getMinMaxValueMA()
        logging.info('MA min: 0x%0.2X MA max: 0x%0.2X' % (ma_min, ma_max))
        # Get the actual multi adjus level
        ma_level = my312.getLevelMA()
        logging.info('MA level: 0x%0.2X' % ma_level)

        # Do some fun
        my312.setLevelMA(level=128)
        my312.setLevelA(level=128)
        my312.getLevelA()
        my312.setLevelB(level=64)
        my312.getLevelB()
        sleep(5.0)
        my312.setLevelMA(level=255)
        my312.setLevelA(level=255)
        my312.setLevelB(level=128)
        sleep(5.0)
        my312.setLevelMA(level=9)
        my312.setLevelA(level=0)
        my312.setLevelB(level=0)

        # Enable the ADC
        my312.enableADC()
    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Reset the key
        my312.resetkey()
        my312.closeserialport()
Ejemplo n.º 5
0
def main():
    # Create a basic logger
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(device='/dev/ttyUSB0')

        # Do an handshake
        my312.handshake()

        # Disable the ADC
        my312.adcDisable()

        # Load intense module
        my312.modeSet(mode=MODE_INTENSE)

        # Set power level
        my312.powerLevelSet(powerlevel=POWERLEVEL_HIGH)

        # Get the possible values of multi adjust
        ma_min, ma_max = my312.levelMAGetMinMaxValue()
        logging.info('MA min: 0x%0.2X MA max: 0x%0.2X' % (ma_min, ma_max))
        # Get the actual multi adjus level
        ma_level = my312.levelMAGet()
        logging.info('MA level: 0x%0.2X' % ma_level)

        # Do some fun
        my312.levelMASet(level=128)
        my312.levelASet(level=128)
        my312.levelAGet()
        my312.levelBSet(level=64)
        my312.levelBGet()
        sleep(5.0)
        my312.levelMASet(level=255)
        my312.levelASet(level=255)
        my312.levelBSet(level=128)
        sleep(5.0)
        my312.levelMASet(level=9)
        my312.levelASet(level=0)
        my312.levelBSet(level=0)
        sleep(5.0)

        # Enable the ADC
        my312.adcEnable()
    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Close the connection
        my312.close()
Ejemplo n.º 6
0
def main():
    # Create a basic logger
    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(device='/dev/ttyUSB0')

        # Do an handshake
        my312.handshake()

        # Switch the modes
        for mode in range(MODE_WAVES, MODE_USER7, 1):
            my312.modeSet(mode=mode)
            sleep(4.0)

    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Close the connection
        my312.close()
Ejemplo n.º 7
0
def main():
    # Create a basic logger
    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)

    try:
        # Create the communication wrapper
        my312 = mk312.MK312CommunicationWrapper(device='/dev/cu.usbserial-ftE23GYE')

        # Do an handshake
        my312.handshake()

        # Switch the modes
        for mode in range(MODE_WAVES, MODE_USER7, 1):
            my312.loadMode(mode=mode)
            sleep(4.0)

    except Exception as e:
        logging.error('Exception: %s.' % e)
    finally:
        # Reset the key
        my312.resetkey()
        my312.closeserialport()
Ejemplo n.º 8
0
def set_mk312(power_a=-1, power_b=-1, ma=-1):
    try:
        my312 = mk312.MK312CommunicationWrapper(device="COM4")
        my312.handshake()
        my312.disableADC()
        my312.loadMode(mode=MODE_INTENSE)
        # my312.setPowerLevel(powerlevel=POWERLEVEL_HIGH)
        if (ma > -1):
            my312.setLevelMA(level=ma)
        mk312_state["ma"] = my312.getLevelMA()
        if (power_a > -1):
            my312.setLevelA(level=power_a)
        mk312_state["power_a"] = my312.getLevelA()
        if (power_a > -1):
            my312.setLevelB(level=power_b)
        mk312_state["power_b"] = my312.getLevelB()
    #my312.enableADC()
    except Exception as e:
        print("excecption mk312: " + e)
    finally:
        my312.resetkey()
        my312.closeserialport()