File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -62,14 +62,16 @@ def listPorts(self):
62
62
return glob .glob ('/dev/ttyACM*' ) + glob .glob ('/dev/ttyUSB*' )
63
63
64
64
def connectToPort (self , portname ):
65
- import socket
66
- try :
67
- self .blockingSocket = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
68
- self .blockingSocket .bind ('\0 PSghhhLab%s' % portname )
69
- self .blockingSocket .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
70
- except socket .error as e :
71
- self .occupiedPorts .add (portname )
72
- raise RuntimeError ("Another program is using %s (%d)" % (portname ))
65
+ import platform
66
+ if platform .system () not in ["Windows" , "Darwin" ]:
67
+ import socket
68
+ try :
69
+ self .blockingSocket = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
70
+ self .blockingSocket .bind ('\0 PSghhhLab%s' % portname )
71
+ self .blockingSocket .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
72
+ except socket .error as e :
73
+ self .occupiedPorts .add (portname )
74
+ raise RuntimeError ("Another program is using %s (%d)" % (portname ))
73
75
74
76
fd = serial .Serial (portname , 9600 , stopbits = 1 , timeout = 0.02 )
75
77
fd .read (100 )
You can’t perform that action at this time.
0 commit comments