RXTXPort.setDTR()/isDTR()/setRTS()/isRTS()/isCTS()/setDSR()/isDSR()/isRI()/isCD() are all wrappers around TIOCMSET/TIOCMGETioctl calls. They all follow the same pattern: the setters retrieve the current control bits and set or clear the relevant bit, then set the new control bits; and the getters retrieve the current control bits, mask out the relevant one, and return a boolean based on whether it's set. These methods are largely copy/pasted, and could be easily deduplicated into a setter function which takes the FD, the bit to set, and the desired state of that bit; and a getter function which takes the FD and the bit, and returns the state of that bit. The JNI functions would then just be thin wrappers around those functions.
RXTXPort.setDTR()
/isDTR()
/setRTS()
/isRTS()
/isCTS()
/setDSR()
/isDSR()
/isRI()
/isCD()
are all wrappers aroundTIOCMSET
/TIOCMGET
ioctl
calls. They all follow the same pattern: the setters retrieve the current control bits and set or clear the relevant bit, then set the new control bits; and the getters retrieve the current control bits, mask out the relevant one, and return a boolean based on whether it's set. These methods are largely copy/pasted, and could be easily deduplicated into a setter function which takes the FD, the bit to set, and the desired state of that bit; and a getter function which takes the FD and the bit, and returns the state of that bit. The JNI functions would then just be thin wrappers around those functions.