-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtrack_sim.py
More file actions
29 lines (23 loc) · 771 Bytes
/
Copy pathmtrack_sim.py
File metadata and controls
29 lines (23 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import socket
import time
# Server address and port
host = "localhost"
port = 23304
# Message to be sent
message = "#860186023032004#MT700#0000#AUTO#1\r\n#33$GPRMC,082947.00,A,1045.6411,N,10650.8207,E,8.50,121.40,071024,,,A*5A\r\n##\r\n"
def send_message():
# Create a socket object
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
# Connect to the server
s.connect((host, port))
# Send the message
s.sendall(message.encode())
print(f"Message sent to {host}:{port}")
except Exception as e:
print(f"Failed to send message: {e}")
def main():
send_message()
# Wait for 10 seconds before sending the next message
if __name__ == "__main__":
main()