diff options
author | David Crocker <dcrocker@eschertech.com> | 2017-03-13 14:49:07 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2017-03-13 14:49:07 +0300 |
commit | 850760230fa6cd5515817430d9d04e22259745ed (patch) | |
tree | dd2b7c78a0d29eed921ff1b8f2dc490fe59746e3 | |
parent | f42a0f9b95737051c807ac1662fa03cf66107e39 (diff) |
Verison 1.18beta2
Temperatures now default to 0C instead of -273C
Handle G2 ande G3 in simulation mode
Implemented M586
Removed support for M557 P parameter. Use a bed.g file instead.
-rw-r--r-- | Release/Duet-0.6-0.8.5/Edge/RepRapFirmware-1.18beta2.bin | bin | 0 -> 308908 bytes | |||
-rw-r--r-- | Release/Duet-WiFi/Edge/DuetWiFiFirmware-1.18beta2.bin | bin | 0 -> 266828 bytes | |||
-rw-r--r-- | Release/RADDS/Edge/RepRapFirmware-1.18beta2.bin | bin | 0 -> 238620 bytes | |||
-rw-r--r-- | src/Duet/Lwip/contrib/apps/mdns/mdns_responder.c | 15 | ||||
-rw-r--r-- | src/Duet/Lwip/lwip/src/core/tcp_in.c | 6 | ||||
-rw-r--r-- | src/Duet/Network.cpp | 299 | ||||
-rw-r--r-- | src/Duet/Network.h | 24 | ||||
-rw-r--r-- | src/Duet/NetworkDefs.h | 4 | ||||
-rw-r--r-- | src/Duet/Webserver.cpp | 63 | ||||
-rw-r--r-- | src/DuetNG/DuetWiFi/Network.cpp | 26 | ||||
-rw-r--r-- | src/DuetNG/DuetWiFi/Network.h | 18 | ||||
-rw-r--r-- | src/GCodes/GCodes2.cpp | 63 | ||||
-rw-r--r-- | src/Heating/Pid.cpp | 4 | ||||
-rw-r--r-- | src/RADDS/Network.cpp | 7 | ||||
-rw-r--r-- | src/RADDS/Network.h | 4 | ||||
-rw-r--r-- | src/Version.h | 4 |
16 files changed, 331 insertions, 206 deletions
diff --git a/Release/Duet-0.6-0.8.5/Edge/RepRapFirmware-1.18beta2.bin b/Release/Duet-0.6-0.8.5/Edge/RepRapFirmware-1.18beta2.bin Binary files differnew file mode 100644 index 00000000..688c84ba --- /dev/null +++ b/Release/Duet-0.6-0.8.5/Edge/RepRapFirmware-1.18beta2.bin diff --git a/Release/Duet-WiFi/Edge/DuetWiFiFirmware-1.18beta2.bin b/Release/Duet-WiFi/Edge/DuetWiFiFirmware-1.18beta2.bin Binary files differnew file mode 100644 index 00000000..9c772b21 --- /dev/null +++ b/Release/Duet-WiFi/Edge/DuetWiFiFirmware-1.18beta2.bin diff --git a/Release/RADDS/Edge/RepRapFirmware-1.18beta2.bin b/Release/RADDS/Edge/RepRapFirmware-1.18beta2.bin Binary files differnew file mode 100644 index 00000000..2dd10462 --- /dev/null +++ b/Release/RADDS/Edge/RepRapFirmware-1.18beta2.bin diff --git a/src/Duet/Lwip/contrib/apps/mdns/mdns_responder.c b/src/Duet/Lwip/contrib/apps/mdns/mdns_responder.c index 48c68d90..5353b367 100644 --- a/src/Duet/Lwip/contrib/apps/mdns/mdns_responder.c +++ b/src/Duet/Lwip/contrib/apps/mdns/mdns_responder.c @@ -59,6 +59,9 @@ #include <string.h> #include <stdlib.h> // for strtol +#if 1 //dc42 +#include <stdbool.h> +#endif #ifndef ip_set_option #define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) @@ -589,6 +592,18 @@ err_t mdns_responder_init(const struct mdns_service *services, int num_services, const char *txt_records[]) { +#if 1 // dc42 changes to allow the set of services to be changed after initialisation + static bool initialised = false; + if (initialised) + { + mdns_state.services = services; + mdns_state.num_services = num_services; + // Ideally we would also update the text records again here, but RRF never changes them + return ERR_OK; + } + initialised = true; +#endif + err_t ret; memset(&mdns_state, 0, sizeof(mdns_state)); diff --git a/src/Duet/Lwip/lwip/src/core/tcp_in.c b/src/Duet/Lwip/lwip/src/core/tcp_in.c index d0ae7da7..cd67fc53 100644 --- a/src/Duet/Lwip/lwip/src/core/tcp_in.c +++ b/src/Duet/Lwip/lwip/src/core/tcp_in.c @@ -768,7 +768,7 @@ tcp_process(struct tcp_pcb *pcb) break; case CLOSING: tcp_receive(pcb); - if (flags & TCP_ACK && ackno == pcb->snd_nxt) { + if ((flags & TCP_ACK) && ackno == pcb->snd_nxt) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: CLOSING %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); tcp_pcb_purge(pcb); TCP_RMV_ACTIVE(pcb); @@ -778,7 +778,7 @@ tcp_process(struct tcp_pcb *pcb) break; case LAST_ACK: tcp_receive(pcb); - if (flags & TCP_ACK && ackno == pcb->snd_nxt) { + if ((flags & TCP_ACK) && ackno == pcb->snd_nxt) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: LAST_ACK %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); /* bugfix #21699: don't set pcb->state to CLOSED here or we risk leaking segments */ recv_flags |= TF_CLOSED; @@ -1263,7 +1263,7 @@ tcp_receive(struct tcp_pcb *pcb) TCP_SEQ_GEQ(seqno + tcplen, next->tcphdr->seqno + next->len)) { /* inseg cannot have FIN here (already processed above) */ - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN && + if ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) && (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) == 0) { TCPH_SET_FLAG(inseg.tcphdr, TCP_FIN); tcplen = TCP_TCPLEN(&inseg); diff --git a/src/Duet/Network.cpp b/src/Duet/Network.cpp index bba5ffa4..967f7934 100644 --- a/src/Duet/Network.cpp +++ b/src/Duet/Network.cpp @@ -67,33 +67,38 @@ extern "C" static volatile bool lwipLocked = false; static bool ethernetStarted = false; -static tcp_pcb *http_pcb = nullptr; -static tcp_pcb *ftp_main_pcb = nullptr; +const size_t NumProtocols = 3; // number of network protocols we support +const size_t HttpProtocolIndex = 0, FtpProtocolIndex = 1, TelnetProtocolIndex = 2; // index of theHTTP service above +const Port DefaultPortNumbers[NumProtocols] = { DefaultHttpPort, DefaultFtpPort, DefaultTelnetPort }; +const char * const ProtocolNames[NumProtocols] = { "HTTP", "FTP", "TELNET" }; +const char * const MdnsServiceStrings[NumProtocols] = { "\x05_http\x04_tcp\x05local", "\x04_ftp\x04_tcp\x05local", "\x07_telnet\x04_tcp\x05local" }; + +static Port portNumbers[NumProtocols] = { DefaultHttpPort, DefaultFtpPort, DefaultTelnetPort }; // port number used for each protocol +static bool protocolEnabled[NumProtocols] = { true, false, false }; // by default only HTTP is enabled +static tcp_pcb *pcbs[NumProtocols] = { nullptr, nullptr, nullptr }; static tcp_pcb *ftp_pasv_pcb = nullptr; -static tcp_pcb *telnet_pcb = nullptr; -static struct mdns_service mdns_services[] = { +const size_t NumMdnsFixedProtocols = 1; // what we need to add to the protocol index in order to access the corresponding entry in mdns_services +static struct mdns_service mdns_services[NumMdnsFixedProtocols + NumProtocols] = +{ { .name = "\x05_echo\x04_tcp\x05local", .port = 7, }, { - .name = "\x05_http\x04_tcp\x05local", - .port = DefaultHttpPort, + 0 }, { - .name = "\x04_ftp\x04_tcp\x05local", - .port = FTP_PORT + 0 }, { - .name = "\x07_telnet\x04_tcp\x05local", - .port = TELNET_PORT + 0 } }; -const size_t MDNS_HTTP_SERVICE_INDEX = 1; // Index of the mDNS HTTP service above -static const char *mdns_txt_records[] = { +static const char *mdns_txt_records[] = +{ "product=" FIRMWARE_NAME, "version=" VERSION, NULL @@ -109,8 +114,6 @@ uint16_t sendingWindowSize, sentDataOutstanding; uint8_t sendingRetries; err_t writeResult, outputResult; -static Port httpPort = DefaultHttpPort; - /*-----------------------------------------------------------------------------------*/ extern "C" @@ -229,64 +232,41 @@ static err_t conn_accept(void *arg, tcp_pcb *pcb, err_t err) LWIP_UNUSED_ARG(arg); LWIP_UNUSED_ARG(err); - /* Allocate a new ConnectionState for this connection */ - ConnectionState *cs = reprap.GetNetwork()->ConnectionAccepted(pcb); - if (cs == nullptr) + // Keep the listening PCBs running + tcp_pcb *targetPcb = nullptr; + for (size_t i = 0; i < NumProtocols && targetPcb == nullptr; ++i) { - tcp_abort(pcb); - return ERR_ABRT; + if (pcbs[i] != nullptr && pcb->local_port == portNumbers[i]) + { + targetPcb = pcbs[i]; + } } - /* Keep the listening PCBs running */ - switch (pcb->local_port) // tell LWIP to accept further connections on the listening PCB + if (targetPcb == nullptr && ftp_pasv_pcb != nullptr && pcb->local_port == ftp_pasv_pcb->local_port) { - case FTP_PORT: // FTP - tcp_accepted(ftp_main_pcb); - break; - - case TELNET_PORT: // Telnet - tcp_accepted(telnet_pcb); - break; + targetPcb = ftp_pasv_pcb; + } - default: // HTTP and FTP data - tcp_accepted((pcb->local_port == httpPort) ? http_pcb : ftp_pasv_pcb); - break; + if (targetPcb != nullptr) + { + // Allocate a new ConnectionState for this connection + ConnectionState *cs = reprap.GetNetwork()->ConnectionAccepted(pcb); + if (cs != nullptr) + { + tcp_accepted(targetPcb); + tcp_arg(pcb, cs); // tell LWIP that this is the structure we wish to be passed for our callbacks + tcp_recv(pcb, conn_recv); // tell LWIP that we wish to be informed of incoming data by a call to the conn_recv() function + tcp_err(pcb, conn_err); + return ERR_OK; + } } - tcp_arg(pcb, cs); // tell LWIP that this is the structure we wish to be passed for our callbacks - tcp_recv(pcb, conn_recv); // tell LWIP that we wish to be informed of incoming data by a call to the conn_recv() function - tcp_err(pcb, conn_err); - return ERR_OK; + tcp_abort(pcb); + return ERR_ABRT; } } // end extern "C" -/*-----------------------------------------------------------------------------------*/ - -void httpd_init() -{ - tcp_pcb* pcb = tcp_new(); - tcp_bind(pcb, IP_ADDR_ANY, httpPort); - http_pcb = tcp_listen(pcb); - tcp_accept(http_pcb, conn_accept); -} - -void ftpd_init() -{ - tcp_pcb* pcb = tcp_new(); - tcp_bind(pcb, IP_ADDR_ANY, FTP_PORT); - ftp_main_pcb = tcp_listen(pcb); - tcp_accept(ftp_main_pcb, conn_accept); -} - -void telnetd_init() -{ - tcp_pcb* pcb = tcp_new(); - tcp_bind(pcb, IP_ADDR_ANY, TELNET_PORT); - telnet_pcb = tcp_listen(pcb); - tcp_accept(telnet_pcb, conn_accept); -} - //*************************************************************************************************** // Network/Ethernet class @@ -314,15 +294,123 @@ void Network::Init() strcpy(hostname, HOSTNAME); init_ethernet(); - - httpd_init(); - ftpd_init(); - telnetd_init(); netbios_init(); longWait = platform->Time(); } +void Network::EnableProtocol(int protocol, int port, int secure, StringRef& reply) +{ + if (secure != 0 && secure != -1) + { + reply.copy("Error: this firmware does not support TLS"); + } + else if (protocol >= 0 && protocol < (int)NumProtocols) + { + const Port portToUse = (port < 0) ? DefaultPortNumbers[protocol] : port; + if (portToUse != portNumbers[protocol]) + { + // We need to shut down and restart the protocol if it is active because the port number has changed + ShutdownProtocol(protocol); + protocolEnabled[protocol] = false; + } + portNumbers[protocol] = portToUse; + if (!protocolEnabled[protocol]) + { + protocolEnabled[protocol] = true; + StartProtocol(protocol); + if (state == NetworkActive) + { + DoMdnsAnnounce(); + } + } + ReportOneProtocol(protocol, reply); + } + else + { + reply.copy("Invalid protocol parameter"); + } +} + +void Network::DisableProtocol(int protocol, StringRef& reply) +{ + if (protocol >= 0 && protocol < (int)NumProtocols) + { + ShutdownProtocol(protocol); + protocolEnabled[protocol] = false; + ReportOneProtocol(protocol, reply); + } + else + { + reply.copy("Invalid protocol parameter"); + } +} + +void Network::StartProtocol(size_t protocol) +{ + if (pcbs[protocol] == nullptr) + { + tcp_pcb* pcb = tcp_new(); + tcp_bind(pcb, IP_ADDR_ANY, portNumbers[protocol]); + pcbs[protocol] = tcp_listen(pcb); + tcp_accept(pcbs[protocol], conn_accept); + } +} + +void Network::ShutdownProtocol(size_t protocol) +{ + if (pcbs[protocol] != nullptr) + { + tcp_close(pcbs[protocol]); + pcbs[protocol] = nullptr; + } +} + +// Report the protocols and ports in use +void Network::ReportProtocols(StringRef& reply) const +{ + reply.Clear(); + for (size_t i = 0; i < NumProtocols; ++i) + { + if (i != 0) + { + reply.cat('\n'); + } + ReportOneProtocol(i, reply); + } +} + +void Network::ReportOneProtocol(size_t protocol, StringRef& reply) const +{ + if (protocolEnabled[protocol]) + { + reply.catf("%s is enabled on port %u", ProtocolNames[protocol], portNumbers[protocol]); + } + else + { + reply.catf("%s is disabled", ProtocolNames[protocol]); + } +} + +void Network::DoMdnsAnnounce() +{ + // Fill in the table of services + size_t numServices = NumMdnsFixedProtocols; + for (size_t i = 0; i < NumProtocols; ++i) + { + if (protocolEnabled[i]) + { + mdns_services[numServices].name = MdnsServiceStrings[i]; + mdns_services[numServices].port = portNumbers[i]; + ++numServices; + } + } + + // We have patched mdns_responder_init so that it can be called more than once + mdns_responder_init(mdns_services, numServices, mdns_txt_records); + mdns_announce(); +} + void Network::Spin(bool full) { if (LockLWIP()) // basically we can't do anything if we can't interact with LWIP @@ -347,24 +435,32 @@ void Network::Spin(bool full) ethernet_set_rx_callback(ðernet_rx_callback); } - // Have we obtained a valid IP address yet? - if (state == NetworkObtainingIP) + // See if we can send anything - only if full spin i.e. not in the middle of file i/o + if (full) { - const uint8_t *ip = ethernet_get_ipaddress(); - if (ip[0] != 0 && ip[1] != 0 && ip[2] != 0 && ip[3] != 0) + // Have we obtained a valid IP address yet? + if (state == NetworkObtainingIP) { - // Yes - we're good to go now - state = NetworkActive; + const uint8_t * const ip = ethernet_get_ipaddress(); + if (ip[0] != 0 && ip[1] != 0 && ip[2] != 0 && ip[3] != 0) + { + // Yes - we're good to go now + state = NetworkActive; - // Send mDNS announcement so that some routers can perform hostname mapping - // if ths board is connected via a non-IGMP capable WiFi bridge (like the TP-Link WR701N) - mdns_announce(); + for (size_t i = 0; i < NumProtocols; ++i) + { + if (protocolEnabled[i]) + { + StartProtocol(i); + } + } + + // Send mDNS announcement so that some routers can perform hostname mapping + // if the board is connected via a non-IGMP capable WiFi bridge (like the TP-Link WR701N) + DoMdnsAnnounce(); + } } - } - // See if we can send anything - only if full spin i.e. not in the middle of file i/o - if (full) - { NetworkTransaction *transaction = writingTransactions; if (transaction != nullptr && sendingConnection == nullptr) { @@ -400,9 +496,6 @@ void Network::Spin(bool full) { start_ethernet(platform->GetIPAddress(), platform->NetMask(), platform->GateWay(), ðernet_status_callback); ethernetStarted = true; - - // Initialise this one here, because it requires a configured IGMP network interface - mdns_responder_init(mdns_services, ARRAY_SIZE(mdns_services), mdns_txt_records); } else { @@ -732,6 +825,10 @@ void Network::Disable() { if (state != NetworkInactive) { + for (size_t i = 0; i < NumProtocols; ++i) + { + ShutdownProtocol(i); + } resetCallback = false; ethernet_set_rx_callback(nullptr); state = NetworkInactive; @@ -798,41 +895,33 @@ void Network::PrependTransaction(NetworkTransaction* volatile* list, NetworkTran *list = r; } -void Network::OpenDataPort(Port port) +Port Network::GetHttpPort() { - closingDataPort = false; - tcp_pcb* pcb = tcp_new(); - tcp_bind(pcb, IP_ADDR_ANY, port); - ftp_pasv_pcb = tcp_listen(pcb); - tcp_accept(ftp_pasv_pcb, conn_accept); + return portNumbers[HttpProtocolIndex]; } -Port Network::GetDataPort() const +Port Network::GetFtpPort() { - return (closingDataPort || (ftp_pasv_pcb == nullptr) ? 0 : ftp_pasv_pcb->local_port); + return portNumbers[FtpProtocolIndex]; } -Port Network::GetHttpPort() const +Port Network::GetTelnetPort() { - return httpPort; + return portNumbers[TelnetProtocolIndex]; } -void Network::SetHttpPort(Port port) +Port Network::GetDataPort() { - if (port != httpPort) - { - // Close the old HTTP PCB and create a new one - tcp_close(http_pcb); - httpPort = port; - httpd_init(); + return (closingDataPort || ftp_pasv_pcb == nullptr) ? 0 : ftp_pasv_pcb->local_port; +} - // Update mDNS service - mdns_services[MDNS_HTTP_SERVICE_INDEX].port = port; - if (state == NetworkActive) - { - mdns_announce(); - } - } +void Network::OpenDataPort(Port port) +{ + closingDataPort = false; + tcp_pcb* pcb = tcp_new(); + tcp_bind(pcb, IP_ADDR_ANY, port); + ftp_pasv_pcb = tcp_listen(pcb); + tcp_accept(ftp_pasv_pcb, conn_accept); } // Close FTP data port and purge associated PCB diff --git a/src/Duet/Network.h b/src/Duet/Network.h index 1c10844b..979a6a17 100644 --- a/src/Duet/Network.h +++ b/src/Duet/Network.h @@ -54,6 +54,10 @@ public: void Interrupt(); void Diagnostics(MessageType mtype); + void EnableProtocol(int protocol, int port, int secure, StringRef& reply); + void DisableProtocol(int protocol, StringRef& reply); + void ReportProtocols(StringRef& reply) const; + // Deal with LwIP void ResetCallback(); @@ -81,12 +85,8 @@ public: NetworkTransaction *GetTransaction(const ConnectionState *cs = nullptr); void OpenDataPort(Port port); - Port GetDataPort() const; void CloseDataPort(); - void SetHttpPort(Port port); - Port GetHttpPort() const; - void SaveDataConnection(); void SaveFTPConnection(); void SaveTelnetConnection(); @@ -95,6 +95,11 @@ public: bool AcquireDataTransaction(); bool AcquireTelnetTransaction(); + static Port GetHttpPort(); + static Port GetFtpPort(); + static Port GetTelnetPort(); + static Port GetDataPort(); + static Port GetLocalPort(Connection conn); static Port GetRemotePort(Connection conn); static uint32_t GetRemoteIP(Connection conn); @@ -111,6 +116,17 @@ private: void PrependTransaction(NetworkTransaction* volatile * list, NetworkTransaction *r); bool AcquireTransaction(ConnectionState *cs); + void StartProtocol(size_t protocol) + pre(protocol < NumProtocols); + + void ShutdownProtocol(size_t protocol) + pre(protocol < NumProtocols); + + void ReportOneProtocol(size_t protocol, StringRef& reply) const + pre(protocol < NumProtocols); + + void DoMdnsAnnounce(); + NetworkTransaction * volatile freeTransactions; NetworkTransaction * volatile readyTransactions; NetworkTransaction * volatile writingTransactions; diff --git a/src/Duet/NetworkDefs.h b/src/Duet/NetworkDefs.h index ff0c95a3..134a90f0 100644 --- a/src/Duet/NetworkDefs.h +++ b/src/Duet/NetworkDefs.h @@ -29,8 +29,8 @@ const uint8_t DefaultNetMask[4] = { 255, 255, 255, 0 }; const uint8_t DefaultGateway[4] = { 0, 0, 0, 0 }; const Port DefaultHttpPort = 80; -const Port FTP_PORT = 21; -const Port TELNET_PORT = 23; +const Port DefaultFtpPort = 21; +const Port DefaultTelnetPort = 23; // MSS is defined in lwip #include "Lwip/lwipopts.h" diff --git a/src/Duet/Webserver.cpp b/src/Duet/Webserver.cpp index 20c8c1e2..d21fd99b 100644 --- a/src/Duet/Webserver.cpp +++ b/src/Duet/Webserver.cpp @@ -150,26 +150,17 @@ void Webserver::Spin() // Take care of different protocol types here ProtocolInterpreter *interpreter; const uint16_t localPort = currentTransaction->GetLocalPort(); - switch (localPort) + if (localPort == Network::GetHttpPort()) { - case FTP_PORT: /* FTP */ - interpreter = ftpInterpreter; - break; - - case TELNET_PORT: /* Telnet */ - interpreter = telnetInterpreter; - break; - - default: /* HTTP and FTP data */ - if (localPort == network->GetHttpPort()) - { - interpreter = httpInterpreter; - } - else - { - interpreter = ftpInterpreter; - } - break; + interpreter = httpInterpreter; + } + else if (localPort == Network::GetTelnetPort()) + { + interpreter = telnetInterpreter; + } + else + { + interpreter = ftpInterpreter; } // See if we have to print some debug info @@ -345,28 +336,20 @@ void Webserver::ConnectionLost(Connection conn) // Inform protocol handlers that this connection has been lost const uint16_t localPort = Network::GetLocalPort(conn); ProtocolInterpreter *interpreter; - switch (localPort) + if (localPort == Network::GetHttpPort()) + { + interpreter = httpInterpreter; + } + else if (localPort == Network::GetFtpPort() || localPort == network->GetDataPort()) { - case FTP_PORT: /* FTP */ interpreter = ftpInterpreter; - break; - - case TELNET_PORT: /* Telnet */ + } + else if (localPort == Network::GetTelnetPort()) + { interpreter = telnetInterpreter; - break; - - default: /* HTTP and FTP data */ - if (localPort == network->GetHttpPort()) - { - interpreter = httpInterpreter; - break; - } - else if (localPort == network->GetDataPort()) - { - interpreter = ftpInterpreter; - break; - } - + } + else + { platform->MessageF(GENERIC_MESSAGE, "Error: Webserver should handle disconnect event at local port %d, but no handler was found!\n", localPort); return; } @@ -1956,7 +1939,7 @@ void Webserver::FtpInterpreter::ConnectionEstablished() // Is this a new connection on the data port? NetworkTransaction *transaction = webserver->currentTransaction; - if (transaction->GetLocalPort() != FTP_PORT) + if (transaction->GetLocalPort() != Network::GetFtpPort()) { if (state == waitingForPasvPort) { @@ -1995,7 +1978,7 @@ void Webserver::FtpInterpreter::ConnectionLost(Connection conn) { connectedClients--; - if (Network::GetLocalPort(conn) != FTP_PORT) + if (Network::GetLocalPort(conn) != Network::GetFtpPort()) { // Did everything work out? Usually this is only called for uploads if (network->AcquireFTPTransaction()) diff --git a/src/DuetNG/DuetWiFi/Network.cpp b/src/DuetNG/DuetWiFi/Network.cpp index 316461c4..e15d0ec0 100644 --- a/src/DuetNG/DuetWiFi/Network.cpp +++ b/src/DuetNG/DuetWiFi/Network.cpp @@ -59,6 +59,22 @@ void Network::Init() uploader = new WifiFirmwareUploader(Serial1); } +void Network::EnableProtocol(int protocol, int port, bool secure, StringRef& reply) +{ + reply.copy("M586 is not yet implemented on this platform"); +} + +void Network::DisableProtocol(int protocol, StringRef& reply) +{ + reply.copy("M586 is not yet implemented on this platform"); + +} + +void Network::ReportProtocols(StringRef& reply) const +{ + reply.copy("M586 is not yet implemented on this platform"); +} + void Network::Activate() { activated = true; @@ -748,16 +764,6 @@ const uint8_t *Network::GetIPAddress() const return ipAddress; } -uint16_t Network::GetHttpPort() const -{ - return DefaultHttpPort; -} - -void Network::SetHttpPort(uint16_t port) -{ - // Not supported -} - // Set the DHCP hostname. Removes all whitespaces and converts the name to lower-case. void Network::SetHostname(const char *name) { diff --git a/src/DuetNG/DuetWiFi/Network.h b/src/DuetNG/DuetWiFi/Network.h index 4b13f34e..f0ec60d3 100644 --- a/src/DuetNG/DuetWiFi/Network.h +++ b/src/DuetNG/DuetWiFi/Network.h @@ -20,7 +20,6 @@ const uint32_t rcKeepOpen = 0x00020000; static const uint8_t DefaultIpAddress[4] = { 192, 168, 1, 10 }; // Need some sort of default... static const uint8_t DefaultNetMask[4] = { 255, 255, 255, 0 }; static const uint8_t DefaultGateway[4] = { 192, 168, 1, 1 }; -static const uint16_t DefaultHttpPort = 80; class TransactionBuffer; class WifiFirmwareUploader; @@ -55,15 +54,16 @@ public: void Start(); void Stop(); + void EnableProtocol(int protocol, int port, bool secure, StringRef& reply); + void DisableProtocol(int protocol, StringRef& reply); + void ReportProtocols(StringRef& reply) const; + bool InLwip() const { return false; } void Enable(); void Disable(); bool IsEnabled() const; - void SetHttpPort(uint16_t port); - uint16_t GetHttpPort() const; - void SetHostname(const char *name); void EspRequestsTransfer(); @@ -88,6 +88,15 @@ private: void TryStartTransfer(); void DebugPrintResponse(); + void StartProtocol(size_t protocol) + pre(protocol < NumProtocols); + + void ShutdownProtocol(size_t protocol) + pre(protocol < NumProtocols); + + void ReportOneProtocol(size_t protocol, StringRef& reply) const + pre(protocol < NumProtocols); + static const char* TranslateEspResetReason(uint32_t reason); Platform *platform; @@ -108,6 +117,7 @@ private: TransferState state; bool activated; bool connectedToAp; + uint8_t ipAddress[4]; char hostname[16]; // Limit DHCP hostname to 15 characters + terminating 0 char wiFiServerVersion[16]; diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index 6ff6aa9e..44faf305 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -68,7 +68,7 @@ bool GCodes::HandleGcode(GCodeBuffer& gb, StringRef& reply) bool error = false; const int code = gb.GetIValue(); - if (simulationMode != 0 && code != 0 && code != 1 && code != 4 && code != 10 && code != 20 && code != 21 && code != 90 && code != 91 && code != 92) + if (simulationMode != 0 && code > 4 && code != 10 && code != 20 && code != 21 && code != 90 && code != 91 && code != 92) { return true; // we only simulate some gcodes } @@ -2219,12 +2219,6 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, StringRef& reply) SetEthernetAddress(gb, code); } - if (gb.Seen('R')) - { - reprap.GetNetwork()->SetHttpPort(gb.GetIValue()); - seen = true; - } - // Process this one last in case the IP address is changed and the network enabled in the same command if (gb.Seen('S')) // Has the user turned the network on or off? { @@ -2243,10 +2237,9 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, StringRef& reply) { const byte *config_ip = platform->GetIPAddress(); const byte *actual_ip = reprap.GetNetwork()->GetIPAddress(); - reply.printf("Network is %s, configured IP address: %d.%d.%d.%d, actual IP address: %d.%d.%d.%d, HTTP port: %d", + reply.printf("Network is %s, configured IP address: %d.%d.%d.%d, actual IP address: %d.%d.%d.%d", reprap.GetNetwork()->IsEnabled() ? "enabled" : "disabled", - config_ip[0], config_ip[1], config_ip[2], config_ip[3], actual_ip[0], actual_ip[1], actual_ip[2], actual_ip[3], - reprap.GetNetwork()->GetHttpPort()); + config_ip[0], config_ip[1], config_ip[2], config_ip[3], actual_ip[0], actual_ip[1], actual_ip[2], actual_ip[3]); } } break; @@ -2335,30 +2328,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, StringRef& reply) case 557: // Set/report Z probe point coordinates if (gb.Seen('P')) { - const int point = gb.GetIValue(); - if (point < 0 || (unsigned int)point >= MaxProbePoints) - { - reprap.GetPlatform()->Message(GENERIC_MESSAGE, "Z probe point index out of range.\n"); - } - else - { - bool seen = false; - if (gb.Seen(axisLetters[X_AXIS])) - { - reprap.GetMove()->SetXBedProbePoint(point, gb.GetFValue()); - seen = true; - } - if (gb.Seen(axisLetters[Y_AXIS])) - { - reprap.GetMove()->SetYBedProbePoint(point, gb.GetFValue()); - seen = true; - } - - if (!seen) - { - reply.printf("Probe point %d - [%.1f, %.1f]", point, reprap.GetMove()->XBedProbePoint(point), reprap.GetMove()->YBedProbePoint(point)); - } - } + reply.copy("Error: M557 P parameter is no longer supported. use a bed.g file instead.\n"); } else { @@ -3142,6 +3112,31 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, StringRef& reply) } break; + case 586: // Configure network protocols + if (gb.Seen('P')) + { + const int protocol = gb.GetIValue(); + if (gb.Seen('S')) + { + const bool enable = (gb.GetIValue() == 1); + if (enable) + { + const int port = (gb.Seen('R')) ? gb.GetIValue() : -1; + const int secure = (gb.Seen('T')) ? gb.GetIValue() : -1; + reprap.GetNetwork()->EnableProtocol(protocol, port, secure, reply); + } + else + { + reprap.GetNetwork()->DisableProtocol(protocol, reply); + } + break; + } + } + + // Default to reporting current protocols if P or S parameter missing + reprap.GetNetwork()->ReportProtocols(reply); + break; + case 665: // Set delta configuration if (!LockMovementAndWaitForStandstill(gb)) { diff --git a/src/Heating/Pid.cpp b/src/Heating/Pid.cpp index 45f13a36..2f4661ec 100644 --- a/src/Heating/Pid.cpp +++ b/src/Heating/Pid.cpp @@ -70,8 +70,8 @@ void PID::Reset() mode = HeaterMode::off; previousTemperaturesGood = 0; previousTemperatureIndex = 0; - activeTemperature = ABS_ZERO; - standbyTemperature = ABS_ZERO; + activeTemperature = 0.0; + standbyTemperature = 0.0; iAccumulator = 0.0; badTemperatureCount = 0; active = false; // default to standby temperature diff --git a/src/RADDS/Network.cpp b/src/RADDS/Network.cpp index 13ff7724..7f37744a 100644 --- a/src/RADDS/Network.cpp +++ b/src/RADDS/Network.cpp @@ -6,3 +6,10 @@ const uint8_t *Network::GetIPAddress() const { return dummy_ipv4; } + +void Network::ReportProtocols(StringRef& reply) const +{ + reply.copy("Networking is not supported on this hardware"); +} + +// End diff --git a/src/RADDS/Network.h b/src/RADDS/Network.h index 32f5ce31..8e315574 100644 --- a/src/RADDS/Network.h +++ b/src/RADDS/Network.h @@ -23,6 +23,10 @@ public: void Interrupt() const { }; void Diagnostics(MessageType mtype) const { }; + void EnableProtocol(int protocol, int port, bool secure, StringRef& reply) { } + void DisableProtocol(int protocol, StringRef& reply) { } + void ReportProtocols(StringRef& reply) const; + bool IsEnabled() const { return false; } bool InLwip() const { return false; } void SetHostname(const char *name) const { }; diff --git a/src/Version.h b/src/Version.h index bd240770..99ebb10a 100644 --- a/src/Version.h +++ b/src/Version.h @@ -9,11 +9,11 @@ #define SRC_VERSION_H_ #ifndef VERSION -# define VERSION "1.18beta1" +# define VERSION "1.18beta2" #endif #ifndef DATE -# define DATE "2017-02-24" +# define DATE "2017-03-10" #endif #define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman" |