예제 #1
0
def main():

  # Connect to IOT Hub
  device = DeviceClient.DeviceClient(config.HUB, config.DEVICE_NAME, config.KEY)

  # Connect to the Atlas Scientific DO circuit board
  do.connect()

  ok = init(do)
  while ok != '*OK':
         ok = init(do)
         
  while True:
    
    do.send("R\r") # Request a value for DO
    
    r = do.receive()
    print(r)
    ok = do.receive()
    print(ok)
    assert ok == '*OK'
    
    msg = "{ \"deviceId\" : \"" + config.DEVICE_NAME + "\", \"do\" : \"" + r + "\"" + ", \"at\" : \"" + str(datetime.now()) + "\"}"
    print(msg)

    try:    
        device.create_sas(600) # Shared Access Signature used for authentication
        print(device.send(bytes(msg,'utf-8')))
    except Exception as err:
        print(err)
    
    time.sleep(SLEEP)
예제 #2
0
def main():

    # Connect to IOT Hub
    device = DeviceClient.DeviceClient(config.HUB, config.DEVICE_NAME,
                                       config.KEY)

    # Connect to the Atlas Scientific DO circuit board
    do.connect()

    ok = init(do)
    while ok != '*OK':
        ok = init(do)

    while True:

        do.send("R\r")  # Request a value for DO

        r = do.receive()
        print(r)
        ok = do.receive()
        print(ok)
        assert ok == '*OK'

        msg = "{ \"deviceId\" : \"" + config.DEVICE_NAME + "\", \"do\" : \"" + r + "\"" + ", \"at\" : \"" + str(
            datetime.now()) + "\"}"
        print(msg)

        try:
            device.create_sas(
                600)  # Shared Access Signature used for authentication
            print(device.send(bytes(msg, 'utf-8')))
        except Exception as err:
            print(err)

        time.sleep(SLEEP)
예제 #3
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

# Connect to the Atlas Scientific DO circuit board
do.connect()

do.send("Cal\r")

ok = do.receive()
assert ok == '*OK'
예제 #4
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

# Connect to the Atlas Scientific DO circuit board
do.connect()
  
do.send("T,?\r")
do.receive()
ok = do.receive()
assert ok == '*OK'