Skip to content

Instantly share code, notes, and snippets.

@nophead
Created April 24, 2018 17:04
Show Gist options
  • Save nophead/9971e140a134753400d45899f4a78d4a to your computer and use it in GitHub Desktop.
Save nophead/9971e140a134753400d45899f4a78d4a to your computer and use it in GitHub Desktop.
Script to demontrate WiFi controlled varaic
#!/usr/bin/env python
import pycurl
from StringIO import StringIO
from time import *
import re
def curl(url):
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, url)
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
return buffer.getvalue()
regex = re.compile('(.*)V *(.*)A *(.*)W Pos *(.*)')
for v in xrange(10, 251, 10):
curl('http://variac/readings?deadband=0&set=&voltage=' + str(v))
while True:
sleep(0.2)
readings = curl('http://variac/readings')
results = regex.match(readings).groups()
V = float(results[0])
A = float(results[1])
W = float(results[2])
P = int(results[3])
if abs(v -V) < 0.1:
break
print v, V, A, W, P
curl('http://variac/readings?manual=')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment