def write_uint16(self, value, little_endian=True):
        """
        Pack the value as an unsigned integer and write 2 bytes to the stream.

        Args:
            value:
            little_endian (bool): specify the endianness. (Default) Little endian.

        Returns:
            int: the number of bytes written.
        """
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.pack('%sH' % endian, value)
Pack the value as an unsigned integer and write 2 bytes to the stream.

        Args:
            value:
            little_endian (bool): specify the endianness. (Default) Little endian.

        Returns:
            int: the number of bytes written.