Web interface works! Horray! Key was to prevent lwip requesting pages when

RepRap was still serving the one before.
This commit is contained in:
Adrian Bowyer 2013-10-07 17:16:21 +01:00
parent 0bd51c6582
commit 368523e3e9
5 changed files with 35 additions and 17 deletions

View file

@ -747,6 +747,11 @@ void RepRapNetworkAllowWriting()
reprap.GetPlatform()->GetNetwork()->SetWriteEnable(true);
}
bool RepRapNetworkHasALiveClient()
{
return reprap.GetPlatform()->GetNetwork()->Status() & clientLive;
}
}
@ -777,15 +782,8 @@ void Network::Reset()
status = nothing;
}
void Network::Init()
void Network::CleanRing()
{
alternateInput = NULL;
alternateOutput = NULL;
init_ethernet();
Reset();
// Clean out the ring buffer.
for(int8_t i = 0; i <= HTTP_STATE_SIZE; i++)
{
netRingGetPointer->Free();
@ -794,6 +792,15 @@ void Network::Init()
netRingAddPointer = netRingGetPointer;
}
void Network::Init()
{
alternateInput = NULL;
alternateOutput = NULL;
init_ethernet();
CleanRing();
Reset();
}
// Webserver calls this to read bytes that have come in from the network
bool Network::Read(char& b)

View file

@ -295,6 +295,7 @@ protected:
private:
void Reset();
void CleanRing();
char* inputBuffer;
char outputBuffer[STRING_LENGTH];
int inputPointer;

View file

@ -1,8 +1,8 @@
<!DOCTYPE HTML>
<head>
<!-- <link rel="shortcut icon" href="https://github.com/reprappro/RepRapFirmware/raw/due/SD-image/www/favicon.ico" /> -->
<link rel="shortcut icon" href="favicon.ico" />
<link rel="shortcut icon" href="https://github.com/reprappro/RepRapFirmware/raw/due/SD-image/www/favicon.ico" />
<!-- <link rel="shortcut icon" href="favicon.ico" /> -->
<style type="text/css">
.pages
@ -71,13 +71,14 @@ td { text-align: center; }
<html>
<!--
<script src="http://reprappro.com/scripts/jquery.js" type="application/javascript"></script>
<script src="http://reprappro.com/scripts/knockout.js" type="application/javascript"></script>
-->
<!--
<script src="jquery.js" type="application/javascript"></script>
<script src="knockout.js" type="application/javascript"></script>
-->
<script>
function jogRowHTML(axis)

View file

@ -655,11 +655,11 @@ Webserver::Webserver(Platform* p)
{
platform = p;
active = false;
gotPassword = false;
}
void Webserver::Init()
{
char scratchString[STRING_LENGTH];
lastTime = platform->Time();
writing = false;
receivingPost = false;
@ -673,7 +673,7 @@ void Webserver::Init()
clientRequest[0] = 0;
password = DEFAULT_PASSWORD;
myName = DEFAULT_NAME;
gotPassword = false;
//gotPassword = false;
gcodeAvailable = false;
gcodePointer = 0;
InitialisePost();

View file

@ -75,6 +75,7 @@ void RepRapNetworkInputBufferReleased(void* pbuf);
void RepRapNetworkHttpStateReleased(void* h);
void RepRapNetworkMessage(char* s);
void RepRapNetworkAllowWriting();
bool RepRapNetworkHasALiveClient();
// Sanity check on initialisations.
@ -91,7 +92,7 @@ conn_err(void *arg, err_t err)
hs = arg;
mem_free(hs);
RepRapNetworkHttpStateReleased(hs);
//RepRapNetworkHttpStateReleased(hs);
RepRapNetworkMessage("Network connection error.\n");
}
/*-----------------------------------------------------------------------------------*/
@ -131,7 +132,7 @@ send_data(struct tcp_pcb *pcb, struct http_state *hs)
RepRapNetworkMessage("..");
do {
err = tcp_write(pcb, hs->file, len, 0);
err = tcp_write(pcb, hs->file, len, 0); // Final arg - 1 means make a copy
if (err == ERR_MEM) {
len /= 2;
}
@ -142,6 +143,8 @@ send_data(struct tcp_pcb *pcb, struct http_state *hs)
tcp_output(pcb);
hs->file += len;
hs->left -= len;
//if(hs->left <= 0)
// RepRapNetworkAllowWriting();
} else
{
RepRapNetworkMessage("send_data: error\n");
@ -281,6 +284,12 @@ http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
struct http_state *hs;
// This is a bit nasty. Fake an out of memory error to prevent new page
// requests coming in while we are still sending the old ones.
if(RepRapNetworkHasALiveClient())
return ERR_MEM;
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);