mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
libfxlink: return status from fxlink_device_start_bulk_{IN,OUT}
This commit is contained in:
parent
1573db3860
commit
1251ca23ee
2 changed files with 14 additions and 11 deletions
|
@ -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)
|
if(!fdev->comm || !fdev->comm->claimed || fdev->comm->tr_bulk_IN)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
fdev->comm->tr_bulk_IN = libusb_alloc_transfer(0);
|
fdev->comm->tr_bulk_IN = libusb_alloc_transfer(0);
|
||||||
if(!fdev->comm->tr_bulk_IN) {
|
if(!fdev->comm->tr_bulk_IN) {
|
||||||
elog("allocation of bulk IN transfer failed\n");
|
elog("allocation of bulk IN transfer failed\n");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(fdev->comm->tr_bulk_IN,
|
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) {
|
if(rc < 0) {
|
||||||
elog_libusb(rc, "bulk IN transfer failed to submit");
|
elog_libusb(rc, "bulk IN transfer failed to submit");
|
||||||
fdev->status = FXLINK_FDEV_STATUS_ERROR;
|
fdev->status = FXLINK_FDEV_STATUS_ERROR;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hlog("calculators %s", fxlink_device_id(fdev));
|
// hlog("calculators %s", fxlink_device_id(fdev));
|
||||||
// log_("submitted new IN transfer (no timeout)\n");
|
// log_("submitted new IN transfer (no timeout)\n");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fxlink_message *fxlink_device_finish_bulk_IN(struct fxlink_device *fdev)
|
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,
|
char const *app, char const *type, void const *data, int size,
|
||||||
bool own_data)
|
bool own_data)
|
||||||
{
|
{
|
||||||
struct fxlink_comm *comm = fdev->comm;
|
struct fxlink_comm *comm = fdev->comm;
|
||||||
if(!comm || !comm->claimed || comm->ftransfer_OUT)
|
if(!comm || !comm->claimed || comm->ftransfer_OUT)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
comm->ftransfer_OUT =
|
comm->ftransfer_OUT =
|
||||||
fxlink_transfer_make_OUT(app, type, data, size, own_data);
|
fxlink_transfer_make_OUT(app, type, data, size, own_data);
|
||||||
if(!comm->ftransfer_OUT) {
|
if(!comm->ftransfer_OUT) {
|
||||||
elog("allocation of OUT transfer (protocol) failed\n");
|
elog("allocation of OUT transfer (protocol) failed\n");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
comm->tr_bulk_OUT = libusb_alloc_transfer(0);
|
comm->tr_bulk_OUT = libusb_alloc_transfer(0);
|
||||||
if(!comm->tr_bulk_OUT) {
|
if(!comm->tr_bulk_OUT) {
|
||||||
elog("allocation of bulk OUT transfer (libusb) failed\n");
|
elog("allocation of bulk OUT transfer (libusb) failed\n");
|
||||||
free(comm->ftransfer_OUT);
|
free(comm->ftransfer_OUT);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(comm->tr_bulk_OUT, fdev->dh,
|
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) {
|
if(rc < 0) {
|
||||||
elog_libusb(rc, "bulk OUT transfer failed to submit");
|
elog_libusb(rc, "bulk OUT transfer failed to submit");
|
||||||
fdev->status = FXLINK_FDEV_STATUS_ERROR;
|
fdev->status = FXLINK_FDEV_STATUS_ERROR;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---
|
//---
|
||||||
|
|
|
@ -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
|
/* 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. */
|
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
|
/* 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
|
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
|
/* Start an OUT transfer on the device. If `own_data` is set, the transfer will
|
||||||
free(data) when it completes. */
|
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,
|
char const *app, char const *type, void const *data, int size,
|
||||||
bool own_data);
|
bool own_data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue