       # ParamMetaData (TYPE_INFO)
       buffer.writeUInt8(@.id)
       if length <= @maximumLength
-        buffer.writeUInt16LE(length)
+        buffer.writeUInt16LE(@maximumLength)
       else
         buffer.writeUInt16LE(MAX)
       buffer.writeBuffer(new Buffer([0x00, 0x00, 0x00, 0x00, 0x00])) # Collation
 
       # ParamLenData
-      if parameter.value
+      if parameter.value?
         if length <= @maximumLength
           buffer.writeUInt16LE(length)
           buffer.writeString(parameter.value, 'ucs2')

      # ParamMetaData (TYPE_INFO)
      buffer.writeUInt8(@.id)
      if length <= @maximumLength
        buffer.writeUInt16LE(length)
      else
        buffer.writeUInt16LE(MAX)
      buffer.writeBuffer(new Buffer([0x00, 0x00, 0x00, 0x00, 0x00]))

      # ParamLenData
      if parameter.value
        if length <= @maximumLength
          buffer.writeUInt16LE(length)
          buffer.writeString(parameter.value, 'ascii')

    writeParameterData: (buffer, parameter) ->
      if parameter.length
        length = parameter.length
      else if parameter.value?
        length = parameter.value.length
      else
        length = @.maximumLength
