Skip to content

Commit

Permalink
the cgi files
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen De Voegt authored and Koen De Voegt committed Mar 16, 2011
1 parent e53f1e3 commit 3481ade
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
1 change: 0 additions & 1 deletion cgi-bin

This file was deleted.

45 changes: 45 additions & 0 deletions cgi-bin/all
@@ -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>'

39 changes: 39 additions & 0 deletions cgi-bin/relay
@@ -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>'

0 comments on commit 3481ade

Please sign in to comment.