11import select
22import socket
33import time
4+ import platform
45from abc import ABC , abstractmethod
56from socket import SocketType
67from threading import Event , Lock
@@ -145,8 +146,10 @@ def __init__(
145146 # The socket buffer can be made large enough that we don't need a reader thread.
146147 self .socket_in .setsockopt (socket .SOL_SOCKET , socket .SO_SNDBUF , MAX_DATA_BUFFER_SIZE )
147148 self .socket_in .setblocking (False )
148- enable_socket_timestamping (self .socket_in , enable_sw_timestamp = True ,
149- enable_hw_timestamp = False ) # type: ignore
149+ # This is not supported in windows
150+ if platform .system () != "Windows" :
151+ enable_socket_timestamping (self .socket_in , enable_sw_timestamp = True ,
152+ enable_hw_timestamp = False ) # type: ignore
150153
151154 self .rx_log = rx_log
152155
@@ -160,8 +163,12 @@ def read(self, size: int, timeout=RESPONSE_TIMEOUT, return_any: bool = False) ->
160163 while len (all_data ) < size and remaining >= 0 :
161164 ready = select .select ([self .socket_in ], [], [], remaining )
162165 if ready [0 ]:
163- data , ancdata , _ , _ = self .socket_in .recvmsg (size - len (all_data ), 1024 )
164- kernel_ts , _ , _ = parse_timestamps_from_ancdata (ancdata )
166+ kernel_ts = None
167+ if hasattr (self .socket_in , "recvmsg" ):
168+ data , ancdata , _ , _ = self .socket_in .recvmsg (size - len (all_data ), 1024 )
169+ kernel_ts , _ , _ = parse_timestamps_from_ancdata (ancdata )
170+ else :
171+ data = self .socket_in .recv (size - len (all_data ))
165172 if kernel_ts :
166173 self .last_rx_data_posix_timestamp_sec = kernel_ts
167174
0 commit comments