Skip to content

Commit 22b1ad0

Browse files
authored
Merge pull request #51 from bobjacobsen/add-close
Add close() method to TCP, USB connections
2 parents c8753d6 + 891cbe0 commit 22b1ad0

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

openlcb/canbus/seriallink.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ def receive(self):
6565
if 0x3B in chunk:
6666
break
6767
return (b''.join(chunks)).decode("utf-8")
68+
69+
def close(self):
70+
self.port.close()
71+
return

openlcb/tcplink/tcpsocket.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ def receive(self):
5050
if chunk == b'':
5151
raise RuntimeError("socket connection broken")
5252
return list(chunk) # convert from bytes
53+
54+
def close(self):
55+
self.sock.close()
56+
return

0 commit comments

Comments
 (0)