CGI application for web servo control

User projects written in or related to FreeBASIC.
zoomkat
Posts: 15
Joined: Apr 08, 2007 22:31

CGI application for web servo control

Postby zoomkat » Apr 09, 2007 3:45

Below is an update on my tinkering with freebasic making a cgi application for use with the Linxmotion ssc-32 servo controller for control of servos over the web. I compiled it and put in the apache cgi-bin folder. I currently don't have an ssc-32 to test with, so I have to connect the serial port tx/rx lines together for a loopback test setup. It seems to work as desired. As the # character (required for the controller) doesn't travel well in query_string, I substituted a - for it, then convert the - into # before sending the string out the serial port. For web use, one would mke a page with two frames, one for a streaming webcam video, and the other for controls and data return from the ssc. Below is the type of info that would be sent to the web server.

http://127.0.0.1/cgi-bin/cgi3.exe?-5P16 ... P2250T2000

Code: Select all

Dim As String qs, dat
Dim idx As Integer

qs = Environ("QUERY_STRING")
if qs = "" goto nodata

again:
  idx = Instr(qs, "-")
  Mid(qs, idx, 1) = "#"
  if idx > 0 goto again

qs = qs + Chr(13)

Open Com "COM1: 9600,N,8,1,BIN,CD,CS,DS,RS" For Binary As #1
Put #1,, qs
Sleep 200
dat = Input$(loc(1), #1)
Close #1

if dat = "" goto nodata
if dat <> "" goto gotdata

nodata:
Print "status: 204"
Print
Print
goto fini

gotdata:
Print "Content-type: text/html"
Print
print "<html><body>"
Print dat
Print "</body></html>"
goto fini

fini:
end

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 6 guests