Godot + Arduino series: companion project code
Self-contained project code for the "Godot Isn't Just for Games" series: Arduino sketches, the Python serial<->UDP bridge, and the Godot 4 projects, one folder per article.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
ledtest.py — isolate the bridge's receive path from Godot.
|
||||
|
||||
Sends a single LED command straight to the bridge's command port, exactly like
|
||||
Godot does. If the running bridge prints "cmd L1 ... -> serial" (and the LED
|
||||
lights), the bridge's receive side is fine and any failure is on Godot's end.
|
||||
If the bridge stays silent even for this, the problem is the bridge/binding.
|
||||
|
||||
Usage (with bridge.py already running):
|
||||
python ledtest.py L1 # turn LED on
|
||||
python ledtest.py L0 # turn LED off
|
||||
"""
|
||||
|
||||
import socket
|
||||
import sys
|
||||
|
||||
msg = (sys.argv[1] if len(sys.argv) > 1 else "L1").encode()
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.sendto(msg, ("127.0.0.1", 4243))
|
||||
print(f"sent {msg!r} to 127.0.0.1:4243")
|
||||
Reference in New Issue
Block a user