MxNPortAPI Function Groups
The supported functions in this API are listed below:
Port Control
open
close
setIoctlMode
setFlowCtrl
setBaud
setRTS
setDTR
flush
Example Program
To make sure this API is workable with the device server on an Android platform, see the example program
below:
Thread thread = new Thread()
{
@Override
public void run() {
/* Enumerate and initialize NPorts on system */
List<MxNPort> NPortList = MxNPortService.getNPortInfoList();
if(NPortList!=null){
}
}
};
thread.start();
NPort W2150A-W4/W2250A-W4 Series User Manual
Input/Output
read
write
MxNPort.IoctlMode mode = new MxNPort.IoctlMode();
mode.baudRate = 38400;
mode.dataBits = MxNPort.DATA_BITS_8;
mode.parity = MxNPort.PARITY_NONE;
mode.stopBits = MxNPort.STOP_BITS_1;
MxNPort mxNPort = NPortList.get(0); /* Get first NPort device */
try {
byte[] buf = {'H','e','l','l','o',' ','W','o','r','l','d'};
mxNPort.open(); /*open port*/
mxNPort.setIoctlMode(mode); /*serial parameters setting*/
mxNPort.write(buf, buf.length); /*write data*/
mxNPort.close(); /*close port*/
} catch (MxException e){
/*Error handling*/
}
Port Status Inquiry
getBaud
getFlowCtrl
getIoctlMode
getLineStatus
getModemStatus
getOQueue
Miscellaneous
setBreak
108