# ********************************************************************
#
#  $Id: svn_id $
#
#  Doc-ModuleControl example
#
#  You can find more information on our web site:
#   Python API Reference:
#      https://www.yoctopuce.com/EN/doc/reference/yoctolib-python-EN.html
#
# *********************************************************************

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
# add ../../Sources to the PYTHONPATH
sys.path.append(os.path.join("..", "..", "Sources"))

from yocto_api import *


def usage():
    sys.exit("usage: demo <serial or logical name> [ON/OFF]")


errmsg = YRefParam()
if YAPI.RegisterHub("usb", errmsg) != YAPI.SUCCESS:
    sys.exit("RegisterHub error: " + str(errmsg))

if len(sys.argv) < 2:
    usage()

m = YModule.FindModule(sys.argv[1])  # # use serial or logical name

if m.isOnline():
    if len(sys.argv) > 2:
        if sys.argv[2].upper() == "ON":
            m.set_beacon(YModule.BEACON_ON)
        if sys.argv[2].upper() == "OFF":
            m.set_beacon(YModule.BEACON_OFF)

    print("serial:       " + m.get_serialNumber())
    print("logical name: " + m.get_logicalName())
    print("luminosity:   " + str(m.get_luminosity()))
    if m.get_beacon() == YModule.BEACON_ON:
        print("beacon:       ON")
    else:
        print("beacon:       OFF")
    print("upTime:       " + str(m.get_upTime() / 1000) + " sec")
    print("USB current:  " + str(m.get_usbCurrent()) + " mA")
    print("logs:\n" + m.get_lastLogs())
else:
    print(sys.argv[1] + " not connected (check identification and USB cable)")
YAPI.FreeAPI()

15469a89a074765572fa4948ace4e813b215946c
<mask token>


def usage():
    sys.exit('usage: demo <serial or logical name> [ON/OFF]')


<mask token>

<mask token>
sys.path.append(os.path.join('..', '..', 'Sources'))
<mask token>


def usage():
    sys.exit('usage: demo <serial or logical name> [ON/OFF]')


<mask token>
if YAPI.RegisterHub('usb', errmsg) != YAPI.SUCCESS:
    sys.exit('RegisterHub error: ' + str(errmsg))
if len(sys.argv) < 2:
    usage()
<mask token>
if m.isOnline():
    if len(sys.argv) > 2:
        if sys.argv[2].upper() == 'ON':
            m.set_beacon(YModule.BEACON_ON)
        if sys.argv[2].upper() == 'OFF':
            m.set_beacon(YModule.BEACON_OFF)
    print('serial:       ' + m.get_serialNumber())
    print('logical name: ' + m.get_logicalName())
    print('luminosity:   ' + str(m.get_luminosity()))
    if m.get_beacon() == YModule.BEACON_ON:
        print('beacon:       ON')
    else:
        print('beacon:       OFF')
    print('upTime:       ' + str(m.get_upTime() / 1000) + ' sec')
    print('USB current:  ' + str(m.get_usbCurrent()) + ' mA')
    print('logs:\n' + m.get_lastLogs())
else:
    print(sys.argv[1] + ' not connected (check identification and USB cable)')
YAPI.FreeAPI()

<mask token>
sys.path.append(os.path.join('..', '..', 'Sources'))
<mask token>


def usage():
    sys.exit('usage: demo <serial or logical name> [ON/OFF]')


errmsg = YRefParam()
if YAPI.RegisterHub('usb', errmsg) != YAPI.SUCCESS:
    sys.exit('RegisterHub error: ' + str(errmsg))
if len(sys.argv) < 2:
    usage()
m = YModule.FindModule(sys.argv[1])
if m.isOnline():
    if len(sys.argv) > 2:
        if sys.argv[2].upper() == 'ON':
            m.set_beacon(YModule.BEACON_ON)
        if sys.argv[2].upper() == 'OFF':
            m.set_beacon(YModule.BEACON_OFF)
    print('serial:       ' + m.get_serialNumber())
    print('logical name: ' + m.get_logicalName())
    print('luminosity:   ' + str(m.get_luminosity()))
    if m.get_beacon() == YModule.BEACON_ON:
        print('beacon:       ON')
    else:
        print('beacon:       OFF')
    print('upTime:       ' + str(m.get_upTime() / 1000) + ' sec')
    print('USB current:  ' + str(m.get_usbCurrent()) + ' mA')
    print('logs:\n' + m.get_lastLogs())
else:
    print(sys.argv[1] + ' not connected (check identification and USB cable)')
YAPI.FreeAPI()

import os, sys
sys.path.append(os.path.join('..', '..', 'Sources'))
from yocto_api import *


def usage():
    sys.exit('usage: demo <serial or logical name> [ON/OFF]')


errmsg = YRefParam()
if YAPI.RegisterHub('usb', errmsg) != YAPI.SUCCESS:
    sys.exit('RegisterHub error: ' + str(errmsg))
if len(sys.argv) < 2:
    usage()
m = YModule.FindModule(sys.argv[1])
if m.isOnline():
    if len(sys.argv) > 2:
        if sys.argv[2].upper() == 'ON':
            m.set_beacon(YModule.BEACON_ON)
        if sys.argv[2].upper() == 'OFF':
            m.set_beacon(YModule.BEACON_OFF)
    print('serial:       ' + m.get_serialNumber())
    print('logical name: ' + m.get_logicalName())
    print('luminosity:   ' + str(m.get_luminosity()))
    if m.get_beacon() == YModule.BEACON_ON:
        print('beacon:       ON')
    else:
        print('beacon:       OFF')
    print('upTime:       ' + str(m.get_upTime() / 1000) + ' sec')
    print('USB current:  ' + str(m.get_usbCurrent()) + ' mA')
    print('logs:\n' + m.get_lastLogs())
else:
    print(sys.argv[1] + ' not connected (check identification and USB cable)')
YAPI.FreeAPI()

# ********************************************************************
#
#  $Id: svn_id $
#
#  Doc-ModuleControl example
#
#  You can find more information on our web site:
#   Python API Reference:
#      https://www.yoctopuce.com/EN/doc/reference/yoctolib-python-EN.html
#
# *********************************************************************

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
# add ../../Sources to the PYTHONPATH
sys.path.append(os.path.join("..", "..", "Sources"))

from yocto_api import *


def usage():
    sys.exit("usage: demo <serial or logical name> [ON/OFF]")


errmsg = YRefParam()
if YAPI.RegisterHub("usb", errmsg) != YAPI.SUCCESS:
    sys.exit("RegisterHub error: " + str(errmsg))

if len(sys.argv) < 2:
    usage()

m = YModule.FindModule(sys.argv[1])  # # use serial or logical name

if m.isOnline():
    if len(sys.argv) > 2:
        if sys.argv[2].upper() == "ON":
            m.set_beacon(YModule.BEACON_ON)
        if sys.argv[2].upper() == "OFF":
            m.set_beacon(YModule.BEACON_OFF)

    print("serial:       " + m.get_serialNumber())
    print("logical name: " + m.get_logicalName())
    print("luminosity:   " + str(m.get_luminosity()))
    if m.get_beacon() == YModule.BEACON_ON:
        print("beacon:       ON")
    else:
        print("beacon:       OFF")
    print("upTime:       " + str(m.get_upTime() / 1000) + " sec")
    print("USB current:  " + str(m.get_usbCurrent()) + " mA")
    print("logs:\n" + m.get_lastLogs())
else:
    print(sys.argv[1] + " not connected (check identification and USB cable)")
YAPI.FreeAPI()
