Exemplo n.º 1
0
def main():
    session = tmex.Session()
    devices = session.enumrate(familyFilter=[0x28])

    for key, device in tmex.iteritems(devices):
        print('%s: %s %s' % (key, device['name'], device['description']))

    while True:
        try:
            devices = list(devices)
            data = session.readDevices(devices=devices, familyFilter=['DS18B2'], timeStamp=True)
            deviceCount = 0
            for rom in data:
                if rom in devices:
                    datarom = data[rom]
                    if 'temperature' in datarom:
                        temp = datarom['temperature']
                        print("{} = {:<8} C".format(rom, temp))
                    deviceCount += 1
            if 'delta' in data:
                delta = data['delta'].total_seconds()
                print("{} sensors were surveyed for {} seconds\n".format(deviceCount, delta))
            print("Sleeping 2 seconds ...")
            time.sleep(2)
        except KeyboardInterrupt:
            break
Exemplo n.º 2
0
def main():
    session = tmex.Session()
    devices = session.enumrate()
     
    for key, device in tmex.iteritems(devices):
        print('%s: %s %s' % (key, device['name'], device['description']))
    
    while True:
        try:
            for key, device in tmex.iteritems(devices):
                readout = session.readDevice(key)
                if len(readout) > 0:
                    messages = ['%s:' % (key)]
                    for key, value in tmex.iteritems(readout):
                        messages.append('%s: %.2f' % (key, value))
                    print(' '.join(messages))
        except KeyboardInterrupt:
            break
Exemplo n.º 3
0
def main():
    session = tmex.Session()
    devices = session.enumrate()

    for key, device in tmex.iteritems(devices):
        print("%s: %s %s" % (key, device["name"], device["description"]))

    while True:
        try:
            for key, device in tmex.iteritems(devices):
                readout = session.readDevice(key)
                if len(readout) > 0:
                    messages = ["%s:" % (key)]
                    for key, value in tmex.iteritems(readout):
                        messages.append("%s: %.2f" % (key, value))
                    print(" ".join(messages))
        except KeyboardInterrupt:
            break
Exemplo n.º 4
0
def main():
    session = tmex.Session()
    devices = session.enumrate()

    for key, device in tmex.iteritems(devices):
        print('%s: %s %s' % (key, device['name'], device['description']))

    while True:
        try:
            for key, device in tmex.iteritems(devices):
                readout = session.readDevice(key)
                if len(readout) > 0:
                    messages = ['%s:' % (key)]
                    for key, value in tmex.iteritems(readout):
                        messages.append('%s: %.2f' % (key, value))
                    print(' '.join(messages))
        except KeyboardInterrupt:
            break