A couple of tidyings and additions:

1. Z home now moves home, rather than just setting the coordinate.
2. Wait for temps implemented.

Also the JSON requests for the g code filelist has been temporarily commented
out in reprap.htm.  It was causing the firmware to hang sometimes.  To be investigated.

Machine now prints nicely...
This commit is contained in:
Adrian Bowyer 2013-10-22 18:27:12 +01:00
parent 3c901fb194
commit 708822a54e
12 changed files with 164 additions and 572 deletions

View file

@ -34,6 +34,9 @@ Licence: GPL
#define HEAT_SAMPLE_TIME 0.5 // Seconds
#define TEMPERATURE_CLOSE_ENOUGH 5.0 // Celsius
#define TEMPERATURE_LOW_SO_DONT_CARE 40.0 // Celsius
#define STANDBY_INTERRUPT_RATE 2.0e-4 // Seconds
#define NUMBER_OF_PROBE_POINTS 3

View file

@ -58,6 +58,7 @@ void GCodes::Init()
homeX = false;
homeY = false;
homeZ = false;
homeZFinalMove = false;
// homeXQueued = false;
// homeYQueued = false;
// homeZQueued = false;
@ -284,13 +285,15 @@ bool GCodes::DoHome()
float moveToDo[DRIVES+1];
bool action[DRIVES+1];
for(int8_t drive = 0; drive <= DRIVES; drive++)
for(int8_t drive = 0; drive < DRIVES; drive++)
action[drive] = false;
action[DRIVES] = true;
if(homeX)
{
action[X_AXIS] = true;
moveToDo[X_AXIS] = -2.0*platform->AxisLength(X_AXIS);
moveToDo[DRIVES] = platform->HomeFeedRate(X_AXIS)*0.016666667;
if(DoCannedCycleMove(moveToDo, action, true))
{
homeX = false;
@ -303,6 +306,7 @@ bool GCodes::DoHome()
{
action[Y_AXIS] = true;
moveToDo[Y_AXIS] = -2.0*platform->AxisLength(Y_AXIS);
moveToDo[DRIVES] = platform->HomeFeedRate(Y_AXIS)*0.016666667;
if(DoCannedCycleMove(moveToDo, action, true))
{
homeY = false;
@ -314,13 +318,24 @@ bool GCodes::DoHome()
if(homeZ)
{
action[Z_AXIS] = true;
moveToDo[Z_AXIS] = -2.0*platform->AxisLength(Z_AXIS);
if(DoCannedCycleMove(moveToDo, action, true))
moveToDo[DRIVES] = platform->HomeFeedRate(Z_AXIS)*0.016666667;
if(homeZFinalMove)
{
homeZ = false;
return NoHome();
moveToDo[Z_AXIS] = 0.0;
if(DoCannedCycleMove(moveToDo, action, false))
{
homeZFinalMove = false;
homeZ = false;
return NoHome();
}
return false;
}else
{
moveToDo[Z_AXIS] = -2.0*platform->AxisLength(Z_AXIS);
if(DoCannedCycleMove(moveToDo, action, true))
homeZFinalMove = true;
return false;
}
return false;
}
// Should never get here
@ -708,6 +723,10 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
drivesRelative = true;
break;
case 84:
platform->Message(HOST_MESSAGE, "Motors off received\n");
break;
case 92: // Set steps/mm for each axis
if(reprap.debug())
platform->GetLine()->Write("Steps/mm: ");
@ -752,7 +771,9 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
break;
case 116: // Wait for everything
platform->Message(HOST_MESSAGE, "Wait for all temperatures received\n");
if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
return false;
result = reprap.GetHeat()->AllHeatersAtSetTemperatures();
break;
case 111: // Debug level
@ -813,7 +834,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
}else{
value = -1;
}
float accel = platform->Acceleration(i,value);
float accel = platform->Acceleration(i, value);
if(reprap.debug())
{
platform->GetLine()->Write(gCodeLetters[i]);
@ -824,6 +845,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
if(reprap.debug())
platform->GetLine()->Write("\n");
break;
case 906: // Motor currents
for(uint8_t i = 0; i < DRIVES; i++)
{

View file

@ -118,6 +118,7 @@ class GCodes
bool homeX;
bool homeY;
bool homeZ;
bool homeZFinalMove;
// bool homeXQueued;
// bool homeYQueued;
// bool homeZQueued;
@ -161,7 +162,7 @@ inline bool GCodes::PrintingAFile()
inline bool GCodes::NoHome()
{
return !(homeX || homeY || homeZ);
return !(homeX || homeY || homeZ || homeZFinalMove);
}
// This function takes care of the fact that the heater and head indices

56
Heat.h
View file

@ -29,9 +29,12 @@ class PID
void Init();
void Spin();
void SetActiveTemperature(const float& t);
float GetActiveTemperature();
void SetStandbyTemperature(const float& t);
float GetStandbyTemperature();
void Activate();
void Standby();
bool Active();
float GetTemperature();
private:
@ -57,10 +60,13 @@ class Heat
void Init();
void Exit();
void SetActiveTemperature(int8_t heater, const float& t);
float GetActiveTemperature(int8_t heater);
void SetStandbyTemperature(int8_t heater, const float& t);
float GetStandbyTemperature(int8_t heater);
void Activate(int8_t heater);
void Standby(int8_t heater);
float GetTemperature(int8_t heater);
bool AllHeatersAtSetTemperatures();
void Diagnostics();
private:
@ -75,16 +81,31 @@ class Heat
//***********************************************************************************************************
inline bool PID::Active()
{
return active;
}
inline void PID::SetActiveTemperature(const float& t)
{
activeTemperature = t;
}
inline float PID::GetActiveTemperature()
{
return activeTemperature;
}
inline void PID::SetStandbyTemperature(const float& t)
{
standbyTemperature = t;
}
inline float PID::GetStandbyTemperature()
{
return standbyTemperature;
}
inline float PID::GetTemperature()
{
return temperature;
@ -105,11 +126,21 @@ inline void Heat::SetActiveTemperature(int8_t heater, const float& t)
pids[heater]->SetActiveTemperature(t);
}
inline float Heat::GetActiveTemperature(int8_t heater)
{
return pids[heater]->GetActiveTemperature();
}
inline void Heat::SetStandbyTemperature(int8_t heater, const float& t)
{
pids[heater]->SetStandbyTemperature(t);
}
inline float Heat::GetStandbyTemperature(int8_t heater)
{
return pids[heater]->GetStandbyTemperature();
}
inline float Heat::GetTemperature(int8_t heater)
{
return pids[heater]->GetTemperature();
@ -125,4 +156,29 @@ inline void Heat::Standby(int8_t heater)
pids[heater]->Standby();
}
inline bool Heat::AllHeatersAtSetTemperatures()
{
float dt;
for(int8_t heater = 0; heater < HEATERS; heater++)
{
dt = GetTemperature(heater);
if(pids[heater]->Active())
{
if(GetActiveTemperature(heater) < TEMPERATURE_LOW_SO_DONT_CARE)
dt = 0;
else
dt = fabs(dt - GetActiveTemperature(heater));
} else
{
if(GetStandbyTemperature(heater) < TEMPERATURE_LOW_SO_DONT_CARE)
dt = 0;
else
dt = fabs(dt - GetStandbyTemperature(heater));
}
if(dt > TEMPERATURE_CLOSE_ENOUGH)
return false;
}
return true;
}
#endif

View file

@ -249,6 +249,21 @@ void Platform::Diagnostics()
Message(HOST_MESSAGE, "Platform Diagnostics:\n");
}
//extern int __bss_end; // void? long?
//extern void *__brkval;
//
//long Platform::GetFreeMemory()
//{
// long free_memory;
//
// if((long)__brkval == 0)
// free_memory = ((long)&free_memory) - ((long)&__bss_end);
// else
// free_memory = ((long)&free_memory) - ((long)__brkval);
//
// return free_memory;
//}
//===========================================================================
//=============================Thermal Settings ============================
@ -351,6 +366,7 @@ void MassStorage::Init()
{
//platform->Message(HOST_MESSAGE, "Please plug in the SD card.\n");
//delay(1000);
sdPresentCount++;
}
if(sdPresentCount >= 5)
@ -883,6 +899,34 @@ void Network::Init()
Reset();
}
void Network::Spin()
{
// Keep the Ethernet running
ethernet_task();
// Anything come in from the network to act on?
if(!netRingGetPointer->Active())
return;
// Finished reading the active ring element?
if(!netRingGetPointer->ReadFinished())
{
// No - Finish reading any data that's been received.
if(inputPointer < inputLength)
return;
// Haven't started reading it yet - set that up.
inputPointer = 0;
inputLength = netRingGetPointer->Length();
inputBuffer = netRingGetPointer->Data();
}
}
// Webserver calls this to read bytes that have come in from the network
bool Network::Read(char& b)
@ -891,7 +935,7 @@ bool Network::Read(char& b)
{
inputLength = -1;
inputPointer = 0;
netRingGetPointer->SetRead();
netRingGetPointer->SetReadFinished(); // Past tense...
SetWriteEnable(true);
//reprap.GetPlatform()->Message(HOST_MESSAGE, "Network - data read.\n");
return false;
@ -935,33 +979,7 @@ void Network::Write(char b)
}
void Network::Spin()
{
// Keep the Ethernet running
ethernet_task();
// Anything come in from the network to act on?
if(!netRingGetPointer->Active())
return;
// Finished reading the active ring element?
if(!netRingGetPointer->Read())
{
// No - Finish reading any data that's been received.
if(inputPointer < inputLength)
return;
// Haven't started reading it yet - set that up.
inputPointer = 0;
inputLength = netRingGetPointer->Length();
inputBuffer = netRingGetPointer->Data();
}
}
void Network::InputBufferReleased(void* pb)
{
@ -1104,12 +1122,12 @@ int NetRing::Length()
return length;
}
bool NetRing::Read()
bool NetRing::ReadFinished()
{
return read;
}
void NetRing::SetRead()
void NetRing::SetReadFinished()
{
read = true;
}

View file

@ -238,8 +238,8 @@ protected:
bool Set(char* d, int l, void* pb, void* pc, void* h);
char* Data();
int Length();
bool Read();
void SetRead();
bool ReadFinished();
void SetReadFinished();
void* Pbuf();
void* Pcb();
void* Hs();
@ -408,6 +408,8 @@ class Platform
void Diagnostics();
// long GetFreeMemory();
// Timing
float Time(); // Returns elapsed seconds since some arbitrary time

View file

@ -178,6 +178,9 @@ void RepRap::Init()
active = true;
gCodes->RunConfigurationGCodes();
platform->Message(HOST_MESSAGE, "RepRapPro RepRap Firmware (Re)Started\n");
// platform->Message(HOST_MESSAGE, "Free memory: ");
// sprintf(scratchString,"%d\n",platform->GetFreeMemory());
// platform->Message(HOST_MESSAGE, scratchString);
}
void RepRap::Exit()

View file

@ -16,14 +16,22 @@
; infill extrusion width = 0.80mm
; first layer extrusion width = 0.48mm
M107
M104 S205 ; set temperature
G28 ; home all axes
G1 Z5 F200 ; lift nozzle
M109 S205 ; wait for temperature to be reached
G90 ; use absolute coordinates
G21 ; set units to millimeters
G90 ; use absolute coordinates
M83 ; use relative distances for extrusion
M107
G10 P0 S205 R205 ; Set extruder temperature
T0
M140 S55; Set bed temperature
G1 Z5 F200 ; lift nozzle
G28 X0 Y0; home X and Y axes
G1 X30 Y30 F2000
G28 Z0
G1 Z0 F200
G32 ; Probe bed
G1 X0 Y0 F2000
G1 Z0 F200
M116; Wait for all temperatures
G1 F1800.000 E-2.00000
G1 Z0.240 F3600.000
G1 X68.609 Y91.575
@ -7584,8 +7592,8 @@ G1 X72.284 Y102.512 E0.02412
G1 X72.512 Y102.283 E0.01333
G1 F1800.000 E-2.00000
M107
M104 S0 ; turn off temperature
G10 P0 S0 R0; Turn off heater
M140 S0
G28 X2 Y180 ; home X axis
G1 X2 Y180 ;
M84 ; disable motors
; filament used = 1425.9mm (3.4cm3)

View file

@ -6,7 +6,7 @@ G90 ; Absolute positioning
M83 ; Extrusion relative
M107; Fan off
G31 Z0.7 P400 ; Set Z probe height and threshold
M906 X1200 Y1200 Z1200 E1200 ; Motor currents (mA)
M906 X400 Y400 Z400 E400 ; Motor currents (mA)
M201 X4000 Y4000 E4000 ; Accelerations (mms-2)
T0 ; Extruder 0

View file

@ -335,7 +335,7 @@ function viewModel()
self.fileList = function()
{
$.get('/rr_files', {}, self.files);
//$.get('/rr_files', {}, self.files);
};
self.getTemps = function()

View file

@ -1,521 +0,0 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#if 0
#include "lwipopts.h"
#if defined(HTTP_RAW_USED)
#include <string.h>
#include "lwip/src/include/lwip/debug.h"
#include "lwip/src/include/lwip/stats.h"
#include "httpd.h"
#include "lwip/src/include/lwip/tcp.h"
#include "fs.h"
struct http_state {
char *file;
uint16_t left;
uint8_t retries;
};
/*-----------------------------------------------------------------------------------*/
//static void
//send_data(struct tcp_pcb *pcb, struct http_state *hs)
//{
// err_t err;
// uint16_t len;
// int i;
//
//// if(hs->left <= 0)
//// {
//// hs->left = GetRepRapNetworkDataToSendLength();
//// hs->file = GetRepRapNetworkDataToSend();
//// }
//
// /* We cannot send more data than space available in the send
// buffer. */
// if (tcp_sndbuf(pcb) < hs->left) {
// len = tcp_sndbuf(pcb);
// } else {
// len = hs->left;
// }
//
// do {
// err = tcp_write(pcb, hs->file, len, 0);
// if (err == ERR_MEM) {
// len /= 2;
// }
// } while (err == ERR_MEM && len > 1);
//
// if (err == ERR_OK) {
// hs->file += len;
// hs->left -= len;
// /* } else {
// printf("send_data: error %s len %d %d\n", lwip_strerr(err), len, tcp_sndbuf(pcb));*/
// }
//}
/*-----------------------------------------------------------------------------------*/
static void
conn_err(void *arg, err_t err)
{
struct http_state *hs;
LWIP_UNUSED_ARG(err);
hs = arg;
mem_free(hs);
}
/*-----------------------------------------------------------------------------------*/
static void
close_conn(struct tcp_pcb *pcb, struct http_state *hs)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
mem_free(hs);
tcp_close(pcb);
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_poll(void *arg, struct tcp_pcb *pcb)
{
struct http_state *hs;
hs = arg;
/* printf("Polll\n");*/
if (hs == NULL) {
/* printf("Null, close\n");*/
tcp_abort(pcb);
return ERR_ABRT;
} else {
++hs->retries;
if (hs->retries == 4) {
tcp_abort(pcb);
return ERR_ABRT;
}
send_data(pcb, hs);
}
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
//static err_t
//http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
//{
// int i;
// char *data;
// struct fs_file file;
// struct http_state *hs;
//
// hs = arg;
//
// if (err == ERR_OK && p != NULL)
// {
//
// /* Inform TCP that we have taken the data. */
// tcp_recved(pcb, p->tot_len);
//
// if (hs->file == NULL)
// {
// data = p->payload;
//
// if (strncmp(data, "GET ", 4) == 0)
// {
// for(i = 0; i < 40; i++) {
// if (((char *)data + 4)[i] == ' ' ||
// ((char *)data + 4)[i] == '\r' ||
// ((char *)data + 4)[i] == '\n')
// {
// ((char *)data + 4)[i] = 0;
// }
// }
//
// if (*(char *)(data + 4) == '/' && *(char *)(data + 5) == 0)
// {
// fs_open("/index.html", &file);
// } else if (!fs_open((char *)data + 4, &file))
// {
// fs_open("/404.html", &file);
// }
//
// hs->file = file.data;
// hs->left = file.len;
// /* printf("data %p len %ld\n", hs->file, hs->left);*/
//
// pbuf_free(p);
// send_data(pcb, hs);
//
// /* Tell TCP that we wish be to informed of data that has been
// successfully sent by a call to the http_sent() function. */
// tcp_sent(pcb, http_sent);
// } else
// {
// pbuf_free(p);
// close_conn(pcb, hs);
// }
// } else
// {
// pbuf_free(p);
// }
// }
//
// if (err == ERR_OK && p == NULL)
// {
// close_conn(pcb, hs);
// }
// return ERR_OK;
//}
static struct tcp_pcb* activePcb = 0;
static struct pbuf* activePbuf = 0;
static struct http_state* activeHttpState = 0;
static char* dataPayload = 0;
//static char outputBuffer[1200];
static int lastDataSentLength = 0;
int GetRepRapNetworkDataToSendLength();
char* GetRepRapNetworkDataToSend();
void RepRapNetworkMessage(char* s);
void RepRapNetworkReceiveInput(char* ip, int length);
void RepRapNetworkDataTransmitted(int length);
int SendBufferSize()
{
if(activePcb == 0)
return -1;
return tcp_sndbuf(activePcb);
}
static err_t DataHasGone(void *arg, struct tcp_pcb *pcb, uint16_t len)
{
RepRapNetworkDataTransmitted(len);
// struct http_state *hs;
//
// LWIP_UNUSED_ARG(len);
//
// hs = arg;
//
// activePcb = pcb;
// activeHttpState = hs;
//
// hs->retries = 0;
//
// if (hs->left > 0)
// {
// send_data(pcb, hs);
// } else
// SetDataToSend();
// if (hs->left <= 0)
// {
// CloseConnection();
// // close_conn(pcb, hs);
// }
return ERR_OK;
}
int SendData(char* data, int length)
{
if(activePcb == 0)
return -1;
int err = tcp_write(activePcb, data, length, 0);
lastDataSentLength = length;
tcp_sent(activePcb, DataHasGone);
return err;
}
//int SetDataToSend()
//{
// int i;
//
// if(activeHttpState == 0)
// return -1;
//
// if(activeHttpState->left > 0)
// return 0;
//
// activeHttpState->left = GetRepRapNetworkDataToSendLength();
// activeHttpState->file = outputBuffer;
//
// if(activeHttpState->left > 0)
// {
// i = 0;
// while(i < activeHttpState->left)
// {
// outputBuffer[i] = GetRepRapNetworkDataToSend()[i];
// i++;
// }
// outputBuffer[i] = 0;
// } else
// outputBuffer[0] = 0;
//
// return 1;
//}
static void FreeBuffer()
{
if(activePbuf != 0)
{
pbuf_free(activePbuf);
activePbuf = 0;
dataPayload = 0;
}
}
static void CloseConnection()
{
if(activePcb != 0 && activeHttpState != 0)
{
close_conn(activePcb, activeHttpState);
//activePcb = 0;
//activeHttpState = 0;
}
}
static void FreeBufferAndCloseConnection()
{
FreeBuffer();
CloseConnection();
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, uint16_t len)
{
struct http_state *hs;
LWIP_UNUSED_ARG(len);
hs = arg;
activePcb = pcb;
activeHttpState = hs;
hs->retries = 0;
if (hs->left > 0)
{
send_data(pcb, hs);
} else
SetDataToSend();
if (hs->left <= 0)
{
CloseConnection();
// close_conn(pcb, hs);
}
return ERR_OK;
}
//int HttpSend()
//{
// if(activePcb != 0 && activeHttpState != 0)
// {
// send_data(activePcb, activeHttpState);
//
// /* Tell TCP that we wish be to informed of data that has been
// successfully sent by a call to the http_sent() function. */
// tcp_sent(activePcb, http_sent);
// }
//}
//static int InterpretAndSend()
//{
// if(dataPayload == 0)
// return false;
//
// int i;
//
// struct fs_file file;
//
// if (strncmp(dataPayload, "GET ", 4) == 0)
// //if(GetRepRapNetworkDataToSendLength() > 0)
// {
// for(i = 0; i < 40; i++) {
// if (((char *)dataPayload + 4)[i] == ' ' ||
// ((char *)dataPayload + 4)[i] == '\r' ||
// ((char *)dataPayload + 4)[i] == '\n')
// {
// ((char *)dataPayload + 4)[i] = 0;
// }
// }
//
// if (*(char *)(dataPayload + 4) == '/' && *(char *)(dataPayload + 5) == 0)
// {
// fs_open("/index.html", &file);
// } else if (!fs_open((char *)dataPayload + 4, &file))
// {
// fs_open("/404.html", &file);
// }
//
// activeHttpState->file = file.data;
// activeHttpState->left = file.len;
//
// //activeHttpState->file = GetRepRapNetworkDataToSend();
// //activeHttpState->left = GetRepRapNetworkDataToSendLength();
//
// /* printf("data %p len %ld\n", hs->file, hs->left);*/
//
// //pbuf_free(p);
// FreeBuffer();
//// send_data(activePcb, activeHttpState);
////
//// /* Tell TCP that we wish be to informed of data that has been
//// successfully sent by a call to the http_sent() function. */
//// tcp_sent(activePcb, http_sent);
//
// //HttpSend();
// } else
// {
// FreeBufferAndCloseConnection();
// //pbuf_free(p);
// //close_conn(pcb, hs);
// }
// return true;
//}
static err_t
http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
int i;
char *data;
struct http_state *hs;
hs = arg;
activePcb = pcb;
activePbuf = p;
activeHttpState = hs;
if (err == ERR_OK && p != NULL)
{
/* Inform TCP that we have taken the data. */
tcp_recved(pcb, p->tot_len);
//if (hs->file == NULL)
//if(GetRepRapNetworkDataToSendLength() <= 0)
//{
data = p->payload;
dataPayload = data;
// Deal with data received
RepRapNetworkReceiveInput(data, p->len);
//InterpretAndSend();
//} /*else
//{
FreeBuffer();
//pbuf_free(p);
//}*/
//FreeBuffer();
}
// if (err == ERR_OK && p == NULL)
// {
// CloseConnection();
// //close_conn(pcb, hs);
// }
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
struct http_state *hs;
LWIP_UNUSED_ARG(arg);
LWIP_UNUSED_ARG(err);
tcp_setprio(pcb, TCP_PRIO_MIN);
/* Allocate memory for the structure that holds the state of the
connection. */
hs = (struct http_state *)mem_malloc(sizeof(struct http_state));
if (hs == NULL) {
//printf("http_accept: Out of memory\n");
return ERR_MEM;
}
/* Initialize the structure. */
hs->file = NULL;
hs->left = 0;
hs->retries = 0;
/* Tell TCP that this is the structure we wish to be passed for our
callbacks. */
tcp_arg(pcb, hs);
/* Tell TCP that we wish to be informed of incoming data by a call
to the http_recv() function. */
tcp_recv(pcb, http_recv);
tcp_err(pcb, conn_err);
tcp_poll(pcb, http_poll, 4);
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
void
httpd_init(void)
{
//struct tcp_pcb *pcb;
activePcb = tcp_new();
tcp_bind(activePcb, IP_ADDR_ANY, 80);
activePcb = tcp_listen(activePcb);
tcp_accept(activePcb, http_accept);
}
/*-----------------------------------------------------------------------------------*/
#endif
#endif

View file

@ -108,7 +108,7 @@ close_conn(struct tcp_pcb *pcb, struct http_state *hs)
tcp_close(pcb);
}
char scratch[40];
//char scratch[40];
/*-----------------------------------------------------------------------------------*/