Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
def init(do):
    do.send("C,0\r")  # Continuous mode off
    ok = do.receive()
    print(ok)
    return ok
Ejemplo n.º 4
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 5
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("C,1\r")

ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 6
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'

Ejemplo n.º 7
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("I\r")
do.receive()
ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 8
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("R\r")
do.receive()
ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 9
0
#!/usr/bin/env python3
import do
import time

do.VERBOSE = True

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

while True:
    do.send("L,1\r")
    
    ok = do.receive()
    assert ok == '*OK'

    time.sleep(3)
    do.send("L,0\r")
    
    ok = do.receive()
    assert ok == '*OK'

    time.sleep(1)


Ejemplo n.º 10
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("P,?\r")
do.receive()
ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 11
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 12
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 13
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("C,0\r")

ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 14
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("NAME,?\r")
do.receive()
ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 15
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'

Ejemplo n.º 16
0
def init(do):
  do.send("C,0\r") # Continuous mode off
  ok = do.receive()
  print(ok)
  return ok
Ejemplo n.º 17
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 18
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 19
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("STATUS\r")

do.receive()
ok = do.receive()
assert ok == '*OK'
Ejemplo n.º 20
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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


Ejemplo n.º 21
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 22
0
#!/usr/bin/env python3
import do
import time

do.VERBOSE = True

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

while True:
    do.send("L,1\r")

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

    time.sleep(3)
    do.send("L,0\r")

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

    time.sleep(1)
Ejemplo n.º 23
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

Ejemplo n.º 24
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'
Ejemplo n.º 25
0
#!/usr/bin/env python3
import do

do.VERBOSE = True

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

do.send("S,?\r")
do.receive()
ok = do.receive()
assert ok == '*OK'