I call library native function OpenSSPComPortUSB() while running program get pop-up unbable to open the port \.\COM208. Why it return \.\COM208 as I have pass PortNumber =7; below is the Java code and my goal is to open port COM7 to start the serial communication with smart hoper.
// AccessITLLib.java
public class AccessITLLib
{
public static class SSP_COMMAND extends Structure
{
SSP_FULL_KEY Key;
public NativeLong BaudRate;
public byte PortNumber;
public NativeLong Timeout;
public byte SSPAddress;
public byte RetryLevel;
public byte EncryptionStatus;
public byte CommandDataLength;
public byte[] CommandData = new byte[255];
public byte ResponseStatus;
public byte ResponseDataLength;
public byte[] ResponseData = new byte[255];
public byte IgnoreError;
}
public interface ITLLib extends Library
{
ITLLib INSTANCE = (ITLLib) Native.loadLibrary("ITLSSPproc",
ITLLib.class);
public int OpenSSPComPort(SSP_COMMAND p);
public int OpenSSPComPortUSB(SSP_COMMAND p);
public int CloseSSPComPort();
public int CloseSSPComPortUSB();
}
public static void main(String[] args)
{
SSP_COMMAND commandStruct = new SSP_COMMAND();
commandStruct.BaudRate = new NativeLong(9600);
commandStruct.PortNumber =7;
commandStruct.Timeout = 500;
commandStruct.RetryLevel = 3;
commandStruct.IgnoreError = 1;
commandStruct.SSPAddress =16;
ITLLib.INSTANCE.CloseSSPComPort();
ITLLib.INSTANCE.CloseSSPComPortUSB();
ITLLib.INSTANCE.OpenSSPComPort(commandStruct);
ITLLib.INSTANCE.OpenSSPComPortUSB(commandStruct);
}
}
here are the c structures
typedef struct{
SSP_FULL_KEY Key;
unsigned long BaudRate;
unsigned long Timeout;
unsigned char PortNumber;
unsigned char SSPAddress;
unsigned char RetryLevel;
unsigned char EncryptionStatus;
unsigned char CommandDataLength;
unsigned char CommandData[255];
unsigned char ResponseStatus;
unsigned char ResponseDataLength;
unsigned char ResponseData[255];
unsigned char IgnoreError;
}SSP_COMMAND;
typedef struct{
unsigned long long FixedKey;
unsigned long long EncryptKey;
}SSP_FULL_KEY;