Platform differences reading byte values using JNA

138 views Asked by At

I have created a JavaFX application to retrieve data from a FTDI peripheral device. I used JNAerator to generate the the API and everything works beautifully on my development machine (OS X). However, when tested on a coworker's box (Windows), the BirdJ Pointer.getBytes() method returns byte arrays where every value is off by exactly 128.

Is there a known platform difference or something else in Java that would explain this inconsistent behavior or is this more likely a problem in the native FTDI drivers?

Is there a cleaner way to resolve it than by introducing ugly platform specific logic to modify every byte read or written?

EDIT

I'm not sure my problem description was clear. Here is a specific example.

I request 3 bytes from the FTDI device to confirm it is ready to send data. I get [-91, -1, -1] which matches the documentation saying to expect "A5 FF FF". My code is written to accept that answer and everything proceeds just fine.

My coworker gets [37, 127, 127] which is "25 7F 7F". Since that is not the expected value, my code reports an error and exits.

1

There are 1 answers

0
Jonathon On

Calling SetDataCharacteristics to ensure that all words use 8 bits solved my problem.