first and working ethernet

This commit is contained in:
2025-07-26 21:48:13 -04:00
commit 473f9013c0
58 changed files with 3405 additions and 0 deletions

76
network_scan.py Normal file
View File

@@ -0,0 +1,76 @@
#!/usr/bin/env python3
"""
Scan the local network to see what devices are active
"""
import subprocess
import sys
import ipaddress
def scan_network():
"""Scan the 192.168.1.x network"""
print("Scanning 192.168.1.0/24 network...")
# Use nmap if available, otherwise use ping
try:
result = subprocess.run(['nmap', '-sn', '192.168.1.0/24'],
capture_output=True, text=True, timeout=30)
if result.returncode == 0:
print("Active hosts (nmap):")
print(result.stdout)
else:
print("nmap failed, trying ping scan...")
ping_scan()
except FileNotFoundError:
print("nmap not found, using ping scan...")
ping_scan()
def ping_scan():
"""Ping scan 192.168.1.1-254"""
active_hosts = []
for i in range(1, 255):
ip = f"192.168.1.{i}"
try:
result = subprocess.run(['ping', '-c', '1', '-W', '1000', ip],
capture_output=True, timeout=2)
if result.returncode == 0:
active_hosts.append(ip)
print(f"{ip} is active")
except subprocess.TimeoutExpired:
pass
except Exception:
pass
print(f"\nFound {len(active_hosts)} active hosts:")
for host in active_hosts:
print(f" {host}")
def check_arp():
"""Check ARP table for RP2040-ETH"""
print("\nChecking ARP table for RP2040-ETH...")
try:
result = subprocess.run(['arp', '-a'], capture_output=True, text=True)
lines = result.stdout.split('\n')
rp2040_found = False
for line in lines:
if '192.168.1.20' in line or '192.168.1.201' in line:
print(f"Found: {line}")
rp2040_found = True
if not rp2040_found:
print("RP2040-ETH not found in ARP table")
except Exception as e:
print(f"ARP check failed: {e}")
if __name__ == "__main__":
scan_network()
check_arp()
print("\nNext steps:")
print("1. Check if 192.168.1.201 appears in the scan")
print("2. Try: ping 192.168.1.201")
print("3. Monitor serial output from RP2040-ETH for debug info")
print("4. Check ethernet cable connection")