public class YSerialPort extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YSerialPort.TimedReportCallback
TimedReportCallback for SerialPort
|
static interface |
YSerialPort.UpdateCallback
Deprecated UpdateCallback for SerialPort
|
static interface |
YSerialPort.YSnoopingCallback
Specialized event Callback for SerialPort
|
Modifier and Type | Field and Description |
---|---|
protected String |
_command |
protected String |
_currentJob |
protected int |
_errCount |
protected YSerialPort.YSnoopingCallback |
_eventCallback |
protected int |
_eventPos |
protected int |
_jobMaxSize |
protected int |
_jobMaxTask |
protected String |
_lastMsg |
protected String |
_protocol |
protected byte[] |
_rxbuff |
protected int |
_rxbuffptr |
protected int |
_rxCount |
protected int |
_rxMsgCount |
protected int |
_rxptr |
protected String |
_serialMode |
protected String |
_startupJob |
protected int |
_txCount |
protected int |
_txMsgCount |
protected YSerialPort.UpdateCallback |
_valueCallbackSerialPort |
protected int |
_voltageLevel |
static String |
COMMAND_INVALID
invalid command value
|
static String |
CURRENTJOB_INVALID
invalid currentJob value
|
static int |
ERRCOUNT_INVALID
invalid errCount value
|
static int |
JOBMAXSIZE_INVALID
invalid jobMaxSize value
|
static int |
JOBMAXTASK_INVALID
invalid jobMaxTask value
|
static String |
LASTMSG_INVALID
invalid lastMsg value
|
static String |
PROTOCOL_INVALID
invalid protocol value
|
static int |
RXCOUNT_INVALID
invalid rxCount value
|
static int |
RXMSGCOUNT_INVALID
invalid rxMsgCount value
|
static String |
SERIALMODE_INVALID
invalid serialMode value
|
static String |
STARTUPJOB_INVALID
invalid startupJob value
|
static int |
TXCOUNT_INVALID
invalid txCount value
|
static int |
TXMSGCOUNT_INVALID
invalid txMsgCount value
|
static int |
VOLTAGELEVEL_INVALID |
static int |
VOLTAGELEVEL_OFF
invalid voltageLevel value
|
static int |
VOLTAGELEVEL_RS232 |
static int |
VOLTAGELEVEL_RS485 |
static int |
VOLTAGELEVEL_SDI12 |
static int |
VOLTAGELEVEL_TTL1V8 |
static int |
VOLTAGELEVEL_TTL3V |
static int |
VOLTAGELEVEL_TTL3VR |
static int |
VOLTAGELEVEL_TTL5V |
static int |
VOLTAGELEVEL_TTL5VR |
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, _yapi, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID
Modifier | Constructor and Description |
---|---|
protected |
YSerialPort(String func) |
protected |
YSerialPort(YAPIContext ctx,
String func) |
Modifier and Type | Method and Description |
---|---|
int |
_internalEventHandler(String advstr) |
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
int |
end_tell() |
static YSerialPort |
FindSerialPort(String func)
Retrieves a serial port for a given identifier.
|
static YSerialPort |
FindSerialPortInContext(YAPIContext yctx,
String func)
Retrieves a serial port for a given identifier in a YAPI context.
|
static YSerialPort |
FirstSerialPort()
Starts the enumeration of serial ports currently accessible.
|
static YSerialPort |
FirstSerialPortInContext(YAPIContext yctx)
Starts the enumeration of serial ports currently accessible.
|
String |
get_command() |
int |
get_CTS()
Reads the level of the CTS line.
|
String |
get_currentJob()
Returns the name of the job file currently in use.
|
int |
get_errCount()
Returns the total number of communication errors detected since last reset.
|
int |
get_jobMaxSize()
Returns maximum size allowed for job files.
|
int |
get_jobMaxTask()
Returns the maximum number of tasks in a job that the device can handle.
|
String |
get_lastMsg()
Returns the latest message fully received (for Line, Frame and Modbus protocols).
|
String |
get_protocol()
Returns the type of protocol used over the serial line, as a string.
|
int |
get_rxCount()
Returns the total number of bytes received since last reset.
|
int |
get_rxMsgCount()
Returns the total number of messages received since last reset.
|
String |
get_serialMode()
Returns the serial port communication parameters, as a string such as
"9600,8N1".
|
String |
get_startupJob()
Returns the job file to use when the device is powered on.
|
int |
get_txCount()
Returns the total number of bytes transmitted since last reset.
|
int |
get_txMsgCount()
Returns the total number of messages send since last reset.
|
int |
get_voltageLevel()
Returns the voltage level used on the serial line.
|
String |
getCurrentJob()
Returns the name of the job file currently in use.
|
int |
getErrCount()
Returns the total number of communication errors detected since last reset.
|
int |
getJobMaxSize()
Returns maximum size allowed for job files.
|
int |
getJobMaxTask()
Returns the maximum number of tasks in a job that the device can handle.
|
String |
getLastMsg()
Returns the latest message fully received (for Line, Frame and Modbus protocols).
|
String |
getProtocol()
Returns the type of protocol used over the serial line, as a string.
|
int |
getRxCount()
Returns the total number of bytes received since last reset.
|
int |
getRxMsgCount()
Returns the total number of messages received since last reset.
|
String |
getSerialMode()
Returns the serial port communication parameters, as a string such as
"9600,8N1".
|
String |
getStartupJob()
Returns the job file to use when the device is powered on.
|
int |
getTxCount()
Returns the total number of bytes transmitted since last reset.
|
int |
getTxMsgCount()
Returns the total number of messages send since last reset.
|
int |
getVoltageLevel()
Returns the voltage level used on the serial line.
|
ArrayList<Integer> |
modbusReadBits(int slaveNo,
int pduAddr,
int nBits)
Reads one or more contiguous internal bits (or coil status) from a MODBUS serial device.
|
ArrayList<Integer> |
modbusReadInputBits(int slaveNo,
int pduAddr,
int nBits)
Reads one or more contiguous input bits (or discrete inputs) from a MODBUS serial device.
|
ArrayList<Integer> |
modbusReadInputRegisters(int slaveNo,
int pduAddr,
int nWords)
Reads one or more contiguous input registers (read-only registers) from a MODBUS serial device.
|
ArrayList<Integer> |
modbusReadRegisters(int slaveNo,
int pduAddr,
int nWords)
Reads one or more contiguous internal registers (holding registers) from a MODBUS serial device.
|
ArrayList<Integer> |
modbusWriteAndReadRegisters(int slaveNo,
int pduWriteAddr,
ArrayList<Integer> values,
int pduReadAddr,
int nReadWords)
Sets several contiguous internal registers (holding registers) on a MODBUS serial device,
then performs a contiguous read of a set of (possibly different) internal registers.
|
int |
modbusWriteBit(int slaveNo,
int pduAddr,
int value)
Sets a single internal bit (or coil) on a MODBUS serial device.
|
int |
modbusWriteBits(int slaveNo,
int pduAddr,
ArrayList<Integer> bits)
Sets several contiguous internal bits (or coils) on a MODBUS serial device.
|
int |
modbusWriteRegister(int slaveNo,
int pduAddr,
int value)
Sets a single internal register (or holding register) on a MODBUS serial device.
|
int |
modbusWriteRegisters(int slaveNo,
int pduAddr,
ArrayList<Integer> values)
Sets several contiguous internal registers (or holding registers) on a MODBUS serial device.
|
YSerialPort |
nextSerialPort()
Continues the enumeration of serial ports started using yFirstSerialPort().
|
String |
queryHex(String hexString,
int maxWait)
Sends a binary message to the serial port, and reads the reply, if any.
|
String |
queryLine(String query,
int maxWait)
Sends a text line query to the serial port, and reads the reply, if any.
|
ArrayList<Integer> |
queryMODBUS(int slaveNo,
ArrayList<Integer> pduBytes)
Sends a message to a specified MODBUS slave connected to the serial port, and reads the
reply, if any.
|
int |
read_avail()
Returns the number of bytes available to read in the input buffer starting from the
current absolute stream position pointer of the API object.
|
int |
read_seek(int absPos)
Changes the current internal stream position to the specified value.
|
int |
read_tell()
Returns the current absolute stream position pointer of the API object.
|
ArrayList<Integer> |
readArray(int nChars)
Reads data from the receive buffer as a list of bytes, starting at current stream position.
|
byte[] |
readBin(int nChars)
Reads data from the receive buffer as a binary buffer, starting at current stream position.
|
int |
readByte()
Reads one byte from the receive buffer, starting at current stream position.
|
String |
readHex(int nBytes)
Reads data from the receive buffer as a hexadecimal string, starting at current stream position.
|
String |
readLine()
Reads a single line (or message) from the receive buffer, starting at current stream position.
|
ArrayList<String> |
readMessages(String pattern,
int maxWait)
Searches for incoming messages in the serial port receive buffer matching a given pattern,
starting at current position.
|
String |
readStr(int nChars)
Reads data from the receive buffer as a string, starting at current stream position.
|
int |
registerSnoopingCallback(YSerialPort.YSnoopingCallback callback)
Registers a callback function to be called each time that a message is sent or
received by the serial port.
|
int |
registerValueCallback(YSerialPort.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
reset()
Clears the serial port buffer and resets counters to zero.
|
int |
selectJob(String jobfile)
Load and start processing the specified job file.
|
int |
sendBreak(int duration)
Emits a BREAK condition on the serial interface.
|
int |
sendCommand(String text) |
int |
set_command(String newval) |
int |
set_currentJob(String newval)
Selects a job file to run immediately.
|
int |
set_protocol(String newval)
Changes the type of protocol used over the serial line.
|
int |
set_RTS(int val)
Manually sets the state of the RTS line.
|
int |
set_serialMode(String newval)
Changes the serial port communication parameters, with a string such as
"9600,8N1".
|
int |
set_startupJob(String newval)
Changes the job to use when the device is powered on.
|
int |
set_voltageLevel(int newval)
Changes the voltage type used on the serial line.
|
int |
setCurrentJob(String newval)
Selects a job file to run immediately.
|
int |
setProtocol(String newval)
Changes the type of protocol used over the serial line.
|
int |
setSerialMode(String newval)
Changes the serial port communication parameters, with a string such as
"9600,8N1".
|
int |
setStartupJob(String newval)
Changes the job to use when the device is powered on.
|
int |
setVoltageLevel(int newval)
Changes the voltage type used on the serial line.
|
ArrayList<YSnoopingRecord> |
snoopMessages(int maxWait)
Retrieves messages (both direction) in the serial port buffer, starting at current position.
|
int |
uploadJob(String jobfile,
String jsonDef)
Saves the job definition string (JSON data) into a job file.
|
int |
writeArray(ArrayList<Integer> byteList)
Sends a byte sequence (provided as a list of bytes) to the serial port.
|
int |
writeBin(byte[] buff)
Sends a binary buffer to the serial port, as is.
|
int |
writeByte(int code)
Sends a single byte to the serial port.
|
int |
writeHex(String hexString)
Sends a byte sequence (provided as a hexadecimal string) to the serial port.
|
int |
writeLine(String text)
Sends an ASCII string to the serial port, followed by a line break (CR LF).
|
int |
writeMODBUS(String hexString)
Sends a MODBUS message (provided as a hexadecimal string) to the serial port.
|
int |
writeStr(String text)
Sends an ASCII string to the serial port, as is.
|
int |
writeStxEtx(String text)
Sends an ASCII string to the serial port, preceeded with an STX code and
followed by an ETX code.
|
_AddToCache, _clearDataStreamCache, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _json_get_array, _json_get_key, _json_get_string, _parse, _parserHelper, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, _uploadEx, clearCache, describe, errMessage, errorMessage, errorType, errType, FindFunction, FindFunctionInContext, FirstFunction, FirstFunctionInContext, functionDescriptor, get_advertisedValue, get_errorMessage, get_errorType, get_friendlyName, get_functionDescriptor, get_functionId, get_hardwareId, get_logicalName, get_module, get_serialNumber, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, isReadOnly, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setLogicalName, setUserData, toString, unmuteValueCallbacks, userData
public static final int RXCOUNT_INVALID
public static final int TXCOUNT_INVALID
public static final int ERRCOUNT_INVALID
public static final int RXMSGCOUNT_INVALID
public static final int TXMSGCOUNT_INVALID
public static final String LASTMSG_INVALID
public static final String CURRENTJOB_INVALID
public static final String STARTUPJOB_INVALID
public static final int JOBMAXTASK_INVALID
public static final int JOBMAXSIZE_INVALID
public static final String COMMAND_INVALID
public static final String PROTOCOL_INVALID
public static final int VOLTAGELEVEL_OFF
public static final int VOLTAGELEVEL_TTL3V
public static final int VOLTAGELEVEL_TTL3VR
public static final int VOLTAGELEVEL_TTL5V
public static final int VOLTAGELEVEL_TTL5VR
public static final int VOLTAGELEVEL_RS232
public static final int VOLTAGELEVEL_RS485
public static final int VOLTAGELEVEL_TTL1V8
public static final int VOLTAGELEVEL_SDI12
public static final int VOLTAGELEVEL_INVALID
public static final String SERIALMODE_INVALID
protected int _rxCount
protected int _txCount
protected int _errCount
protected int _rxMsgCount
protected int _txMsgCount
protected String _lastMsg
protected String _currentJob
protected String _startupJob
protected int _jobMaxTask
protected int _jobMaxSize
protected String _command
protected String _protocol
protected int _voltageLevel
protected String _serialMode
protected YSerialPort.UpdateCallback _valueCallbackSerialPort
protected int _rxptr
protected byte[] _rxbuff
protected int _rxbuffptr
protected int _eventPos
protected YSerialPort.YSnoopingCallback _eventCallback
protected YSerialPort(YAPIContext ctx, String func)
func
- : functionidprotected YSerialPort(String func)
func
- : functionidprotected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) throws Exception
_parseAttr
in class YFunction
Exception
public int get_rxCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getRxCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_txCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getTxCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_errCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getErrCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_rxMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getRxMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_txMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getTxMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_lastMsg() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getLastMsg() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_currentJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getCurrentJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_currentJob(String newval) throws YAPI_Exception
newval
- : a stringYAPI_Exception
- on errorpublic int setCurrentJob(String newval) throws YAPI_Exception
newval
- : a stringYAPI_Exception
- on errorpublic String get_startupJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getStartupJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_startupJob(String newval) throws YAPI_Exception
newval
- : a string corresponding to the job to use when the device is powered onYAPI_Exception
- on errorpublic int setStartupJob(String newval) throws YAPI_Exception
newval
- : a string corresponding to the job to use when the device is powered onYAPI_Exception
- on errorpublic int get_jobMaxTask() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getJobMaxTask() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_jobMaxSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getJobMaxSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_command() throws YAPI_Exception
YAPI_Exception
public int set_command(String newval) throws YAPI_Exception
YAPI_Exception
public String get_protocol() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getProtocol() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_protocol(String newval) throws YAPI_Exception
newval
- : a string corresponding to the type of protocol used over the serial lineYAPI_Exception
- on errorpublic int setProtocol(String newval) throws YAPI_Exception
newval
- : a string corresponding to the type of protocol used over the serial lineYAPI_Exception
- on errorpublic int get_voltageLevel() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getVoltageLevel() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_voltageLevel(int newval) throws YAPI_Exception
newval
- : a value among YSerialPort.VOLTAGELEVEL_OFF, YSerialPort.VOLTAGELEVEL_TTL3V,
YSerialPort.VOLTAGELEVEL_TTL3VR, YSerialPort.VOLTAGELEVEL_TTL5V, YSerialPort.VOLTAGELEVEL_TTL5VR,
YSerialPort.VOLTAGELEVEL_RS232, YSerialPort.VOLTAGELEVEL_RS485, YSerialPort.VOLTAGELEVEL_TTL1V8 and
YSerialPort.VOLTAGELEVEL_SDI12 corresponding to the voltage type used on the serial lineYAPI_Exception
- on errorpublic int setVoltageLevel(int newval) throws YAPI_Exception
newval
- : a value among YSerialPort.VOLTAGELEVEL_OFF, YSerialPort.VOLTAGELEVEL_TTL3V,
YSerialPort.VOLTAGELEVEL_TTL3VR, YSerialPort.VOLTAGELEVEL_TTL5V, YSerialPort.VOLTAGELEVEL_TTL5VR,
YSerialPort.VOLTAGELEVEL_RS232, YSerialPort.VOLTAGELEVEL_RS485, YSerialPort.VOLTAGELEVEL_TTL1V8 and
YSerialPort.VOLTAGELEVEL_SDI12 corresponding to the voltage type used on the serial lineYAPI_Exception
- on errorpublic String get_serialMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getSerialMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_serialMode(String newval) throws YAPI_Exception
newval
- : a string corresponding to the serial port communication parameters, with a string such as
"9600,8N1"YAPI_Exception
- on errorpublic int setSerialMode(String newval) throws YAPI_Exception
newval
- : a string corresponding to the serial port communication parameters, with a string such as
"9600,8N1"YAPI_Exception
- on errorpublic static YSerialPort FindSerialPort(String func)
func
- : a string that uniquely characterizes the serial port, for instance
RS232MK1.serialPort.public static YSerialPort FindSerialPortInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the serial port, for instance
RS232MK1.serialPort.public int registerValueCallback(YSerialPort.UpdateCallback callback)
callback
- : the callback function to call, or a null pointer. The callback function should take two
arguments: the function object of which the value has changed, and the character string describing
the new advertised value.public int _invokeValueCallback(String value)
_invokeValueCallback
in class YFunction
public int sendCommand(String text) throws YAPI_Exception
YAPI_Exception
public String readLine() throws YAPI_Exception
YAPI_Exception
- on errorpublic ArrayList<String> readMessages(String pattern, int maxWait) throws YAPI_Exception
pattern
- : a limited regular expression describing the expected message format,
or an empty string if all messages should be returned (no filtering).
When using binary protocols, the format applies to the hexadecimal
representation of the message.maxWait
- : the maximum number of milliseconds to wait for a message if none is found
in the receive buffer.YAPI_Exception
- on errorpublic int read_seek(int absPos)
absPos
- : the absolute position index for next read operations.public int read_tell()
public int read_avail() throws YAPI_Exception
YAPI_Exception
public int end_tell() throws YAPI_Exception
YAPI_Exception
public String queryLine(String query, int maxWait) throws YAPI_Exception
query
- : the line query to send (without CR/LF)maxWait
- : the maximum number of milliseconds to wait for a reply.YAPI_Exception
- on errorpublic String queryHex(String hexString, int maxWait) throws YAPI_Exception
hexString
- : the message to send, coded in hexadecimalmaxWait
- : the maximum number of milliseconds to wait for a reply.YAPI_Exception
- on errorpublic int uploadJob(String jobfile, String jsonDef) throws YAPI_Exception
jobfile
- : name of the job file to save on the device filesystemjsonDef
- : a string containing a JSON definition of the jobYAPI_Exception
- on errorpublic int selectJob(String jobfile) throws YAPI_Exception
jobfile
- : name of the job file (on the device filesystem)YAPI_Exception
- on errorpublic int reset() throws YAPI_Exception
YAPI_Exception
- on errorpublic int writeByte(int code) throws YAPI_Exception
code
- : the byte to sendYAPI_Exception
- on errorpublic int writeStr(String text) throws YAPI_Exception
text
- : the text string to sendYAPI_Exception
- on errorpublic int writeBin(byte[] buff) throws YAPI_Exception
buff
- : the binary buffer to sendYAPI_Exception
- on errorpublic int writeArray(ArrayList<Integer> byteList) throws YAPI_Exception
byteList
- : a list of byte codesYAPI_Exception
- on errorpublic int writeHex(String hexString) throws YAPI_Exception
hexString
- : a string of hexadecimal byte codesYAPI_Exception
- on errorpublic int writeLine(String text) throws YAPI_Exception
text
- : the text string to sendYAPI_Exception
- on errorpublic int readByte() throws YAPI_Exception
YAPI_Exception
- on errorpublic String readStr(int nChars) throws YAPI_Exception
nChars
- : the maximum number of characters to readYAPI_Exception
- on errorpublic byte[] readBin(int nChars) throws YAPI_Exception
nChars
- : the maximum number of bytes to readYAPI_Exception
- on errorpublic ArrayList<Integer> readArray(int nChars) throws YAPI_Exception
nChars
- : the maximum number of bytes to readYAPI_Exception
- on errorpublic String readHex(int nBytes) throws YAPI_Exception
nBytes
- : the maximum number of bytes to readYAPI_Exception
- on errorpublic int sendBreak(int duration) throws YAPI_Exception
duration
- : 0 for a standard BREAK, or duration between 1 and 100 msYAPI_Exception
- on errorpublic int set_RTS(int val) throws YAPI_Exception
val
- : 1 to turn RTS on, 0 to turn RTS offYAPI_Exception
- on errorpublic int get_CTS() throws YAPI_Exception
YAPI_Exception
- on errorpublic ArrayList<YSnoopingRecord> snoopMessages(int maxWait) throws YAPI_Exception
maxWait
- : the maximum number of milliseconds to wait for a message if none is found
in the receive buffer.YAPI_Exception
- on errorpublic int registerSnoopingCallback(YSerialPort.YSnoopingCallback callback) throws YAPI_Exception
callback
- : the callback function to call, or a null pointer.
The callback function should take four arguments:
the YSerialPort object that emitted the event, and
the YSnoopingRecord object that describes the message
sent or received.YAPI_Exception
- on errorpublic int _internalEventHandler(String advstr) throws YAPI_Exception
YAPI_Exception
public int writeStxEtx(String text) throws YAPI_Exception
text
- : the text string to sendYAPI_Exception
- on errorpublic int writeMODBUS(String hexString) throws YAPI_Exception
hexString
- : a hexadecimal message string, including device address but no CRC/LRCYAPI_Exception
- on errorpublic ArrayList<Integer> queryMODBUS(int slaveNo, ArrayList<Integer> pduBytes) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to querypduBytes
- : the message to send (PDU), as a vector of bytes. The first byte of the
PDU is the MODBUS function code.YAPI_Exception
- on errorpublic ArrayList<Integer> modbusReadBits(int slaveNo, int pduAddr, int nBits) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to querypduAddr
- : the relative address of the first bit/coil to read (zero-based)nBits
- : the number of bits/coils to readYAPI_Exception
- on errorpublic ArrayList<Integer> modbusReadInputBits(int slaveNo, int pduAddr, int nBits) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to querypduAddr
- : the relative address of the first bit/input to read (zero-based)nBits
- : the number of bits/inputs to readYAPI_Exception
- on errorpublic ArrayList<Integer> modbusReadRegisters(int slaveNo, int pduAddr, int nWords) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to querypduAddr
- : the relative address of the first holding register to read (zero-based)nWords
- : the number of holding registers to readYAPI_Exception
- on errorpublic ArrayList<Integer> modbusReadInputRegisters(int slaveNo, int pduAddr, int nWords) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to querypduAddr
- : the relative address of the first input register to read (zero-based)nWords
- : the number of input registers to readYAPI_Exception
- on errorpublic int modbusWriteBit(int slaveNo, int pduAddr, int value) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to drivepduAddr
- : the relative address of the bit/coil to set (zero-based)value
- : the value to set (0 for OFF state, non-zero for ON state)YAPI_Exception
- on errorpublic int modbusWriteBits(int slaveNo, int pduAddr, ArrayList<Integer> bits) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to drivepduAddr
- : the relative address of the first bit/coil to set (zero-based)bits
- : the vector of bits to be set (one integer per bit)YAPI_Exception
- on errorpublic int modbusWriteRegister(int slaveNo, int pduAddr, int value) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to drivepduAddr
- : the relative address of the register to set (zero-based)value
- : the 16 bit value to setYAPI_Exception
- on errorpublic int modbusWriteRegisters(int slaveNo, int pduAddr, ArrayList<Integer> values) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to drivepduAddr
- : the relative address of the first internal register to set (zero-based)values
- : the vector of 16 bit values to setYAPI_Exception
- on errorpublic ArrayList<Integer> modbusWriteAndReadRegisters(int slaveNo, int pduWriteAddr, ArrayList<Integer> values, int pduReadAddr, int nReadWords) throws YAPI_Exception
slaveNo
- : the address of the slave MODBUS device to drivepduWriteAddr
- : the relative address of the first internal register to set (zero-based)values
- : the vector of 16 bit values to setpduReadAddr
- : the relative address of the first internal register to read (zero-based)nReadWords
- : the number of 16 bit values to readYAPI_Exception
- on errorpublic YSerialPort nextSerialPort()
public static YSerialPort FirstSerialPort()
public static YSerialPort FirstSerialPortInContext(YAPIContext yctx)
yctx
- : a YAPI context.Copyright © 2023. All rights reserved.