Skip to content

Add Windows support and native PlatformIO test coverage - #24

Merged
pschatzmann merged 7 commits into
pschatzmann:mainfrom
yanxke:yan/windows-port
Sep 3, 2026
Merged

Add Windows support and native PlatformIO test coverage#24
pschatzmann merged 7 commits into
pschatzmann:mainfrom
yanxke:yan/windows-port

Conversation

@yanxke

@yanxke yanxke commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Windows support to the desktop Arduino emulator while preserving the existing POSIX/Linux implementation. Tested on both Windows and Ubuntu.

Changes

  • Fix RingBufferExt handling of valid 0x00 payload bytes.
  • Add platform detection and cross-platform socket abstractions.
  • Implement Windows Winsock support.
  • Split POSIX and Windows Ethernet server implementations.
  • Make UDP networking cross-platform and correctly handle hostname resolution, non-blocking reads, socket errors, and send/receive loopback traffic.
  • Add Windows serial support, including COM ports 10 and above.
  • Make physical serial devices opt-in when running on Windows.
  • Add Windows-compatible SD directory creation.
  • Add a native PlatformIO example and Unity test suite.

Testing

Verified with:
pio test -e native
All 9 native tests passed, including GPIO delegation, SD filesystem operations, UDP loopback, TCP loopback, socket error mapping, Arduino types, and timing behavior.

@pschatzmann

Copy link
Copy Markdown
Owner

Review of PR #24 found 4 issues, ranked by severity:

  • entry.cpp:20 — Windows WinMain calls setup()/loop() directly, skipping hardwareSetup() that the POSIX path runs via Main.cpp. On Windows builds with USE_RPI/USE_FTDI/USE_REMOTE, hardware peripherals never get initialized.
  • SocketImplWindows.cpp:1184 — getIPAddress(validEntries[]) on Windows ignores the interface filter entirely, always returning the hostname's address instead of matching POSIX's interface-selection behavior.
  • EthernetServerWindows.h:725 — Windows begin_() swallows listen failures silently (no Logger.error), unlike POSIX which logs "listen failed" — makes port-in-use failures hard to diagnose.
    Simplification (1):
  • . Serial.h:36 — The new #if ARDUINO_EMULATOR_WINDOWS/#else branches are identical, dead conditional code that risks silent divergence on future edits.

@yanxke

yanxke commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Review of PR #24 found 4 issues, ranked by severity:

  • entry.cpp:20 — Windows WinMain calls setup()/loop() directly, skipping hardwareSetup() that the POSIX path runs via Main.cpp. On Windows builds with USE_RPI/USE_FTDI/USE_REMOTE, hardware peripherals never get initialized.
  • SocketImplWindows.cpp:1184 — getIPAddress(validEntries[]) on Windows ignores the interface filter entirely, always returning the hostname's address instead of matching POSIX's interface-selection behavior.
  • EthernetServerWindows.h:725 — Windows begin_() swallows listen failures silently (no Logger.error), unlike POSIX which logs "listen failed" — makes port-in-use failures hard to diagnose.
    Simplification (1):
  • . Serial.h:36 — The new #if ARDUINO_EMULATOR_WINDOWS/#else branches are identical, dead conditional code that risks silent divergence on future edits.

All addressed.

@pschatzmann
pschatzmann merged commit 115fe2f into pschatzmann:main Sep 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants