2017-06-12 01:06:23 +02:00
|
|
|
/* ****************************************************************************
|
2018-06-18 15:30:16 +02:00
|
|
|
* stream/open_usb.c -- open a USB stream.
|
2017-06-12 01:06:23 +02:00
|
|
|
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
|
|
*
|
|
|
|
* This file is part of libcasio.
|
|
|
|
* libcasio is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3.0 of the License,
|
|
|
|
* or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* libcasio is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with libcasio; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ************************************************************************* */
|
2019-05-25 03:36:14 +02:00
|
|
|
#include "stream.h"
|
2017-06-12 01:06:23 +02:00
|
|
|
|
|
|
|
/**
|
2019-04-10 08:08:38 +02:00
|
|
|
* casio_open_native_usb_stream:
|
2017-06-12 01:06:23 +02:00
|
|
|
* Open the USB stream.
|
|
|
|
*
|
|
|
|
* @arg stream the stream to make.
|
2018-05-06 19:08:28 +02:00
|
|
|
* @arg bus the USB bus on which to find the device.
|
|
|
|
* -1 if any device on any bus (and address is not read).
|
|
|
|
* @arg address the address on the bus of the device.
|
|
|
|
* -1 if any device on the bus.
|
2017-06-12 01:06:23 +02:00
|
|
|
* @return the error code (0 if ok).
|
|
|
|
*/
|
|
|
|
|
2019-04-10 08:08:38 +02:00
|
|
|
int CASIO_EXPORT casio_open_native_usb_stream(tio_stream_t **streamp,
|
2018-05-06 19:08:28 +02:00
|
|
|
int bus, int address)
|
2017-06-12 01:06:23 +02:00
|
|
|
{
|
2018-05-06 19:08:28 +02:00
|
|
|
if (bus < -1 || bus > 255 || address < -1 || address > 255)
|
|
|
|
return (casio_error_op);
|
2019-04-10 08:08:38 +02:00
|
|
|
if (!open_native_usb_stream_func)
|
2017-06-12 01:06:23 +02:00
|
|
|
return (casio_error_op);
|
2018-05-06 19:08:28 +02:00
|
|
|
|
2019-04-10 08:08:38 +02:00
|
|
|
return ((*open_native_usb_stream_func)(streamp, bus, address));
|
2017-06-12 01:06:23 +02:00
|
|
|
}
|