From f742a5fde0680735f5aa3176f383bab8f78fa504 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 23 Dec 2022 19:16:42 +0000 Subject: [PATCH] #45 Fixes to compilation issues in udp/spi systems --- .../native/arm/peripherals/spi/all/pom.xml | 28 +++++++++++++++++++ receivers/native/arm/peripherals/spi/pom.xml | 1 + .../c++/spi-for-wiznet-stm32/lowlevel/SPI.h | 23 --------------- .../main/c++/spi-for-wiznet/lowlevel/SPI.h | 2 +- .../native/arm/peripherals/udp/all/pom.xml | 28 +++++++++++++++++++ receivers/native/arm/peripherals/udp/pom.xml | 1 + .../c++/wiznet-udp-ll/ZcodeUdpChannel.hpp | 24 ++++++++-------- .../wiznet-arduino-library-src/Dhcp.h | 6 ++-- .../lowlevel/wiznet-arduino-library-src/Dns.h | 16 +++++------ .../wiznet-arduino-library-src/Ethernet.h | 10 +++---- .../EthernetClient.h | 22 +++++++-------- .../wiznet-arduino-library-src/EthernetUdp.h | 6 ++-- .../wiznet-arduino-library-src/Ethernetcpp.h | 2 +- .../wiznet-arduino-library-src/socket.h | 2 +- .../utility/w5100.h | 9 +++--- 15 files changed, 107 insertions(+), 73 deletions(-) create mode 100644 receivers/native/arm/peripherals/spi/all/pom.xml create mode 100644 receivers/native/arm/peripherals/udp/all/pom.xml diff --git a/receivers/native/arm/peripherals/spi/all/pom.xml b/receivers/native/arm/peripherals/spi/all/pom.xml new file mode 100644 index 000000000..ad9fa1dd7 --- /dev/null +++ b/receivers/native/arm/peripherals/spi/all/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + + org.zcode + zcode-receivers-spi + 0.0.1-SNAPSHOT + + + zcode-receivers-spi-all + nar + Zcode full peripheral set + + + + org.zcode + zcode-receivers-spi-for-wiznet + ${project.version} + nar + + + org.zcode + zcode-receivers-spi-for-wiznet-stm32 + ${project.version} + nar + + + diff --git a/receivers/native/arm/peripherals/spi/pom.xml b/receivers/native/arm/peripherals/spi/pom.xml index 4259eb8a6..f9e12dd01 100644 --- a/receivers/native/arm/peripherals/spi/pom.xml +++ b/receivers/native/arm/peripherals/spi/pom.xml @@ -11,6 +11,7 @@ pom Zcode SPI + all spi-for-wiznet spi-for-wiznet-stm32 diff --git a/receivers/native/arm/peripherals/spi/spi-for-wiznet-stm32/src/main/c++/spi-for-wiznet-stm32/lowlevel/SPI.h b/receivers/native/arm/peripherals/spi/spi-for-wiznet-stm32/src/main/c++/spi-for-wiznet-stm32/lowlevel/SPI.h index cb8ce6838..ab366fb5e 100644 --- a/receivers/native/arm/peripherals/spi/spi-for-wiznet-stm32/src/main/c++/spi-for-wiznet-stm32/lowlevel/SPI.h +++ b/receivers/native/arm/peripherals/spi/spi-for-wiznet-stm32/src/main/c++/spi-for-wiznet-stm32/lowlevel/SPI.h @@ -25,29 +25,6 @@ #ifndef USE_SPI_1 #error SPI_1 is needed for udp comunications... #endif -#ifdef USE_SPI_1 -#if !SPI_SCK(_SPI_1, SPI_1_SCK) -#error Not defined as a valid SPI 1 SCK pin: SPI_1_SCK -#endif -#if !SPI_MISO(_SPI_1, SPI_1_MISO) -#error Not defined as a valid SPI 1 MISO pin: SPI_1_MISO -#endif -#if !SPI_MOSI(_SPI_1, SPI_1_MOSI) -#error Not defined as a valid SPI 1 MOSI pin: SPI_1_MOSI -#endif -#endif - -#ifdef USE_SPI_2 -#if !SPI_SCK(_SPI_2, SPI_2_SCK) -#error Not defined as a valid SPI 2 SCK pin: SPI_2_SCK -#endif -#if !SPI_MISO(_SPI_2, SPI_2_MISO) -#error Not defined as a valid SPI 2 MISO pin: SPI_2_MISO -#endif -#if !SPI_MOSI(_SPI_2, SPI_2_MOSI) -#error Not defined as a valid SPI 2 MOSI pin: SPI_2_MOSI -#endif -#endif template class SPIClass { diff --git a/receivers/native/arm/peripherals/spi/spi-for-wiznet/src/main/c++/spi-for-wiznet/lowlevel/SPI.h b/receivers/native/arm/peripherals/spi/spi-for-wiznet/src/main/c++/spi-for-wiznet/lowlevel/SPI.h index 17140b91d..37ef01aea 100644 --- a/receivers/native/arm/peripherals/spi/spi-for-wiznet/src/main/c++/spi-for-wiznet/lowlevel/SPI.h +++ b/receivers/native/arm/peripherals/spi/spi-for-wiznet/src/main/c++/spi-for-wiznet/lowlevel/SPI.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT */ -#if defined(SPI_WIZNET_STM32) +#if defined(STM32) #include #else #error Please select a supported device family diff --git a/receivers/native/arm/peripherals/udp/all/pom.xml b/receivers/native/arm/peripherals/udp/all/pom.xml new file mode 100644 index 000000000..eab533c1d --- /dev/null +++ b/receivers/native/arm/peripherals/udp/all/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + + org.zcode + zcode-receivers-udp + 0.0.1-SNAPSHOT + + + zcode-receivers-udp-all + nar + Zcode full peripheral set + + + + org.zcode + zcode-receivers-udp-core + ${project.version} + nar + + + org.zcode + zcode-receivers-wiznet-udp-ll + ${project.version} + nar + + + diff --git a/receivers/native/arm/peripherals/udp/pom.xml b/receivers/native/arm/peripherals/udp/pom.xml index 8fec3a19c..54bfd250f 100644 --- a/receivers/native/arm/peripherals/udp/pom.xml +++ b/receivers/native/arm/peripherals/udp/pom.xml @@ -11,6 +11,7 @@ pom Zcode UDP + all udp-core wiznet-udp-ll diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/ZcodeUdpChannel.hpp b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/ZcodeUdpChannel.hpp index 368349917..2793566a3 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/ZcodeUdpChannel.hpp +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/ZcodeUdpChannel.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +//#include #include "lowlevel/wiznet-arduino-library-src/Ethernet.h" template @@ -162,11 +162,11 @@ class ZcodeUdpChannel: public ZcodeCommandChannel { 0), debugPort(0), port(port) { uint8_t *mac; uint8_t macHardCoded[6] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xad }; - if (ZcodeFlashPersistence::persist.hasMac()) { - mac = ZcodeFlashPersistence::persist.getMac(); - } else { - mac = macHardCoded; - } +// if (ZcodeFlashPersistence::persist.hasMac()) { +// mac = ZcodeFlashPersistence::persist.getMac(); +// } else { + mac = macHardCoded; +// } while (!Ethernet .begin(mac, 5000, 5000)) { //TODO: not just loop forever, instead come back later... } @@ -223,7 +223,7 @@ class ZcodeUdpChannel: public ZcodeCommandChannel { slot.fail(BAD_PARAM, "MAC addresses must be 6 bytes long"); return; } else if (slot.getBigField()->getLength() != 0) { - ZcodeFlashPersistence::persist.writeMac(slot.getBigField()->getData()); +// ZcodeFlashPersistence::persist.writeMac(slot.getBigField()->getData()); } out->writeStatus(OK); } @@ -233,11 +233,11 @@ class ZcodeUdpChannel: public ZcodeCommandChannel { Ethernet .init(); uint8_t *mac; uint8_t macHardCoded[6] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xad }; - if (ZcodeFlashPersistence::persist.hasMac()) { - mac = ZcodeFlashPersistence::persist.getMac(); - } else { - mac = macHardCoded; - } +// if (ZcodeFlashPersistence::persist.hasMac()) { +// mac = ZcodeFlashPersistence::persist.getMac(); +// } else { + mac = macHardCoded; +// } while (!Ethernet .begin(mac, 5000, 5000)) { } udp.begin(port); diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dhcp.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dhcp.h index f5834f778..66fc5c4e3 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dhcp.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dhcp.h @@ -175,9 +175,9 @@ class DhcpClass { // DHCP Library v0.3 - April 25, 2009 // Author: Jordan Terrell - blog.jordanterrell.com #include -#include -#include "../../../wiznet-udp/lowlevel/src/Ethernet.h" -#include "../../../wiznet-udp/lowlevel/src/utility/w5100.h" +#include +#include "Ethernet.h" +#include "utility/w5100.h" template int DhcpClass::beginWithDHCP(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dns.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dns.h index ec5217f89..27c58d9ee 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dns.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Dns.h @@ -40,9 +40,9 @@ class DNSClient { // (c) Copyright 2009-2010 MCQN Ltd. // Released under Apache License, version 2.0 -#include "../../../wiznet-udp/lowlevel/src/Ethernet.h" -#include -#include "../../../wiznet-udp/lowlevel/src/utility/w5100.h" +#include "Ethernet.h" +#include +#include "utility/w5100.h" #define SOCKET_NONE 255 // Various flags and header field values for a DNS message @@ -139,7 +139,7 @@ int DNSClient::getHostByName(const char *aHostname, IPAddress &aResult, uint } // Find a socket to use - if (iUdp.begin(1024 + (SystemMilliClock < LL > ::getTimeMillis() & 0xF)) == 1) { + if (iUdp.begin(1024 + (SystemMilliClock::getTimeMillis() & 0xF)) == 1) { // Try up to three times int retries = 0; // while ((retries < 3) && (ret <= 0)) { @@ -193,7 +193,7 @@ uint16_t DNSClient::BuildRequest(const char *aName) // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ // As we only support one request at a time at present, we can simplify // some of this header - iRequestId = SystemMilliClock < LL > ::getTimeMillis(); // generate a random ID + iRequestId = SystemMilliClock::getTimeMillis(); // generate a random ID uint16_t twoByteBuffer; // FIXME We should also check that there's enough space available to write to, rather @@ -252,14 +252,14 @@ uint16_t DNSClient::BuildRequest(const char *aName) template uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress &aAddress) { - uint32_t startTime = SystemMilliClock < LL > ::getTimeMillis(); + uint32_t startTime = SystemMilliClock::getTimeMillis(); // Wait for a response packet while (iUdp.parsePacket() <= 0) { - if ((SystemMilliClock < LL > ::getTimeMillis() - startTime) > aTimeout) { + if ((SystemMilliClock::getTimeMillis() - startTime) > aTimeout) { return TIMED_OUT; } - SystemMilliClock < LL > ::blockDelayMillis(50); + SystemMilliClock::blockDelayMillis(50); } // We've had a reply! diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernet.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernet.h index 7dd78b926..b04b62a0a 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernet.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernet.h @@ -155,9 +155,9 @@ extern EthernetClass Ethernet; #define UDP_TX_PACKET_MAX_SIZE 24 -#include "../../../wiznet-udp/lowlevel/src/socket.h" -#include "../../../wiznet-udp/lowlevel/src/Dhcp.h" -#include "../../../wiznet-udp/lowlevel/src/Dns.h" -#include "../../../wiznet-udp/lowlevel/src/EthernetUdp.h" -#include "../../../wiznet-udp/lowlevel/src/Ethernetcpp.h" +#include "socket.h" +#include "Dhcp.h" +#include "Dns.h" +#include "EthernetUdp.h" +#include "Ethernetcpp.h" #endif diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetClient.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetClient.h index 487d5ad8e..3b4bace66 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetClient.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetClient.h @@ -74,11 +74,11 @@ class EthernetClient: public Client { uint16_t _timeout; }; -#include "../../../wiznet-udp/lowlevel/src/Ethernet.h" -#include "../../../wiznet-udp/lowlevel/src/Client.h" -#include -#include "../../../wiznet-udp/lowlevel/src/Dns.h" -#include "../../../wiznet-udp/lowlevel/src/utility/w5100.h" +#include "Ethernet.h" +#include "Client.h" +#include +#include "Dns.h" +#include "utility/w5100.h" template int EthernetClient::connect(const char *host, uint16_t port) @@ -117,7 +117,7 @@ int EthernetClient::connect(IPAddress ip, uint16_t port) if (sockindex >= MAX_SOCK_NUM) return 0; Ethernet .socketConnect(sockindex, rawIPAddress(ip), port); - uint32_t start = SystemMilliClock < LL > ::getTimeMillis(); + uint32_t start = SystemMilliClock::getTimeMillis(); while (1) { uint8_t stat = Ethernet .socketStatus(sockindex); if (stat == SnSR::ESTABLISHED) @@ -126,9 +126,9 @@ int EthernetClient::connect(IPAddress ip, uint16_t port) return 1; if (stat == SnSR::CLOSED) return 0; - if (SystemMilliClock < LL > ::getTimeMillis() - start > _timeout) + if (SystemMilliClock::getTimeMillis() - start > _timeout) break; - SystemMilliClock < LL > ::blockDelayMillis(1); + SystemMilliClock::blockDelayMillis(1); } Ethernet .socketClose(sockindex); sockindex = MAX_SOCK_NUM; @@ -220,7 +220,7 @@ void EthernetClient::stop() // attempt to close the connection gracefully (send a FIN to other side) Ethernet .socketDisconnect(sockindex); - unsigned long start = SystemMilliClock < LL > ::getTimeMillis(); + unsigned long start = SystemMilliClock::getTimeMillis(); // wait up to a second for the connection to close do { @@ -228,8 +228,8 @@ void EthernetClient::stop() sockindex = MAX_SOCK_NUM; return; // exit the loop } - SystemMilliClock < LL > ::blockDelayMillis(1); - } while (SystemMilliClock < LL > ::getTimeMillis() - start < _timeout); + SystemMilliClock::blockDelayMillis(1); + } while (SystemMilliClock::getTimeMillis() - start < _timeout); // if it hasn't closed, close it forcefully Ethernet .socketClose(sockindex); diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetUdp.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetUdp.h index 244213ebc..8401d073e 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetUdp.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/EthernetUdp.h @@ -141,9 +141,9 @@ class EthernetUDP: public UDP { * bjoern@cs.stanford.edu 12/30/2008 */ -#include "../../../wiznet-udp/lowlevel/src/Ethernet.h" -#include "../../../wiznet-udp/lowlevel/src/Dns.h" -#include "../../../wiznet-udp/lowlevel/src/utility/w5100.h" +#include "Ethernet.h" +#include "Dns.h" +#include "utility/w5100.h" /* Start EthernetUDP socket, listening at local port PORT */ template diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernetcpp.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernetcpp.h index ee76fcea7..dc5bb8762 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernetcpp.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernetcpp.h @@ -20,7 +20,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "../../../../../../../../clock/src/main/c++/clock-ll/SystemMilliClock.hpp" +#include #include "Dhcp.h" #include "Ethernet.h" #include "utility/w5100.h" diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/socket.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/socket.h index 4dab8b3f2..57de87bd1 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/socket.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/socket.h @@ -584,4 +584,4 @@ bool EthernetClass::socketSendUDP(uint8_t s) return true; } -#include "../../../wiznet-udp/lowlevel/src/EthernetServer.h" +#include "EthernetServer.h" diff --git a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/utility/w5100.h b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/utility/w5100.h index e6373fca8..88b5fe594 100644 --- a/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/utility/w5100.h +++ b/receivers/native/arm/peripherals/udp/wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/utility/w5100.h @@ -487,9 +487,8 @@ class W5100Class { * published by the Free Software Foundation. */ -#include "../../../../../../../../wiznet-udp-ll/src/main/c++/wiznet-udp-ll/lowlevel/wiznet-arduino-library-src/Ethernet.h" -#include -#include "../../../../wiznet-udp/lowlevel/src/utility/w5100.h" +#include "../Ethernet.h" +#include #include /***************************************************/ @@ -581,7 +580,7 @@ uint8_t W5100Class::init(void) // case maximum 560 ms pulse length. This delay is meant to wait // until the reset pulse is ended. If your hardware has a shorter // reset time, this can be edited or removed. - SystemMilliClock < LL > ::blockDelayMillis(560); + SystemMilliClock::blockDelayMillis(560); //Serial.println("w5100 init"); SPI .begin(); @@ -697,7 +696,7 @@ uint8_t W5100Class::softReset(void) //Serial.println(mr, HEX); if (mr == 0) return 1; - SystemMilliClock < LL > ::blockDelayMillis(1); + SystemMilliClock::blockDelayMillis(1); } while (++count < 20); return 0; }