-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathantenna
More file actions
46 lines (35 loc) · 1.05 KB
/
Copy pathantenna
File metadata and controls
46 lines (35 loc) · 1.05 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import socket
import os
import time
import threading
import sys
# msg='t'
HEADER =100
PORT =5005
# Below is port for LAN to UART
# PORT=5005
FORMAT = 'utf-8'
DISCONNECT_MESSAGE ="!DISCONNECT"
class Comm():
def __init__(self):
self.SERVER = socket.gethostbyname(socket.gethostname())
# Below is IP for LAN to UART
self.SERVER="192.168.1.7"
self.ADDR=(self.SERVER,PORT)
self.client =socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.client.connect(self.ADDR)
# ps4.a.camera_2.setText("Hello")
def send(self,msg):
self.message=msg.encode(FORMAT)
self.msg_length=len(self.message)
self.send_length=str(self.msg_length).encode(FORMAT)
#We are padding spaces to make message 64 bytes
self.send_length +=b' '*(HEADER-len(self.send_length))
self.client.send(self.send_length)
self.client.sendall(self.message)
def SendMsg(self,msg):
comm.send(msg)
print(msg)
comm=Comm()
while(1):
comm.SendMsg('t')