Merge remote-tracking branch 'dc42/duet' into duet
This commit is contained in:
commit
e7afc883c2
9 changed files with 149 additions and 73 deletions
32
GCodes.cpp
32
GCodes.cpp
|
@ -111,8 +111,6 @@ void GCodes::Spin()
|
||||||
if(!active)
|
if(!active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char b;
|
|
||||||
|
|
||||||
// Check each of the sources of G Codes (web, serial, and file) to
|
// Check each of the sources of G Codes (web, serial, and file) to
|
||||||
// see if what they are doing has been done. If it hasn't, return without
|
// see if what they are doing has been done. If it hasn't, return without
|
||||||
// looking at anything else.
|
// looking at anything else.
|
||||||
|
@ -147,7 +145,7 @@ void GCodes::Spin()
|
||||||
|
|
||||||
if(webserver->GCodeAvailable())
|
if(webserver->GCodeAvailable())
|
||||||
{
|
{
|
||||||
b = webserver->ReadGCode();
|
char b = webserver->ReadGCode();
|
||||||
if(webGCode->Put(b))
|
if(webGCode->Put(b))
|
||||||
{
|
{
|
||||||
if(webGCode->WritingFileDirectory() != NULL)
|
if(webGCode->WritingFileDirectory() != NULL)
|
||||||
|
@ -166,6 +164,7 @@ void GCodes::Spin()
|
||||||
{
|
{
|
||||||
if(platform->GetLine()->Status() & byteAvailable)
|
if(platform->GetLine()->Status() & byteAvailable)
|
||||||
{
|
{
|
||||||
|
char b;
|
||||||
platform->GetLine()->Read(b);
|
platform->GetLine()->Read(b);
|
||||||
WriteHTMLToFile(b, serialGCode);
|
WriteHTMLToFile(b, serialGCode);
|
||||||
}
|
}
|
||||||
|
@ -175,14 +174,27 @@ void GCodes::Spin()
|
||||||
|
|
||||||
if(platform->GetLine()->Status() & byteAvailable)
|
if(platform->GetLine()->Status() & byteAvailable)
|
||||||
{
|
{
|
||||||
platform->GetLine()->Read(b);
|
// Read several bytes instead of just one. This is mainly to speed up file uploading.
|
||||||
if(serialGCode->Put(b))
|
int8_t i = 0;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
if(serialGCode->WritingFileDirectory() != NULL)
|
char b;
|
||||||
WriteGCodeToFile(serialGCode);
|
platform->GetLine()->Read(b);
|
||||||
else
|
if(serialGCode->Put(b)) // add char to buffer and test whether the gcode is complete
|
||||||
serialGCode->SetFinished(ActOnGcode(serialGCode));
|
{
|
||||||
}
|
// we have a complete gcode
|
||||||
|
if(serialGCode->WritingFileDirectory() != NULL)
|
||||||
|
{
|
||||||
|
WriteGCodeToFile(serialGCode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serialGCode->SetFinished(ActOnGcode(serialGCode));
|
||||||
|
}
|
||||||
|
break; // stop after receiving a complete gcode in case we haven't finished processing it
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
} while (i < 16 && (platform->GetLine()->Status() & byteAvailable));
|
||||||
platform->ClassReport("GCodes", longWait);
|
platform->ClassReport("GCodes", longWait);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
26
GCodes.h
26
GCodes.h
|
@ -41,9 +41,9 @@ class GCodeBuffer
|
||||||
char* GetUnprecedentedString();
|
char* GetUnprecedentedString();
|
||||||
char* GetString();
|
char* GetString();
|
||||||
char* Buffer();
|
char* Buffer();
|
||||||
bool Finished();
|
bool Finished() const;
|
||||||
void SetFinished(bool f);
|
void SetFinished(bool f);
|
||||||
char* WritingFileDirectory();
|
char* WritingFileDirectory() const;
|
||||||
void SetWritingFileDirectory(char* wfd);
|
void SetWritingFileDirectory(char* wfd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -75,8 +75,9 @@ class GCodes
|
||||||
void QueueFileToPrint(char* fileName);
|
void QueueFileToPrint(char* fileName);
|
||||||
bool GetProbeCoordinates(int count, float& x, float& y, float& z);
|
bool GetProbeCoordinates(int count, float& x, float& y, float& z);
|
||||||
char* GetCurrentCoordinates();
|
char* GetCurrentCoordinates();
|
||||||
bool PrintingAFile();
|
bool PrintingAFile() const;
|
||||||
void Diagnostics();
|
void Diagnostics();
|
||||||
|
bool HaveIncomingData() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ class GCodes
|
||||||
bool SetOffsets(GCodeBuffer *gb);
|
bool SetOffsets(GCodeBuffer *gb);
|
||||||
bool SetPositions(GCodeBuffer *gb);
|
bool SetPositions(GCodeBuffer *gb);
|
||||||
void LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92);
|
void LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92);
|
||||||
bool NoHome();
|
bool NoHome() const;
|
||||||
bool Push();
|
bool Push();
|
||||||
bool Pop();
|
bool Pop();
|
||||||
bool DisableDrives();
|
bool DisableDrives();
|
||||||
|
@ -110,7 +111,7 @@ class GCodes
|
||||||
void WriteHTMLToFile(char b, GCodeBuffer *gb);
|
void WriteHTMLToFile(char b, GCodeBuffer *gb);
|
||||||
bool OffsetAxes(GCodeBuffer *gb);
|
bool OffsetAxes(GCodeBuffer *gb);
|
||||||
|
|
||||||
int8_t Heater(int8_t head);
|
int8_t Heater(int8_t head) const;
|
||||||
Platform* platform;
|
Platform* platform;
|
||||||
bool active;
|
bool active;
|
||||||
Webserver* webserver;
|
Webserver* webserver;
|
||||||
|
@ -172,7 +173,7 @@ inline char* GCodeBuffer::Buffer()
|
||||||
return gcodeBuffer;
|
return gcodeBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GCodeBuffer::Finished()
|
inline bool GCodeBuffer::Finished() const
|
||||||
{
|
{
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ inline void GCodeBuffer::SetFinished(bool f)
|
||||||
finished = f;
|
finished = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char* GCodeBuffer::WritingFileDirectory()
|
inline char* GCodeBuffer::WritingFileDirectory() const
|
||||||
{
|
{
|
||||||
return writingFileDirectory;
|
return writingFileDirectory;
|
||||||
}
|
}
|
||||||
|
@ -192,12 +193,17 @@ inline void GCodeBuffer::SetWritingFileDirectory(char* wfd)
|
||||||
writingFileDirectory = wfd;
|
writingFileDirectory = wfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GCodes::PrintingAFile()
|
inline bool GCodes::PrintingAFile() const
|
||||||
{
|
{
|
||||||
return fileBeingPrinted != NULL;
|
return fileBeingPrinted != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GCodes::NoHome()
|
inline bool GCodes::HaveIncomingData() const
|
||||||
|
{
|
||||||
|
return fileBeingPrinted != NULL || webserver->GCodeAvailable() || (platform->GetLine()->Status() & byteAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool GCodes::NoHome() const
|
||||||
{
|
{
|
||||||
return !(homeX || homeY || homeZ || homeAxisMoveCount);
|
return !(homeX || homeY || homeZ || homeAxisMoveCount);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +211,7 @@ inline bool GCodes::NoHome()
|
||||||
// This function takes care of the fact that the heater and head indices
|
// This function takes care of the fact that the heater and head indices
|
||||||
// don't match because the bed is heater 0.
|
// don't match because the bed is heater 0.
|
||||||
|
|
||||||
inline int8_t GCodes::Heater(int8_t head)
|
inline int8_t GCodes::Heater(int8_t head) const
|
||||||
{
|
{
|
||||||
return head+1;
|
return head+1;
|
||||||
}
|
}
|
||||||
|
|
18
Move.cpp
18
Move.cpp
|
@ -441,7 +441,7 @@ void Move::DoLookAhead()
|
||||||
// or both to the maximum that can be achieved because of the requirements of
|
// or both to the maximum that can be achieved because of the requirements of
|
||||||
// the adjacent moves.
|
// the adjacent moves.
|
||||||
|
|
||||||
if(addNoMoreMoves || !gCodes->PrintingAFile() || lookAheadRingCount > LOOK_AHEAD)
|
if(addNoMoreMoves || !gCodes->HaveIncomingData() || lookAheadRingCount > LOOK_AHEAD)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Run up the moves
|
// Run up the moves
|
||||||
|
@ -497,7 +497,7 @@ void Move::DoLookAhead()
|
||||||
// If there are any new unprocessed moves in there, set their end speeds
|
// If there are any new unprocessed moves in there, set their end speeds
|
||||||
// according to the cosine of the angle between them.
|
// according to the cosine of the angle between them.
|
||||||
|
|
||||||
if(addNoMoreMoves || !gCodes->PrintingAFile() || lookAheadRingCount > 1)
|
if(addNoMoreMoves || !gCodes->HaveIncomingData() || lookAheadRingCount > 1)
|
||||||
{
|
{
|
||||||
n1 = lookAheadRingGetPointer;
|
n1 = lookAheadRingGetPointer;
|
||||||
n0 = n1->Previous();
|
n0 = n1->Previous();
|
||||||
|
@ -531,7 +531,7 @@ void Move::DoLookAhead()
|
||||||
|
|
||||||
// If we are just doing one isolated move, set its end velocity to InstantDv(Z_AXIS).
|
// If we are just doing one isolated move, set its end velocity to InstantDv(Z_AXIS).
|
||||||
|
|
||||||
if(addNoMoreMoves || !gCodes->PrintingAFile())
|
if(addNoMoreMoves || !gCodes->HaveIncomingData())
|
||||||
{
|
{
|
||||||
n1->SetV(platform->InstantDv(Z_AXIS));
|
n1->SetV(platform->InstantDv(Z_AXIS));
|
||||||
n1->SetProcessed(complete);
|
n1->SetProcessed(complete);
|
||||||
|
@ -988,18 +988,18 @@ MovementProfile DDA::Init(LookAhead* lookAhead, float& u, float& v)
|
||||||
} else // Must be extruders only
|
} else // Must be extruders only
|
||||||
SetEAcceleration(eDistance);
|
SetEAcceleration(eDistance);
|
||||||
|
|
||||||
// If we are going from an XY move to a Z move, u needs to be platform->InstantDv(Z_AXIS).
|
// If we are going from an XY move or extruder move to a Z move, u needs to be platform->InstantDv(Z_AXIS).
|
||||||
|
|
||||||
if((myLookAheadEntry->Previous()->GetMovementType() & xyMove) && (mt & zMove))
|
if((myLookAheadEntry->Previous()->GetMovementType() & (xyMove | eMove)) && (mt & zMove))
|
||||||
{
|
{
|
||||||
u = platform->InstantDv(Z_AXIS);
|
u = platform->InstantDv(Z_AXIS);
|
||||||
result = change;
|
result = change;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are going from a Z move to an XY move, v needs to be platform->InstantDv(Z_AXIS),
|
// if we are going from a Z move to an XY move or E move, v needs to be platform->InstantDv(Z_AXIS),
|
||||||
// as does instantDv.
|
// as does instantDv.
|
||||||
|
|
||||||
if((myLookAheadEntry->Previous()->GetMovementType() & zMove) && (mt & xyMove))
|
if((myLookAheadEntry->Previous()->GetMovementType() & zMove) && (mt & (xyMove | eMove)))
|
||||||
{
|
{
|
||||||
v = platform->InstantDv(Z_AXIS);
|
v = platform->InstantDv(Z_AXIS);
|
||||||
instantDv = v;
|
instantDv = v;
|
||||||
|
@ -1163,7 +1163,7 @@ void LookAhead::Init(long ep[], float f, float vv, bool ce, int8_t mt)
|
||||||
// are printing a file, so set processed
|
// are printing a file, so set processed
|
||||||
// complete when we aren't.
|
// complete when we aren't.
|
||||||
|
|
||||||
if(reprap.GetGCodes()->PrintingAFile())
|
if(reprap.GetGCodes()->HaveIncomingData())
|
||||||
processed = unprocessed;
|
processed = unprocessed;
|
||||||
else
|
else
|
||||||
processed = complete|vCosineSet|upPass;
|
processed = complete|vCosineSet|upPass;
|
||||||
|
@ -1198,7 +1198,7 @@ float LookAhead::Cosine()
|
||||||
|
|
||||||
if(a2 <= 0.0 || b2 <= 0.0)
|
if(a2 <= 0.0 || b2 <= 0.0)
|
||||||
{
|
{
|
||||||
cosine = 0.5; // Why not?
|
cosine = 0.0; // one of the moves is just an extruder move (probably a retraction), so orthogonal (in 4D space!) to XYZ moves
|
||||||
return cosine;
|
return cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
55
Platform.cpp
55
Platform.cpp
|
@ -310,7 +310,7 @@ void Platform::ClassReport(char* className, float &lastTime)
|
||||||
// should compute it for you (i.e. it won't need to be calculated at run time).
|
// should compute it for you (i.e. it won't need to be calculated at run time).
|
||||||
|
|
||||||
// If the A->D converter has a range of 0..1023 and the measured voltage is V (between 0 and 1023)
|
// If the A->D converter has a range of 0..1023 and the measured voltage is V (between 0 and 1023)
|
||||||
// then the thermistor resistance, R = V.RS/(1023 - V)
|
// then the thermistor resistance, R = V.RS/(1024 - V)
|
||||||
// and the temperature, T = BETA/ln(R/R_INF)
|
// and the temperature, T = BETA/ln(R/R_INF)
|
||||||
// To get degrees celsius (instead of kelvin) add -273.15 to T
|
// To get degrees celsius (instead of kelvin) add -273.15 to T
|
||||||
//#define THERMISTOR_R_INFS ( THERMISTOR_25_RS*exp(-THERMISTOR_BETAS/298.15) ) // Compute in Platform constructor
|
//#define THERMISTOR_R_INFS ( THERMISTOR_25_RS*exp(-THERMISTOR_BETAS/298.15) ) // Compute in Platform constructor
|
||||||
|
@ -319,8 +319,10 @@ void Platform::ClassReport(char* className, float &lastTime)
|
||||||
|
|
||||||
float Platform::GetTemperature(int8_t heater)
|
float Platform::GetTemperature(int8_t heater)
|
||||||
{
|
{
|
||||||
float r = (float)GetRawTemperature(heater);
|
// If the ADC reading is N then for an ideal ADC, the input voltage is at least N/(ADC_RANGE + 1) and less than (N + 1)/(ADC_RANGE + 1), times the analog reference.
|
||||||
return ABS_ZERO + thermistorBetas[heater]/log( (r*thermistorSeriesRs[heater]/(AD_RANGE - r))/thermistorInfRs[heater] );
|
// So we add 0.5 to to the reading to get a better estimate of the input. We don't care whether or not we get exactly zero with the thermistor disconnected.
|
||||||
|
float r = (float)GetRawTemperature(heater) + 0.5;
|
||||||
|
return ABS_ZERO + thermistorBetas[heater]/log( (r*thermistorSeriesRs[heater]/((AD_RANGE + 1) - r))/thermistorInfRs[heater] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -831,6 +833,8 @@ Line::Line()
|
||||||
|
|
||||||
void Line::Init()
|
void Line::Init()
|
||||||
{
|
{
|
||||||
|
getIndex = 0;
|
||||||
|
numChars = 0;
|
||||||
// alternateInput = NULL;
|
// alternateInput = NULL;
|
||||||
// alternateOutput = NULL;
|
// alternateOutput = NULL;
|
||||||
SerialUSB.begin(BAUD_RATE);
|
SerialUSB.begin(BAUD_RATE);
|
||||||
|
@ -862,9 +866,10 @@ void RepRapNetworkInputBufferReleased(void* pb)
|
||||||
reprap.GetPlatform()->GetNetwork()->InputBufferReleased(pb);
|
reprap.GetPlatform()->GetNetwork()->InputBufferReleased(pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepRapNetworkHttpStateReleased(void* h)
|
void RepRapNetworkConnectionError(void* h)
|
||||||
{
|
{
|
||||||
reprap.GetPlatform()->GetNetwork()->HttpStateReleased(h);
|
reprap.GetPlatform()->GetNetwork()->ConnectionError(h);
|
||||||
|
reprap.GetWebserver()->ConnectionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called to put out a message via the RepRap firmware.
|
// Called to put out a message via the RepRap firmware.
|
||||||
|
@ -1046,14 +1051,19 @@ void Network::InputBufferReleased(void* pb)
|
||||||
netRingGetPointer->ReleasePbuf();
|
netRingGetPointer->ReleasePbuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Network::HttpStateReleased(void* h)
|
void Network::ConnectionError(void* h)
|
||||||
{
|
{
|
||||||
if(netRingGetPointer->Hs() != h)
|
// h points to an http state block that the caller is about to release, so we need to stop referring to it.
|
||||||
|
// The state block is usually but not always in use by the current http request being processed, in which case we abandon the current request.
|
||||||
|
if (netRingGetPointer != netRingAddPointer && netRingGetPointer->Hs() == h)
|
||||||
{
|
{
|
||||||
reprap.GetPlatform()->Message(HOST_MESSAGE, "Network::HttpStateReleased() - Pointers don't match!\n");
|
netRingGetPointer->Free();
|
||||||
return;
|
netRingGetPointer = netRingGetPointer->Next();
|
||||||
}
|
}
|
||||||
netRingGetPointer->ReleaseHs();
|
|
||||||
|
// Reset the network layer. In particular, this clears the output buffer to make sure nothing more gets sent,
|
||||||
|
// and sets statue to 'nothing' so that we can accept another connection attempt.
|
||||||
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1072,7 +1082,7 @@ void Network::ReceiveInput(char* data, int length, void* pbuf, void* pcb, void*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Network::CanWrite()
|
bool Network::CanWrite() const
|
||||||
{
|
{
|
||||||
return writeEnabled;
|
return writeEnabled;
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1133,7 @@ void Network::Close()
|
||||||
//Reset();
|
//Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Network::Status()
|
int8_t Network::Status() const
|
||||||
{
|
{
|
||||||
if(inputPointer >= inputLength)
|
if(inputPointer >= inputLength)
|
||||||
return status;
|
return status;
|
||||||
|
@ -1222,6 +1232,27 @@ void NetRing::ReleaseHs()
|
||||||
hs = 0;
|
hs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Line::Spin()
|
||||||
|
{
|
||||||
|
// Read the serial data in blocks to avoid excessive flow control
|
||||||
|
if (numChars <= lineBufsize/2)
|
||||||
|
{
|
||||||
|
int16_t target = SerialUSB.available() + (int16_t)numChars;
|
||||||
|
if (target > lineBufsize)
|
||||||
|
{
|
||||||
|
target = lineBufsize;
|
||||||
|
}
|
||||||
|
while ((int16_t)numChars < target)
|
||||||
|
{
|
||||||
|
int incomingByte = SerialUSB.read();
|
||||||
|
if (incomingByte < 0) break;
|
||||||
|
buffer[(getIndex + numChars) % lineBufsize] = (char)incomingByte;
|
||||||
|
++numChars;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
44
Platform.h
44
Platform.h
|
@ -183,13 +183,15 @@ Licence: GPL
|
||||||
|
|
||||||
#define BAUD_RATE 115200 // Communication speed of the USB if needed.
|
#define BAUD_RATE 115200 // Communication speed of the USB if needed.
|
||||||
|
|
||||||
|
const uint16_t lineBufsize = 256; // use a power of 2 for good performance
|
||||||
|
|
||||||
/****************************************************************************************************/
|
/****************************************************************************************************/
|
||||||
|
|
||||||
enum EndStopHit
|
enum EndStopHit
|
||||||
{
|
{
|
||||||
noStop = 0,
|
noStop = 0, // no enstop hit
|
||||||
lowHit = 1,
|
lowHit = 1, // low switch hit, or Z-probe in use and above threshold
|
||||||
highHit = 2
|
highHit = 2 // high stop hit
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************************************************************************************/
|
/***************************************************************************************************/
|
||||||
|
@ -264,17 +266,17 @@ class Network //: public InputOutput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int8_t Status(); // Returns OR of IOStatus
|
int8_t Status() const; // Returns OR of IOStatus
|
||||||
bool Read(char& b);
|
bool Read(char& b);
|
||||||
bool CanWrite();
|
bool CanWrite() const;
|
||||||
void SetWriteEnable(bool enable);
|
void SetWriteEnable(bool enable);
|
||||||
void Write(char b);
|
void Write(char b);
|
||||||
void Write(char* s);
|
void Write(char* s);
|
||||||
void Close();
|
void Close();
|
||||||
void ReceiveInput(char* data, int length, void* pb, void* pc, void* h);
|
void ReceiveInput(char* data, int length, void* pb, void* pc, void* h);
|
||||||
void InputBufferReleased(void* pb);
|
void InputBufferReleased(void* pb);
|
||||||
void HttpStateReleased(void* h);
|
void ConnectionError(void* h);
|
||||||
bool Active();
|
bool Active() const;
|
||||||
bool LinkIsUp();
|
bool LinkIsUp();
|
||||||
|
|
||||||
friend class Platform;
|
friend class Platform;
|
||||||
|
@ -308,7 +310,7 @@ class Line //: public InputOutput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int8_t Status(); // Returns OR of IOStatus
|
int8_t Status() const; // Returns OR of IOStatus
|
||||||
int Read(char& b);
|
int Read(char& b);
|
||||||
void Write(char b);
|
void Write(char b);
|
||||||
void Write(char* s);
|
void Write(char* s);
|
||||||
|
@ -324,6 +326,9 @@ protected:
|
||||||
void Spin();
|
void Spin();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
char buffer[lineBufsize];
|
||||||
|
uint16_t getIndex;
|
||||||
|
uint16_t numChars;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MassStorage
|
class MassStorage
|
||||||
|
@ -979,18 +984,11 @@ inline Line* Platform::GetLine()
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Line::Spin()
|
inline int8_t Line::Status() const
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int8_t Line::Status()
|
|
||||||
{
|
{
|
||||||
// if(alternateInput != NULL)
|
// if(alternateInput != NULL)
|
||||||
// return alternateInput->Status();
|
// return alternateInput->Status();
|
||||||
|
return numChars == 0 ? nothing : byteAvailable;
|
||||||
if(SerialUSB.available() > 0)
|
|
||||||
return byteAvailable;
|
|
||||||
return nothing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Line::Read(char& b)
|
inline int Line::Read(char& b)
|
||||||
|
@ -998,11 +996,11 @@ inline int Line::Read(char& b)
|
||||||
// if(alternateInput != NULL)
|
// if(alternateInput != NULL)
|
||||||
// return alternateInput->Read(b);
|
// return alternateInput->Read(b);
|
||||||
|
|
||||||
int incomingByte = SerialUSB.read();
|
if (numChars == 0) return 0;
|
||||||
if(incomingByte < 0)
|
b = buffer[getIndex];
|
||||||
return 0;
|
getIndex = (getIndex + 1) % lineBufsize;
|
||||||
b = (char)incomingByte;
|
--numChars;
|
||||||
return true;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Line::Write(char b)
|
inline void Line::Write(char b)
|
||||||
|
@ -1046,7 +1044,7 @@ inline bool Network::LinkIsUp()
|
||||||
return status_link_up();
|
return status_link_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Network::Active()
|
inline bool Network::Active() const
|
||||||
{
|
{
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
BIN
Release/RepRapFirmware-dc42.bin
Normal file
BIN
Release/RepRapFirmware-dc42.bin
Normal file
Binary file not shown.
|
@ -137,7 +137,7 @@ bool Webserver::LoadGcodeBuffer(char* gc, bool convertWeb)
|
||||||
{
|
{
|
||||||
if(!platform->GetMassStorage()->Delete(platform->GetGCodeDir(), &gcodeBuffer[4]))
|
if(!platform->GetMassStorage()->Delete(platform->GetGCodeDir(), &gcodeBuffer[4]))
|
||||||
{
|
{
|
||||||
platform->Message(HOST_MESSAGE, "Unsuccsessful attempt to delete: ");
|
platform->Message(HOST_MESSAGE, "Unsuccessful attempt to delete: ");
|
||||||
platform->Message(HOST_MESSAGE, &gcodeBuffer[4]);
|
platform->Message(HOST_MESSAGE, &gcodeBuffer[4]);
|
||||||
platform->Message(HOST_MESSAGE, "\n");
|
platform->Message(HOST_MESSAGE, "\n");
|
||||||
}
|
}
|
||||||
|
@ -711,6 +711,30 @@ void Webserver::Init()
|
||||||
//platform->GetMassStorage()->Delete(platform->GetWebDir(), MESSAGE_FILE);
|
//platform->GetMassStorage()->Delete(platform->GetWebDir(), MESSAGE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is called when the connection has been lost.
|
||||||
|
// In particular, we must cancel any pending writes.
|
||||||
|
void Webserver::ConnectionError()
|
||||||
|
{
|
||||||
|
writing = false;
|
||||||
|
receivingPost = false;
|
||||||
|
postSeen = false;
|
||||||
|
getSeen = false;
|
||||||
|
jsonPointer = -1;
|
||||||
|
clientLineIsBlank = true;
|
||||||
|
needToCloseClient = false;
|
||||||
|
clientLinePointer = 0;
|
||||||
|
clientLine[0] = 0;
|
||||||
|
clientRequest[0] = 0;
|
||||||
|
gotPassword = false;
|
||||||
|
gcodeAvailable = false;
|
||||||
|
gcodePointer = 0;
|
||||||
|
InitialisePost();
|
||||||
|
lastTime = platform->Time();
|
||||||
|
longWait = lastTime;
|
||||||
|
active = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Webserver::Exit()
|
void Webserver::Exit()
|
||||||
{
|
{
|
||||||
platform->Message(HOST_MESSAGE, "Webserver class exited.\n");
|
platform->Message(HOST_MESSAGE, "Webserver class exited.\n");
|
||||||
|
|
|
@ -50,6 +50,7 @@ class Webserver
|
||||||
void Diagnostics();
|
void Diagnostics();
|
||||||
void SetPassword(char* pw);
|
void SetPassword(char* pw);
|
||||||
void SetName(char* nm);
|
void SetName(char* nm);
|
||||||
|
void ConnectionError();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct http_state {
|
||||||
|
|
||||||
void RepRapNetworkReceiveInput(char* ip, int length, void* pbuf, void* pcb, void* hs);
|
void RepRapNetworkReceiveInput(char* ip, int length, void* pbuf, void* pcb, void* hs);
|
||||||
void RepRapNetworkInputBufferReleased(void* pbuf);
|
void RepRapNetworkInputBufferReleased(void* pbuf);
|
||||||
void RepRapNetworkHttpStateReleased(void* h);
|
void RepRapNetworkConnectionError(void* h);
|
||||||
void RepRapNetworkMessage(char* s);
|
void RepRapNetworkMessage(char* s);
|
||||||
void RepRapNetworkAllowWriting();
|
void RepRapNetworkAllowWriting();
|
||||||
bool RepRapNetworkHasALiveClient();
|
bool RepRapNetworkHasALiveClient();
|
||||||
|
@ -86,15 +86,19 @@ static int initCount = 0;
|
||||||
static void
|
static void
|
||||||
conn_err(void *arg, err_t err)
|
conn_err(void *arg, err_t err)
|
||||||
{
|
{
|
||||||
struct http_state *hs;
|
// Report the error to the monitor
|
||||||
|
RepRapNetworkMessage("Network connection error, code ");
|
||||||
|
{
|
||||||
|
char tempBuf[10];
|
||||||
|
snprintf(tempBuf, sizeof(tempBuf)/sizeof(char), "%d\n", err);
|
||||||
|
RepRapNetworkMessage(tempBuf);
|
||||||
|
}
|
||||||
|
|
||||||
LWIP_UNUSED_ARG(err);
|
struct http_state *hs = arg;
|
||||||
|
RepRapNetworkConnectionError(hs); // tell the higher levels about the error
|
||||||
hs = arg;
|
mem_free(hs); // release the state data
|
||||||
mem_free(hs);
|
|
||||||
//RepRapNetworkHttpStateReleased(hs);
|
|
||||||
RepRapNetworkMessage("Network connection error.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Reference in a new issue