@@ -51,6 +51,9 @@ def _set_special_baudrate(self, baudrate):
5151 def _set_rs485_mode (self , rs485_settings ):
5252 raise NotImplementedError ('RS485 not supported on this platform' )
5353
54+ def set_low_latency_mode (self , low_latency_settings ):
55+ raise NotImplementedError ('Low latency not supported on this platform' )
56+
5457
5558# some systems support an extra flag to enable the two in POSIX unsupported
5659# paritiy settings for MARK and SPACE
@@ -115,6 +118,24 @@ class PlatformSpecific(PlatformSpecificBase):
115118 4000000 : 0o010017
116119 }
117120
121+ def set_low_latency_mode (self , low_latency_settings ):
122+ buf = array .array ('i' , [0 ] * 32 )
123+
124+ try :
125+ # get serial_struct
126+ fcntl .ioctl (self .fd , termios .TIOCGSERIAL , buf )
127+
128+ # set or unset ASYNC_LOW_LATENCY flag
129+ if low_latency_settings :
130+ buf [4 ] |= 0x2000
131+ else :
132+ buf [4 ] &= ~ 0x2000
133+
134+ # set serial_struct
135+ fcntl .ioctl (self .fd , termios .TIOCSSERIAL , buf )
136+ except IOError as e :
137+ raise ValueError ('Failed to update ASYNC_LOW_LATENCY flag to {}: {}' .format (low_latency_settings , e ))
138+
118139 def _set_special_baudrate (self , baudrate ):
119140 # right size is 44 on x86_64, allow for some growth
120141 buf = array .array ('i' , [0 ] * 64 )
0 commit comments