1.18beta1 for Duet Ethernet

Reduced SPI speed to avoid data corruption when uploading files
FTP directory listings now work on Duet Ethernet. File transfers still
don't work.
This commit is contained in:
David Crocker 2017-02-24 13:50:41 +00:00
parent b226c7262f
commit 95bb295716
12 changed files with 26 additions and 52 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -8,6 +8,7 @@
#include "Network.h"
#include "NetworkTransaction.h"
#include "Platform.h"
#include "RepRap.h"
#include "wizchip_conf.h"
#include "Wiznet/Internet/DHCP/dhcp.h"
@ -356,6 +357,10 @@ bool Network::AcquireTransaction(size_t socketNumber)
{
currentTransactionSocketNumber = socketNumber;
}
else if (reprap.Debug(moduleNetwork))
{
debugPrintf("Failed to acquire transaction for socket %u\n", socketNumber);
}
return success;
}
@ -381,7 +386,7 @@ void Network::TerminateSockets()
void Network::Defer(NetworkTransaction *tr)
{
const Socket *skt = tr->GetConnection();
const Socket * const skt = tr->GetConnection();
if (skt != nullptr && skt->GetNumber() == currentTransactionSocketNumber)
{
++currentTransactionSocketNumber;

View file

@ -81,18 +81,20 @@ public:
private:
enum class NetworkState
{
disabled, // WiFi not active
enabled, // WiFi enabled but not started yet
establishingLink, // starting up (waiting for initialisation)
obtainingIP,
active
disabled, // Network disabled
enabled, // Network enabled but not started yet
establishingLink, // starting up, waiting for link
obtainingIP, // link established, waiting for DHCP
active // network running
};
void InitSockets();
void TerminateSockets();
bool AcquireTransaction(size_t socketNumber);
Platform *platform;
bool AcquireTransaction(size_t socketNumber)
pre(socketNumber < NumTcpSockets);
Platform * const platform;
float longWait;
uint32_t lastTickMillis;

View file

@ -17,8 +17,6 @@
//***************************************************************************************************
// Socket class
#define IMMEDIATE_ACQUIRE 1
Socket::Socket() : currentTransaction(nullptr), receivedData(nullptr), state(SocketState::inactive)
{
}
@ -43,7 +41,6 @@ void Socket::ReInit()
persistConnection = true;
isTerminated = false;
isSending = false;
needTransaction = false;
state = SocketState::inactive;
// Re-initialise the socket on the W5500
@ -187,8 +184,7 @@ void Socket::Poll(bool full)
if (state == SocketState::listening) // if it is a new connection
{
needTransaction = false;
if (socketNum == FtpSocketNumber || socketNum == TelnetSocketNumber)
if (socketNum == FtpSocketNumber || socketNum == FtpDataSocketNumber || socketNum == TelnetSocketNumber)
{
// FTP and Telnet protocols need a connection reply, so tell the Webserver module about the new connection
if (currentTransaction == nullptr)
@ -229,7 +225,6 @@ void Socket::Poll(bool full)
}
}
#ifdef IMMEDIATE_ACQUIRE
if (currentTransaction == nullptr && receivedData != nullptr)
{
currentTransaction = NetworkTransaction::Allocate();
@ -238,17 +233,6 @@ void Socket::Poll(bool full)
currentTransaction->Set(this, TransactionStatus::receiving);
}
}
#else
if (currentTransaction == nullptr && (receivedData != nullptr || needTransaction))
{
currentTransaction = NetworkTransaction::Allocate();
if (currentTransaction != nullptr)
{
currentTransaction->Set(this, (needTransaction) ? TransactionStatus::acquired : TransactionStatus::receiving);
needTransaction = false;
}
}
#endif
// See if we can send any data.
// Currently we don't send if we are being called from hsmci because we don't want to risk releasing a buffer that we may be reading data into.
@ -298,27 +282,16 @@ void Socket::Poll(bool full)
break;
case SOCK_CLOSED:
#ifdef _HTTPSERVER_DEBUG_
printf("> HTTPSocket[%d] : CLOSED\r\n", s);
#endif
reprap.GetWebserver()->ConnectionLost(this); // the webserver needs this to be called for both graceful and disgraceful disconnects
state = SocketState::inactive;
if (socket(socketNum, Sn_MR_TCP, localPort, 0x00) == socketNum) // Reinitialize the socket
if (full) // don't make a call to webserver if we might be in it already
{
#ifdef _HTTPSERVER_DEBUG_
printf("> HTTPSocket[%d] : OPEN\r\n", socketNum);
#endif
reprap.GetWebserver()->ConnectionLost(this); // the webserver needs this to be called for both graceful and disgraceful disconnects
ReInit();
}
break;
default:
break;
} // end of switch
#ifdef _USE_WATCHDOG_
HTTPServer_WDT_Reset();
#endif
}
}
// Try to send data, returning true if all data has been sent and we ought to close the socket
@ -333,7 +306,7 @@ bool Socket::TrySendData()
setSn_IR(socketNum, Sn_IR_SENDOK); // if yes
isSending = false;
}
else if(tmp & Sn_IR_TIMEOUT) // did it time out?
else if (tmp & Sn_IR_TIMEOUT) // did it time out?
{
isSending = false;
disconnectNoWait(socketNum); // if so, close the socket
@ -406,17 +379,12 @@ bool Socket::AcquireTransaction()
if (getSn_SR(socketNum) == SOCK_ESTABLISHED)
{
#ifdef IMMEDIATE_ACQUIRE
currentTransaction = NetworkTransaction::Allocate();
if (currentTransaction != nullptr)
{
currentTransaction->Set(this, TransactionStatus::acquired);
return true;
}
#else
needTransaction = true;
return true;
#endif
}
return false;
}

View file

@ -61,7 +61,6 @@ private:
SocketNumber socketNum; // The W5500 socket number we are using
SocketState state;
bool isSending; // True if we have written data to the W5500 to send and have not yet seen success or timeout
bool needTransaction; // True if the web server has asked for a transaction
};
#endif /* SRC_DUETNG_DUETETHERNET_SOCKET_H_ */

View file

@ -1955,7 +1955,7 @@ void Webserver::FtpInterpreter::ConnectionEstablished()
}
// Is this a new connection on the data port?
NetworkTransaction *transaction = webserver->currentTransaction;
NetworkTransaction * const transaction = webserver->currentTransaction;
if (transaction->GetLocalPort() != FTP_PORT)
{
if (state == waitingForPasvPort)
@ -2343,7 +2343,7 @@ void Webserver::FtpInterpreter::ProcessLine()
SendReply(150, "Here comes the directory listing.");
// send directory listing via data port
NetworkTransaction *dataTransaction = network->GetTransaction();
NetworkTransaction * const dataTransaction = network->GetTransaction();
FileInfo fileInfo;
if (platform->GetMassStorage()->FindFirst(currentDir, fileInfo))

View file

@ -25,7 +25,7 @@
#include "matrix.h"
// Functions called by the W5500 module to transfer data to/from the W5500 via SPI
const uint32_t SpiClockFrequency = 60000000;
const uint32_t SpiClockFrequency = 40000000; // tried 60MHz and we got some data corruption when uploading files, so try 40MHz instead
const unsigned int SpiPeripheralChannelId = 0; // we use NPCS0 as the slave select signal
#if USE_PDC

View file

@ -1063,7 +1063,7 @@ void Move::DoDeltaCalibration(size_t numFactors, StringRef& reply)
// Transform the probing points to motor endpoints and store them in a matrix, so that we can do multiple iterations using the same data
FixedMatrix<floatc_t, MaxDeltaCalibrationPoints, DELTA_AXES> probeMotorPositions;
floatc_t corrections[MaxDeltaCalibrationPoints];
float_t initialSumOfSquares = 0.0;
float initialSumOfSquares = 0.0;
for (size_t i = 0; i < numPoints; ++i)
{
corrections[i] = 0.0;

View file

@ -13,7 +13,7 @@
#endif
#ifndef DATE
# define DATE "2017-02-21"
# define DATE "2017-02-24"
#endif
#define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman"