code: def _embedPayload(slaveaddress, mode, functioncode, payloaddata):
      
      _checkSlaveaddress(slaveaddress)
      _checkMode(mode)
      _checkFunctioncode(functioncode, None)
      _checkString(payloaddata, description='payload')
  
      firstPart = _numToOneByteString(slaveaddress) + _numToOneByteString(functioncode) + payloaddata
  
      if mode == MODE_ASCII:
          request = _ASCII_HEADER + \
                  _hexencode(firstPart) + \
                  _hexencode(_calculateLrcString(firstPart)) + \
                  _ASCII_FOOTER
      else:
          request = firstPart + _calculateCrcString(firstPart)
  
      return request
docs: Build a request from the slaveaddress, the function code and the payload data.
  
      Args:
          * slaveaddress (int): The address of the slave.
          * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
          * functioncode (int): The function code for the command to be performed. Can for example be 16 (Write register).
          * payloaddata (str): The byte string to be sent to the slave.
  
      Returns:
          The built (raw) request string for sending to the slave (including CRC etc).
  
      Raises:
          ValueError, TypeError.
  
      The resulting request has the format:
       * RTU Mode: slaveaddress byte + functioncode byte + payloaddata + CRC (which is two bytes).
       * ASCII Mode: header (:) + slaveaddress (2 characters) + functioncode (2 characters) + payloaddata + LRC (which is two characters) + footer (CRLF)
  
      The LRC or CRC is calculated from the byte string made up of slaveaddress + functioncode + payloaddata.
      The header, LRC/CRC, and footer are excluded from the calculation.