libusbの戻り値の意味、およびC言語を使用して対応する戻り値の意味を出力する方法
Meaning Libusb Return Value
最近、jniはAndroidでlibusbを使用しています。 libusbの戻り値の意味はこれまで知られていませんでした。これは次のように構成されています。
/ **成功(エラーなし)* /
LIBUSB_SUCCESS = 0、
/ **入出力エラー* /
LIBUSB_ERROR_IO = -1
/** 無効なパラメーター */
LIBUSB_ERROR_INVALID_PARAM = -2、
/ **アクセスが拒否されました(権限が不十分です)* /
LIBUSB_ERROR_ACCESS = -3、
/ **そのようなデバイスはありません(切断されている可能性があります)* /
LIBUSB_ERROR_NO_DEVICE = -4、
/ **エンティティが見つかりません* /
LIBUSB_ERROR_NOT_FOUND = -5、
/ **リソースがビジーです* /
LIBUSB_ERROR_BUSY = -6、
/ **操作がタイムアウトしました* /
LIBUSB_ERROR_TIMEOUT = -7、
/ **オーバーフロー* /
LIBUSB_ERROR_OVERFLOW = -8、
/ **パイプエラー* /
LIBUSB_ERROR_PIPE = -9、
/ **システムコールが中断されました(おそらくシグナルが原因です)* /
LIBUSB_ERROR_INTERRUPTED = -10、
/ **メモリ不足* /
LIBUSB_ERROR_NO_MEM = -11、
/ **このプラットフォームでは操作がサポートされていないか実装されていません* /
LIBUSB_ERROR_NOT_SUPPORTED = -12、
/ *注意:以下のLIBUSB_ERROR_COUNTと、
ここに新しいエラーコードを追加するときのstrerror.cのメッセージ文字列。 * /
/ **その他のエラー* /
LIBUSB_ERROR_OTHER = -99、
C言語は、戻り値に基づいて戻り値の意味を直接出力する必要があります。
libusb_strerror
/** ingroup libusb_misc * Error codes. Most libusb functions return 0 on success or one of these * codes on failure. * You can call libusb_error_name() to retrieve a string representation of an * error code or libusb_strerror() to get an end-user suitable description of * an error code. */ enum libusb_error { /** Success (no error) */ LIBUSB_SUCCESS = 0, /** Input/output error */ LIBUSB_ERROR_IO = -1, /** Invalid parameter */ LIBUSB_ERROR_INVALID_PARAM = -2, /** Access denied (insufficient permissions) */ LIBUSB_ERROR_ACCESS = -3, /** No such device (it may have been disconnected) */ LIBUSB_ERROR_NO_DEVICE = -4, /** Entity not found */ LIBUSB_ERROR_NOT_FOUND = -5, /** Resource busy */ LIBUSB_ERROR_BUSY = -6, /** Operation timed out */ LIBUSB_ERROR_TIMEOUT = -7, /** Overflow */ LIBUSB_ERROR_OVERFLOW = -8, /** Pipe error */ LIBUSB_ERROR_PIPE = -9, /** System call interrupted (perhaps due to signal) */ LIBUSB_ERROR_INTERRUPTED = -10, /** Insufficient memory */ LIBUSB_ERROR_NO_MEM = -11, /** Operation not supported or unimplemented on this platform */ LIBUSB_ERROR_NOT_SUPPORTED = -12, /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the message strings in strerror.c when adding new error codes here. */ /** Other error */ LIBUSB_ERROR_OTHER = -99, } int iResult = 0 iResult = libusb_claim_interface(handle, 0) printf('libusb result: %s
', libusb_strerror((enum libusb_error)iResult))