oscilloscope.py
来自「tinyos-2.x.rar」· Python 代码 · 共 30 行
PY
30 行
#!/usr/bin/env python
import sys
import tos
AM_OSCILLOSCOPE = 0x93
class OscilloscopeMsg(tos.Packet):
def __init__(self, packet = None):
tos.Packet.__init__(self,
[('version', 'int', 2),
('interval', 'int', 2),
('id', 'int', 2),
('count', 'int', 2),
('readings', 'blob', None)],
packet)
if '-h' in sys.argv:
print "Usage:", sys.argv[0], "serial@/dev/ttyUSB0:57600"
sys.exit()
am = tos.AM()
while True:
p = am.read()
if p and p.type == AM_OSCILLOSCOPE:
msg = OscilloscopeMsg(p.data)
print msg.id, msg.count, [i<<8 | j for (i,j) in zip(msg.readings[::2], msg.readings[1::2])]
#print msg
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?