我有这个本机功能,当我将设备连接到我的系统时,我在 JNA 中得到空值
CP210x_GetProductString( DWORD DeviceNum,LPVOID DeviceString,DWORD Options)
DeviceNum
— 需要产品描述字符串、序列号或完整路径的设备的索引。DeviceString
CP210x_DEVICE_STRING
—返回以 NULL 结尾的序列号、设备描述或完整路径字符串的类型变量。Options
— 确定是否DeviceString
包含产品描述、序列号或完整路径字符串的标志
JNA 代码:
public class Helloworld {
public interface CLibrary extends Library{
CLibrary INSTANCE = (CLibrary) Native.loadLibrary(
(Platform.isWindows() ? "CP210xManufacturing.dll" : "c"),
CLibrary.class);
int CP210x_GetProductString(int dn,String [] ds,int op);
}
public static void main(String[] args) {
int dn=0;
String dsc = new String[100];
if(CLibrary.INSTANCE.CP210x_GetProductString(dn, dsc,
CP210x.CP210x_RETURN_SERIAL_NUMBER) == CP210x.CP210x_SUCCESS){
{
for(int i=0;i<dsc.length;i++)
System.out.print(dsc[i]);
}
}
}
}