flandre/test/testrobotremotecontrol.py
2025-03-23 22:33:55 +08:00

24 lines
621 B
Python

import socket
from time import sleep
def send_message(message: str, host='11.6.1.53', port=29999):
# Create a TCP/IP socket
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect to the server
client_socket.connect((host, port))
try:
# Send the message
client_socket.sendall(message.encode())
print(f"Sent: {message}")
finally:
# Close the socket
client_socket.close()
if __name__ == "__main__":
# send_message('remoteControl -on\nplay\nremoteControl -off\n')
send_message('remoteControl -on\nstop\nremoteControl -off\n')