Mxnportapi Function Groups; Example Program - Moxa Technologies NPort 5000 Series User Manual

Hide thumbs Also See for NPort 5000 Series:
Table of Contents

Advertisement

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){
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*/
}
}
}
};
thread.start();
NPort 5000 Series User Manual
Input/Output
read
write
Port Status Inquiry
getBaud
getFlowCtrl
getIoctlMode
getLineStatus
getModemStatus
getOQueue
Miscellaneous
setBreak
165

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents