From e2347c29d2a9e3061737073dc635dac75a506233 Mon Sep 17 00:00:00 2001 From: Jarrad Ashton Brown Date: Thu, 26 Feb 2026 16:03:14 -0600 Subject: [PATCH] Improve gitignore for PlatformIO + macOS --- .DS_Store | Bin 8196 -> 0 bytes .gitignore | 11 +++++ Source/ports/OpEnerTeensy/.gitignore | 5 -- Source/ports/OpEnerTeensy/src/main.cpp | 62 ++++++++++++++++++++----- 4 files changed, 61 insertions(+), 17 deletions(-) delete mode 100644 .DS_Store create mode 100644 .gitignore delete mode 100644 Source/ports/OpEnerTeensy/.gitignore diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index f206389355fb21e248d87499c398bae3bc2bbb98..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM%}*0S6n_HyYoh z8a1t9z%cM%G9ca$4pxB)jb(-M)q#yn0T64jTNact50EyF#)QVQLTQRVRrWx%DbXng zQRX=A2zA7S#^#NDzclI@n|V+w~lZYxgMi|H1Kj1RTdt5EXPYpUSzpY+NRWi z6|-V#yJKVH)=+s_4oBS12+dZH)B>?{QB*w^oqaA_$#>*p4eENk zeSNf*df7F-Qu4X7(r>n1S!?Wk{e^~$jdoLWOH*r8TU%TErH;#;ombL!OUBKv5#te1(dS+eBk9KmX<;q z&F+%t(spB*4Y==5^3aPs&gK?Eq<=i3tK)2mEe#y#N3J diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea7fba1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# +# macOS junk +.DS_Store +**/.DS_Store + +# PlatformIO build + deps (ANY folder) +**/.pio/ +.platformio/ + +# VS Code (all subprojects) +**/.vscode/ \ No newline at end of file diff --git a/Source/ports/OpEnerTeensy/.gitignore b/Source/ports/OpEnerTeensy/.gitignore deleted file mode 100644 index 89cc49c..0000000 --- a/Source/ports/OpEnerTeensy/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.pio -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/ipch diff --git a/Source/ports/OpEnerTeensy/src/main.cpp b/Source/ports/OpEnerTeensy/src/main.cpp index cad53f9..8284e5a 100644 --- a/Source/ports/OpEnerTeensy/src/main.cpp +++ b/Source/ports/OpEnerTeensy/src/main.cpp @@ -1,21 +1,59 @@ #include +#include -// put function declarations here: -int myFunction(int, int); +using namespace qindesign::network; + +// Network config +IPAddress ip(192, 168, 1, 177); // change to your network +IPAddress gateway(192, 168, 1, 1); +IPAddress subnet(255, 255, 255, 0); + +EthernetUDP udp; +const uint16_t localPort = 2222; // EtherNet/IP uses 2222 (good test) void setup() { - // put your setup code here, to run once: - int result = myFunction(2, 3); + Serial.begin(115200); + delay(2000); + + Serial.println("Starting Ethernet..."); + + Ethernet.begin(ip, subnet, gateway); + + if (!Ethernet.linkStatus()) { + Serial.println("Ethernet cable not connected!"); + } + + Serial.print("IP: "); + Serial.println(Ethernet.localIP()); + + udp.begin(localPort); + + Serial.print("Listening on UDP port: "); + Serial.println(localPort); } void loop() { - // put your main code here, to run repeatedly: - int data = myFunction(50,1); - Serial.print((int)data); - delay(1000); -} + int packetSize = udp.parsePacket(); -// put function definitions here: -int myFunction(int x, int y) { - return x + y; + if (packetSize) { + Serial.print("Received packet: "); + Serial.println(packetSize); + + char buffer[512]; + int len = udp.read(buffer, sizeof(buffer)); + + if (len > 0) { + buffer[len] = 0; + } + + Serial.print("Data: "); + Serial.println(buffer); + + // Echo back + udp.beginPacket(udp.remoteIP(), udp.remotePort()); + udp.write((const uint8_t*)"ACK", 3); + udp.endPacket(); + + Serial.println("Sent ACK"); + } } \ No newline at end of file