本文整理汇总了C++中USBDevice::bulkWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ USBDevice::bulkWrite方法的具体用法?C++ USBDevice::bulkWrite怎么用?C++ USBDevice::bulkWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USBDevice
的用法示例。
在下文中一共展示了USBDevice::bulkWrite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getUSBDevice
JNIEXPORT jint JNICALL Java_com_stericsson_sdk_equipment_io_usb_internal_USBNativeDevice_write(
JNIEnv *env, jobject src, jbyteArray data, jint offset, jint length,
jint timeout) {
try {
USBDevice *device = getUSBDevice(env, src);
if (device) {
jsize dataLength = env->GetArrayLength(data);
if ((offset < 0) || ((offset + length) > dataLength)) {
std::stringstream ss;
ss<<"offset:"<<offset<<"\tlength: "<<length<<"\tdataLength: "<<dataLength;
Logger::getInstance()->error(LP, ss.str());
env->ThrowNew(env->FindClass(EX_ARRAY_INDEX_OUT_OF_BOUND),
"Given offset and length exceeds write buffer space!");
} else {
jbyte *buf = (jbyte *) malloc(length * sizeof(jbyte));
env->GetByteArrayRegion(data, offset, length, buf);
int ret = device->bulkWrite(env, (char *) buf, length, timeout);
free(buf);
return ret;
}
} else {
Logger::getInstance()->error(LP, "Cannot find device!");
}
} catch (const char *errorString) {
env->ThrowNew(env->FindClass(EX_NATIVE_EXCEPTION), errorString);
} catch (...) {
env->ThrowNew(env->FindClass(EX_NATIVE_EXCEPTION),
"Unexpected native call failure in method write!");
}
return UNDEF;
}