25 lines
625 B
Python
Executable File
25 lines
625 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import socket
|
|
import time
|
|
import struct
|
|
|
|
def send_test_packets():
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
pico_address = ('192.168.128.1', 4243) # Adresse IP du Pico W
|
|
|
|
packet_number = 0
|
|
instruction = 0
|
|
|
|
while True:
|
|
# Créer le message binaire
|
|
message = struct.pack('BB', packet_number, instruction)
|
|
sock.sendto(message, pico_address)
|
|
|
|
packet_number = (packet_number + 1) % 256
|
|
instruction = (instruction + 1) % 256
|
|
|
|
time.sleep(3.5)
|
|
|
|
if __name__ == '__main__':
|
|
send_test_packets() |