Skip to content

Commit 9438305

Browse files
committed
Change the socket sending style
1 parent 0cd5e1d commit 9438305

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

demo/Client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
from pymycobot import MyCobotSocket
55

66
m = MyCobotSocket("192.168.10.10", "9000")
7-
m.connect()
7+
# connect pi
8+
# m.connect()
89
print(m.get_coords())

pymycobot/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def _process_single(self, data):
186186

187187
def write(self, command, method=None):
188188
if method == "socket":
189-
self.sock.sendall(str(command).encode())
189+
self.sock.sendall(bytes(command))
190190
data = self.sock.recv(1024)
191191
return data
192192
else:

pymycobot/mycobotsocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MyCobotSocket(MyCobotCommandGenerator):
4848
_write = write
4949
_read = read
5050

51-
def __init__(self, ip, netport):
51+
def __init__(self, ip, netport=9000):
5252
"""
5353
Args:
5454
ip: Server ip
@@ -57,7 +57,7 @@ def __init__(self, ip, netport):
5757
super(MyCobotSocket, self).__init__()
5858
self.calibration_parameters = calibration_parameters
5959
self.SERVER_IP = ip
60-
self.SERVER_PORT = 9000
60+
self.SERVER_PORT = netport
6161
self.sock = self.connect_socket()
6262

6363
def connect(self, serialport="/dev/ttyAMA0", baudrate="1000000", timeout='0.1'):

0 commit comments

Comments
 (0)