diff --git a/libfxlink/devices.c b/libfxlink/devices.c index 9dff247..6f0952c 100644 --- a/libfxlink/devices.c +++ b/libfxlink/devices.c @@ -438,15 +438,15 @@ static void bulk_IN_callback(struct libusb_transfer *transfer) } } -void fxlink_device_start_bulk_IN(struct fxlink_device *fdev) +bool fxlink_device_start_bulk_IN(struct fxlink_device *fdev) { if(!fdev->comm || !fdev->comm->claimed || fdev->comm->tr_bulk_IN) - return; + return false; fdev->comm->tr_bulk_IN = libusb_alloc_transfer(0); if(!fdev->comm->tr_bulk_IN) { elog("allocation of bulk IN transfer failed\n"); - return; + return false; } libusb_fill_bulk_transfer(fdev->comm->tr_bulk_IN, @@ -462,11 +462,12 @@ void fxlink_device_start_bulk_IN(struct fxlink_device *fdev) if(rc < 0) { elog_libusb(rc, "bulk IN transfer failed to submit"); fdev->status = FXLINK_FDEV_STATUS_ERROR; - return; + return false; } // hlog("calculators %s", fxlink_device_id(fdev)); // log_("submitted new IN transfer (no timeout)\n"); + return true; } struct fxlink_message *fxlink_device_finish_bulk_IN(struct fxlink_device *fdev) @@ -552,26 +553,26 @@ static void bulk_OUT_callback(struct libusb_transfer *transfer) } } -void fxlink_device_start_bulk_OUT(struct fxlink_device *fdev, +bool fxlink_device_start_bulk_OUT(struct fxlink_device *fdev, char const *app, char const *type, void const *data, int size, bool own_data) { struct fxlink_comm *comm = fdev->comm; if(!comm || !comm->claimed || comm->ftransfer_OUT) - return; + return false; comm->ftransfer_OUT = fxlink_transfer_make_OUT(app, type, data, size, own_data); if(!comm->ftransfer_OUT) { elog("allocation of OUT transfer (protocol) failed\n"); - return; + return false; } comm->tr_bulk_OUT = libusb_alloc_transfer(0); if(!comm->tr_bulk_OUT) { elog("allocation of bulk OUT transfer (libusb) failed\n"); free(comm->ftransfer_OUT); - return; + return false; } libusb_fill_bulk_transfer(comm->tr_bulk_OUT, fdev->dh, @@ -588,8 +589,10 @@ void fxlink_device_start_bulk_OUT(struct fxlink_device *fdev, if(rc < 0) { elog_libusb(rc, "bulk OUT transfer failed to submit"); fdev->status = FXLINK_FDEV_STATUS_ERROR; - return; + return false; } + + return true; } //--- diff --git a/libfxlink/include/fxlink/devices.h b/libfxlink/include/fxlink/devices.h index 5406374..5675f5e 100644 --- a/libfxlink/include/fxlink/devices.h +++ b/libfxlink/include/fxlink/devices.h @@ -201,7 +201,7 @@ bool fxlink_device_claim_fxlink(struct fxlink_device *fdev); /* Start an IN transfer on the device if none is currently running, so that the device structure is always ready to receive data from the calculator. */ -void fxlink_device_start_bulk_IN(struct fxlink_device *fdev); +bool fxlink_device_start_bulk_IN(struct fxlink_device *fdev); /* Finish an IN transfer and obtain the completed message. This function should be checked every frame as it will return a non-NULL pointer as soon as the @@ -212,7 +212,7 @@ struct fxlink_message *fxlink_device_finish_bulk_IN( /* Start an OUT transfer on the device. If `own_data` is set, the transfer will free(data) when it completes. */ -void fxlink_device_start_bulk_OUT(struct fxlink_device *fdev, +bool fxlink_device_start_bulk_OUT(struct fxlink_device *fdev, char const *app, char const *type, void const *data, int size, bool own_data);