<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read(device):
 """ Reads data from the specified device. :param device: the AlarmDecoder device :type device: :py:class:`~alarmdecoder.devices.Device` :returns: string """

        response = None
        bytes_avail = bytes_available(device)

        if isinstance(device, alarmdecoder.devices.SerialDevice):
            response = device._device.read(bytes_avail)
        elif isinstance(device, alarmdecoder.devices.SocketDevice):
            response = device._device.recv(bytes_avail)

        return response