parameters: (self)
docstring: \
          get last modem state (cached value. if value is "old", request a new
          one. this cache helps that we don't issue to many requests when e.g. all
          status lines, one after the other is queried by te user (getCTS, getDSR
          etc.)
docstring_summary: \
          get last modem state (cached value. if value is "old", request a new
          one. this cache helps that we don't issue to many requests when e.g. all
          status lines, one after the other is queried by te user (getCTS, getDSR
          etc.)
docstring_tokens: \ get last modem state ( cached value . if value is old request a new one . this cache helps that we don t issue to many requests when e . g . all status lines one after the other is queried by te user ( getCTS getDSR etc . )
function: def getModemState(self):
          """\
          get last modem state (cached value. if value is "old", request a new
          one. this cache helps that we don't issue to many requests when e.g. all
          status lines, one after the other is queried by te user (getCTS, getDSR
          etc.)
          """
          # active modem state polling enabled? is the value fresh enough?
          if self._poll_modem_state and self._modemstate_expires < time.time():
              if self.logger:
                  self.logger.debug('polling modem state')
              # when it is older, request an update
              self.rfc2217SendSubnegotiation(NOTIFY_MODEMSTATE)
              timeout_time = time.time() + self._network_timeout
              while time.time() < timeout_time:
                  time.sleep(0.05)    # prevent 100% CPU load
                  # when expiration time is updated, it means that there is a new
                  # value
                  if self._modemstate_expires > time.time():
                      if self.logger:
                          self.logger.warning('poll for modem state failed')
                      break
              # even when there is a timeout, do not generate an error just
              # return the last known value. this way we can support buggy
              # servers that do not respond to polls, but send automatic
              # updates.
          if self._modemstate is not None:
              if self.logger:
                  self.logger.debug('using cached modem state')
              return self._modemstate
          else:
              # never received a notification from the server
              raise SerialException("remote sends no NOTIFY_MODEMSTATE")
function_tokens: def getModemState ( self ) : # active modem state polling enabled? is the value fresh enough? if self . _poll_modem_state and self . _modemstate_expires < time . time ( ) : if self . logger : self . logger . debug ( 'polling modem state' ) # when it is older, request an update self . rfc2217SendSubnegotiation ( NOTIFY_MODEMSTATE ) timeout_time = time . time ( ) + self . _network_timeout while time . time ( ) < timeout_time : time . sleep ( 0.05 ) # prevent 100% CPU load # when expiration time is updated, it means that there is a new # value if self . _modemstate_expires > time . time ( ) : if self . logger : self . logger . warning ( 'poll for modem state failed' ) break # even when there is a timeout, do not generate an error just # return the last known value. this way we can support buggy # servers that do not respond to polls, but send automatic # updates. if self . _modemstate is not None : if self . logger : self . logger . debug ( 'using cached modem state' ) return self . _modemstate else : # never received a notification from the server raise SerialException ( "remote sends no NOTIFY_MODEMSTATE" )