我正在研究ITLSSPProc.dll
哪个具有本机方法,它在 C 语言中具有以下结构定义,但我必须用 Java 编写代码。最近三天我一直在搜索,但找不到解决方案。
1.typedef struct{
unsigned __int64 FixedKey; // 8 byte number for fixed host key
unsigned __int64 EncryptKey; // 8 Byte number for variable key
}SSP_FULL_KEY;
2.typedef struct{
unsigned __int64 Generator;
unsigned __int64 Modulus;
unsigned __int64 HostInter;
unsigned __int64 HostRandom;
unsigned __int64 SlaveInterKey;
unsigned __int64 SlaveRandom;
unsigned __int64 KeyHost;
unsigned __int64 KeySlave;
}SSP_KEYS
3.typedef struct{
SSP_FULL_KEY Key; // the full key
unsigned long BaudRate; // baud rate of the packet
unsigned long Timeout; // how long in ms to wait for a reply from the slave
unsigned char PortNumber; // the serial com port number of the host
unsigned char SSPAddress; // the SSP address of the slave
unsigned char RetryLevel; // how many retries to the slave for non-response
unsigned char EncryptionStatus; // is this an encrypted command 0 – No, 1 - Yes
unsigned char CommandDataLength; // Number of bytes in the command
unsigned char CommandData[255]; // Array containing the command bytes
unsigned char ResponseStatus; // Response Status (PORT_STATUS enum)
unsigned char ResponseDataLength; // how many bytes in the response
unsigned char ResponseData[255]; // an array of response data
unsigned char IgnoreError; // flag to suppress error box (0 – display,1 suppress)
}SSP_COMMAND
这是我尝试过的 Java 代码,但我无法调用本机方法:
public class SSP_FULL_KEY
{
long FixedKey;
long EncryptKey;
public SSP_FULL_KEY(long fix, long encr)
{
FixedKey = fix;
EncryptKey = encr;
}
}
public class SSP_COMMAND
{
//string PortNumber;
SSP_FULL_KEY key;
long BaudRate; // baud rate of the packet
long Timeout; // how long in ms to wait for a reply from the slave
String PortNumber; // the serial com port number of the host
String SSPAddress; // the SSP address of the slave
String RetryLevel; // how many retries to the slave for non-response
String EncryptionStatus; // is this an encrypted command 0 - No, 1 - Yes
String CommandDataLength; // Number of bytes in the command
String[] CommandData = new String[255]; // Array containing the command bytes
String ResponseStatus; // Response Status (PORT_STATUS enum)
String ResponseDataLength; // how many bytes in the response
String ResponseData[] = new String[255]; // an array of response data
String IgnoreError; // flag to suppress error box (0 - display,1- suppress)
public SSP_COMMAND(String comport)
{
BaudRate = 9600;
Timeout = 500;
PortNumber = comport;
RetryLevel = "5";
IgnoreError = "0";
EncryptionStatus = "0";
ResponseStatus = "0";
ResponseDataLength = "0";
SSPAddress = "0";
CommandDataLength = "0";
key = new SSP_FULL_KEY(012345670123, 012345670123);
}
}
native method:OpenSSPComPort(SSPCOMMAND * cmd)
这里我传递参数:
Pointer to SSP_COMMAND structure Returns: WORD 0 for fail, 1 for success
并得到错误不满意的链接错误