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