after my modifications, web page will not load...
gourdo
Posts: 6
Hello--
First time poster and new spinneret/propeller user...I have tried to modify your code that is posted on http://spinneret.servebeer.com:5000/gstart/get.htm , and I do not get my local web page any more.
I ran through all Mike Gs instructions by the numbers, had it working until I added a servo and what I thought was the html adding a button for the servo (on/off)...
my code looks like :
PRI Dispatcher2(id)
''do some processing before sending the response
if(strcomp(Request.GetName(id), string("servo")))
Demo (id)
StaticFileHandler(id)
return
PRI Demo(id) | qstr
'' Get the query string value
qstr := Request.Get(id, string("servo"))
if (strcomp( string("on"), qstr ))
ServoStatus(1)
else
ServoStatus(0)
return
PRI ServoStatus(state)
cognew(MoveMotor(26),@StackSpace4) 'Start a new cog and run the MoveMotor method on it that outputs pulses on Pin 7
'The new cog that is started above continuously reads the "position" variable as it's changed by the example Spin code below
repeat
position:=100 'Start sending 1ms servo signal high pulses (100 * 10us = 1ms)
waitcnt(clkfreq+cnt) 'Wait for 1 second (1ms high pulses continue to be generated by the other cog)
position:=138 'Start sending 1.38ms servo signal high pulses (Center position)
waitcnt(clkfreq+cnt) 'Wait for 1 second (1.38ms high pulses continue to be generated by the other cog)
position:=50 'Start sending 0.5ms servo signal high pulses (Clockwise position)
waitcnt(clkfreq+cnt) 'Wait for 1 second (0.5ms high pulses continue to be generated by the other cog)
position:=225 'Start sending 2.25ms servo signal high pulses (Counterclockwise position)
waitcnt(clkfreq+cnt)
return
PUB MoveMotor(Pin) 'This method outputs a continuous stream of servo signal pulses on "Pin"
dira[Pin]~~ 'Set the direction of "Pin" to be an output
repeat 'Send out a continous train of pulses
outa[Pin]~~ 'Set "Pin" High
waitcnt((clkfreq/100_000)*position+cnt) 'Wait for the specifed position (units = 10 microseconds)
outa[Pin]~ 'Set "Pin" Low
waitcnt(clkfreq/100+cnt) 'Wait 10ms between pulses
...the rest of the code is using exactly what Mike had; I did add the requisite StackSpace for the new cogs, the variables, etc....the code loaded on to the Spinneret, I kept the index.htm page as is, then I modified the led.htm web page to look like:
<html>
<head>
<title>GETing to the Server</title>
</head>
<body>
<div style="width:600px;margin:auto;">
<h1 style="text-align:center;color:blue;">LED</h1>
<div style="text-align:center;"><a href="index.htm">Hello World</a> | <a href="led.htm">LED</a></div>
<p><a href="led.htm?led=on">LED On</a> :: <a href="led.htm?led=off">LED Off</a></p>
<p>LED: <span id="placeholder"></span></p>
<p><a href="led.htm?servo=on">SERVO On</a> :: <a href="led.htm?SERVO=off">SERVO Off</a></p>
<p>LED: <span id="placeholder"></span></p>
</div>
</div>
</body>
</html>
All the networking pieces worked fine, got the web page, turned on the led via the web server, then I did the above mods and all is no go. I get this message:
The connection was reset
The connection to the server was reset while the page was loading.
Please help!
Even with my mods, I get the following on PST:
Mount SD Card - OK
Start RTC: 01/04/2000 10:40:43
W5100 Driver Started
Status Memory Lock ID : 1
HTTP Server Lock ID : 2
TCP Socket Listener ID : 0
TCP Socket Listener ID : 1
TCP Socket Listener ID : 2
TCP Socket Listener ID : 3
Started Socket Monitoring Service
Initial Socket States
3-14 2-14 1-14 0-14
clsd open lstn estb clwt clng udps
0000-0000-1111-0000-0000-0000-0000
Initial Socket Queue
FIFO[0] 00000000
//////////////////////////////////////////////////////////////
First time poster and new spinneret/propeller user...I have tried to modify your code that is posted on http://spinneret.servebeer.com:5000/gstart/get.htm , and I do not get my local web page any more.
I ran through all Mike Gs instructions by the numbers, had it working until I added a servo and what I thought was the html adding a button for the servo (on/off)...
my code looks like :
PRI Dispatcher2(id)
''do some processing before sending the response
if(strcomp(Request.GetName(id), string("servo")))
Demo (id)
StaticFileHandler(id)
return
PRI Demo(id) | qstr
'' Get the query string value
qstr := Request.Get(id, string("servo"))
if (strcomp( string("on"), qstr ))
ServoStatus(1)
else
ServoStatus(0)
return
PRI ServoStatus(state)
cognew(MoveMotor(26),@StackSpace4) 'Start a new cog and run the MoveMotor method on it that outputs pulses on Pin 7
'The new cog that is started above continuously reads the "position" variable as it's changed by the example Spin code below
repeat
position:=100 'Start sending 1ms servo signal high pulses (100 * 10us = 1ms)
waitcnt(clkfreq+cnt) 'Wait for 1 second (1ms high pulses continue to be generated by the other cog)
position:=138 'Start sending 1.38ms servo signal high pulses (Center position)
waitcnt(clkfreq+cnt) 'Wait for 1 second (1.38ms high pulses continue to be generated by the other cog)
position:=50 'Start sending 0.5ms servo signal high pulses (Clockwise position)
waitcnt(clkfreq+cnt) 'Wait for 1 second (0.5ms high pulses continue to be generated by the other cog)
position:=225 'Start sending 2.25ms servo signal high pulses (Counterclockwise position)
waitcnt(clkfreq+cnt)
return
PUB MoveMotor(Pin) 'This method outputs a continuous stream of servo signal pulses on "Pin"
dira[Pin]~~ 'Set the direction of "Pin" to be an output
repeat 'Send out a continous train of pulses
outa[Pin]~~ 'Set "Pin" High
waitcnt((clkfreq/100_000)*position+cnt) 'Wait for the specifed position (units = 10 microseconds)
outa[Pin]~ 'Set "Pin" Low
waitcnt(clkfreq/100+cnt) 'Wait 10ms between pulses
...the rest of the code is using exactly what Mike had; I did add the requisite StackSpace for the new cogs, the variables, etc....the code loaded on to the Spinneret, I kept the index.htm page as is, then I modified the led.htm web page to look like:
<html>
<head>
<title>GETing to the Server</title>
</head>
<body>
<div style="width:600px;margin:auto;">
<h1 style="text-align:center;color:blue;">LED</h1>
<div style="text-align:center;"><a href="index.htm">Hello World</a> | <a href="led.htm">LED</a></div>
<p><a href="led.htm?led=on">LED On</a> :: <a href="led.htm?led=off">LED Off</a></p>
<p>LED: <span id="placeholder"></span></p>
<p><a href="led.htm?servo=on">SERVO On</a> :: <a href="led.htm?SERVO=off">SERVO Off</a></p>
<p>LED: <span id="placeholder"></span></p>
</div>
</div>
</body>
</html>
All the networking pieces worked fine, got the web page, turned on the led via the web server, then I did the above mods and all is no go. I get this message:
The connection was reset
The connection to the server was reset while the page was loading.
Please help!
Even with my mods, I get the following on PST:
Mount SD Card - OK
Start RTC: 01/04/2000 10:40:43
W5100 Driver Started
Status Memory Lock ID : 1
HTTP Server Lock ID : 2
TCP Socket Listener ID : 0
TCP Socket Listener ID : 1
TCP Socket Listener ID : 2
TCP Socket Listener ID : 3
Started Socket Monitoring Service
Initial Socket States
3-14 2-14 1-14 0-14
clsd open lstn estb clwt clng udps
0000-0000-1111-0000-0000-0000-0000
Initial Socket Queue
FIFO[0] 00000000
//////////////////////////////////////////////////////////////
Comments
This section of code is looking for a file named servo. Did you change the name of Led.htm to servo.htm or create a file named servo.htm? If not, Dispatcher2 will return without sending a response to the browser. The socket will close and browser will complain.
This code block takes several seconds to complete which might cause a timeout. Plus it invokes a new COG service on each request. I would start the servo service when the web server starts. Change the logic so setting the position variable to something other than, say, -1 will output a PWM control signal.
Mike--Thanks for your help--- to the above, I had written " <p><a href="led.htm?servo=on">SERVO On</a> :: <a href="led.htm?SERVO=off">SERVO Off</a></p> "
Is that part correct (the html section)?
I'll work on the rest of your suggestions now that I am home from work....
I'm not sure... This section of code is looking for a file named servo.htm. Do you have a file name servo.htm on the SD card?
This is a bug in your code as posted on the forum.
Makes perfect sense now. I'll probably get to this over the weekend. Sounds like I'll just create another web page called servo.htm, and for now call it good. Later on I'll figure out how to add multiple bottons on one page controlling multiple functions..... Wanted to thank you either way.