code: def _calculateLrcString(inputstring):
      
      _checkString(inputstring, description='input LRC string')
  
      register = 0
      for character in inputstring:
          register += ord(character)
  
      lrc = ((register ^ 0xFF) + 1) & 0xFF
  
      lrcString = _numToOneByteString(lrc)
      return lrcString
docs: Calculate LRC for Modbus.
  
      Args:
          inputstring (str): An arbitrary-length message (without the beginning
          colon and terminating CRLF). It should already be decoded from hex-string.
  
      Returns:
          A one-byte LRC bytestring (not encoded to hex-string)
  
      Algorithm from the document 'MODBUS over serial line specification and implementation guide V1.02'.
  
      The LRC is calculated as 8 bits (one byte).
  
      For example a LRC 0110 0001 (bin) = 61 (hex) = 97 (dec) = 'a'. This function will
      then return 'a'.
  
      In Modbus ASCII mode, this should be transmitted using two characters. This
      example should be transmitted '61', which is a string of length two. This function
      does not handle that conversion for transmission.