I use a native C function from a dll like that:
short sSmartISOEx(USHORT usInDataLen, const UCHAR *pucDataIn, USHORT *pusOutDataLen, UCHAR *pucDataOut);
This function is declared in my java like that:
short sSmartISOEx(short usInDataLen, ByteBuffer pucDataIn, ShortBuffer pusOutDataLen, ByteBuffer pucDataOut);
So to use it i send a ByteBuffer pucDataIn with a lenght of usInDataLen. And normaly i retrieve a ByteBuffer pucDataOut with a lenght of pusOutDataLen.
The function work correctly, but my problem is after retrieving the ByteBuffer pucDataOut, i do something like that:
System.out.println("first byte: " + pucDataOut.get(0));
System.out.println("second byte: " + pucDataOut.get(1));
In my specifice case normaly "First byte" value is 0x69 and "Second byte" value is 0x86 But when i execute my code, this is what i obtain:
first byte: 105
second byte: -122
For 105 it's ok, it correspond to 0x69 But for -122, it correspond to 0xffffff86
Why this "pucDataOut.get(1)" correspond to 4 byte and not just only one byte. How to obtain exactly a byte array of two values 0x69 and 0x86