Skip to content

Commit

Permalink
Merge pull request #51 from bobjacobsen/add-close
Browse files Browse the repository at this point in the history
Add close() method to TCP, USB connections
  • Loading branch information
bobjacobsen authored Aug 27, 2024
2 parents c8753d6 + 891cbe0 commit 22b1ad0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openlcb/canbus/seriallink.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ def receive(self):
if 0x3B in chunk:
break
return (b''.join(chunks)).decode("utf-8")

def close(self):
self.port.close()
return
4 changes: 4 additions & 0 deletions openlcb/tcplink/tcpsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ def receive(self):
if chunk == b'':
raise RuntimeError("socket connection broken")
return list(chunk) # convert from bytes

def close(self):
self.sock.close()
return

0 comments on commit 22b1ad0

Please sign in to comment.