Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93787454
modulecontrol.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 1, 12:24
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Dec 3, 12:24 (2 d)
Engine
blob
Format
Raw Data
Handle
22704698
Attached To
rSERVICENOWCHATALERT servicenow-chat-alert
modulecontrol.py
View Options
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
os
,
sys
# add ../../Sources to the PYTHONPATH
sys
.
path
.
append
(
os
.
path
.
join
(
".."
,
".."
,
"Sources"
))
import
os
,
sys
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
()
Event Timeline
Log In to Comment