Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Koen De Voegt
authored and
Koen De Voegt
committed
Mar 16, 2011
1 parent
e53f1e3
commit 3481ade
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
import cgi | ||
import serial | ||
import time | ||
import sys | ||
import getpass | ||
|
||
serialPort = "/dev/ttyACM0" | ||
|
||
print "Content-type: text/html" | ||
print "" | ||
|
||
command = "" | ||
|
||
try: | ||
fs = cgi.FieldStorage() | ||
command = fs["value"].value | ||
except: | ||
try: | ||
command = sys.argv[1] | ||
except: | ||
print "Error!!!", sys.exc_info()[0] | ||
|
||
ser = serial.Serial(serialPort, 2400) | ||
|
||
ser.open() | ||
for i in range(0, 4): | ||
command = "%" + str(i) + "#" + command | ||
ser.write(command) | ||
|
||
time.sleep(0.4) | ||
|
||
while ser.inWaiting() > 0: | ||
ser.read() | ||
|
||
time.sleep(1) | ||
|
||
while ser.inWaiting() > 0: | ||
ser.read() | ||
|
||
ser.close() | ||
|
||
print '<head><meta HTTP-EQUIV="REFRESH" content="0; url=http://localhost"></head>' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
|
||
import cgi | ||
import serial | ||
import time | ||
import sys | ||
import getpass | ||
|
||
serialPort = "/dev/ttyACM0" | ||
|
||
print "Content-type: text/html" | ||
print "" | ||
|
||
command = "" | ||
|
||
try: | ||
fs = cgi.FieldStorage() | ||
command = "%" + fs["relay"].value + "#" + fs["value"].value | ||
except: | ||
try: | ||
command = "%" + sys.argv[1] + "#" + sys.argv[2] | ||
except: | ||
print "Error!!!", sys.exc_info()[0] | ||
|
||
ser = serial.Serial(serialPort, 2400) | ||
|
||
ser.open() | ||
|
||
ser.write(command) | ||
|
||
time.sleep(0.3) | ||
|
||
while ser.inWaiting() > 0: | ||
ser.read() | ||
|
||
ser.close() | ||
|
||
print '<head><meta HTTP-EQUIV="REFRESH" content="0; url=http://localhost"></head>' | ||
|