Class BrickletRS485


  • public class BrickletRS485
    extends Device
    Communicates with RS485/Modbus devices with full- or half-duplex
    • Field Detail

      • DEVICE_DISPLAY_NAME

        public static final java.lang.String DEVICE_DISPLAY_NAME
        See Also:
        Constant Field Values
      • FUNCTION_WRITE_LOW_LEVEL

        public static final byte FUNCTION_WRITE_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_READ_LOW_LEVEL

        public static final byte FUNCTION_READ_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_ENABLE_READ_CALLBACK

        public static final byte FUNCTION_ENABLE_READ_CALLBACK
        See Also:
        Constant Field Values
      • FUNCTION_DISABLE_READ_CALLBACK

        public static final byte FUNCTION_DISABLE_READ_CALLBACK
        See Also:
        Constant Field Values
      • FUNCTION_IS_READ_CALLBACK_ENABLED

        public static final byte FUNCTION_IS_READ_CALLBACK_ENABLED
        See Also:
        Constant Field Values
      • FUNCTION_SET_RS485_CONFIGURATION

        public static final byte FUNCTION_SET_RS485_CONFIGURATION
        See Also:
        Constant Field Values
      • FUNCTION_GET_RS485_CONFIGURATION

        public static final byte FUNCTION_GET_RS485_CONFIGURATION
        See Also:
        Constant Field Values
      • FUNCTION_SET_MODBUS_CONFIGURATION

        public static final byte FUNCTION_SET_MODBUS_CONFIGURATION
        See Also:
        Constant Field Values
      • FUNCTION_GET_MODBUS_CONFIGURATION

        public static final byte FUNCTION_GET_MODBUS_CONFIGURATION
        See Also:
        Constant Field Values
      • FUNCTION_SET_COMMUNICATION_LED_CONFIG

        public static final byte FUNCTION_SET_COMMUNICATION_LED_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_GET_COMMUNICATION_LED_CONFIG

        public static final byte FUNCTION_GET_COMMUNICATION_LED_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_SET_ERROR_LED_CONFIG

        public static final byte FUNCTION_SET_ERROR_LED_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_GET_ERROR_LED_CONFIG

        public static final byte FUNCTION_GET_ERROR_LED_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_SET_BUFFER_CONFIG

        public static final byte FUNCTION_SET_BUFFER_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_GET_BUFFER_CONFIG

        public static final byte FUNCTION_GET_BUFFER_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_GET_BUFFER_STATUS

        public static final byte FUNCTION_GET_BUFFER_STATUS
        See Also:
        Constant Field Values
      • FUNCTION_ENABLE_ERROR_COUNT_CALLBACK

        public static final byte FUNCTION_ENABLE_ERROR_COUNT_CALLBACK
        See Also:
        Constant Field Values
      • FUNCTION_DISABLE_ERROR_COUNT_CALLBACK

        public static final byte FUNCTION_DISABLE_ERROR_COUNT_CALLBACK
        See Also:
        Constant Field Values
      • FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED

        public static final byte FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED
        See Also:
        Constant Field Values
      • FUNCTION_GET_ERROR_COUNT

        public static final byte FUNCTION_GET_ERROR_COUNT
        See Also:
        Constant Field Values
      • FUNCTION_GET_MODBUS_COMMON_ERROR_COUNT

        public static final byte FUNCTION_GET_MODBUS_COMMON_ERROR_COUNT
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_REPORT_EXCEPTION

        public static final byte FUNCTION_MODBUS_SLAVE_REPORT_EXCEPTION
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_READ_COILS_REQUEST_LOW_LEVEL

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_READ_COILS_REQUEST_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_READ_COILS

        public static final byte FUNCTION_MODBUS_MASTER_READ_COILS
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_READ_HOLDING_REGISTERS_REQUEST_LOW_LEVEL

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_READ_HOLDING_REGISTERS_REQUEST_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_READ_HOLDING_REGISTERS

        public static final byte FUNCTION_MODBUS_MASTER_READ_HOLDING_REGISTERS
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_COIL_REQUEST

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_COIL_REQUEST
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_WRITE_SINGLE_COIL

        public static final byte FUNCTION_MODBUS_MASTER_WRITE_SINGLE_COIL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_REGISTER_REQUEST

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_REGISTER_REQUEST
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_WRITE_SINGLE_REGISTER

        public static final byte FUNCTION_MODBUS_MASTER_WRITE_SINGLE_REGISTER
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_COILS_REQUEST

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_COILS_REQUEST
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_COILS_LOW_LEVEL

        public static final byte FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_COILS_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_REGISTERS_REQUEST

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_REGISTERS_REQUEST
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_LOW_LEVEL

        public static final byte FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_READ_DISCRETE_INPUTS_REQUEST_LOW_LEVEL

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_READ_DISCRETE_INPUTS_REQUEST_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS

        public static final byte FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL

        public static final byte FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL
        See Also:
        Constant Field Values
      • FUNCTION_MODBUS_MASTER_READ_INPUT_REGISTERS

        public static final byte FUNCTION_MODBUS_MASTER_READ_INPUT_REGISTERS
        See Also:
        Constant Field Values
      • FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION

        public static final byte FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION
        See Also:
        Constant Field Values
      • FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION

        public static final byte FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION
        See Also:
        Constant Field Values
      • FUNCTION_GET_SPITFP_ERROR_COUNT

        public static final byte FUNCTION_GET_SPITFP_ERROR_COUNT
        See Also:
        Constant Field Values
      • FUNCTION_SET_BOOTLOADER_MODE

        public static final byte FUNCTION_SET_BOOTLOADER_MODE
        See Also:
        Constant Field Values
      • FUNCTION_GET_BOOTLOADER_MODE

        public static final byte FUNCTION_GET_BOOTLOADER_MODE
        See Also:
        Constant Field Values
      • FUNCTION_SET_WRITE_FIRMWARE_POINTER

        public static final byte FUNCTION_SET_WRITE_FIRMWARE_POINTER
        See Also:
        Constant Field Values
      • FUNCTION_WRITE_FIRMWARE

        public static final byte FUNCTION_WRITE_FIRMWARE
        See Also:
        Constant Field Values
      • FUNCTION_SET_STATUS_LED_CONFIG

        public static final byte FUNCTION_SET_STATUS_LED_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_GET_STATUS_LED_CONFIG

        public static final byte FUNCTION_GET_STATUS_LED_CONFIG
        See Also:
        Constant Field Values
      • FUNCTION_GET_CHIP_TEMPERATURE

        public static final byte FUNCTION_GET_CHIP_TEMPERATURE
        See Also:
        Constant Field Values
      • COMMUNICATION_LED_CONFIG_OFF

        public static final int COMMUNICATION_LED_CONFIG_OFF
        See Also:
        Constant Field Values
      • COMMUNICATION_LED_CONFIG_ON

        public static final int COMMUNICATION_LED_CONFIG_ON
        See Also:
        Constant Field Values
      • COMMUNICATION_LED_CONFIG_SHOW_HEARTBEAT

        public static final int COMMUNICATION_LED_CONFIG_SHOW_HEARTBEAT
        See Also:
        Constant Field Values
      • COMMUNICATION_LED_CONFIG_SHOW_COMMUNICATION

        public static final int COMMUNICATION_LED_CONFIG_SHOW_COMMUNICATION
        See Also:
        Constant Field Values
      • ERROR_LED_CONFIG_SHOW_HEARTBEAT

        public static final int ERROR_LED_CONFIG_SHOW_HEARTBEAT
        See Also:
        Constant Field Values
      • ERROR_LED_CONFIG_SHOW_ERROR

        public static final int ERROR_LED_CONFIG_SHOW_ERROR
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_ILLEGAL_FUNCTION

        public static final int EXCEPTION_CODE_ILLEGAL_FUNCTION
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_ILLEGAL_DATA_ADDRESS

        public static final int EXCEPTION_CODE_ILLEGAL_DATA_ADDRESS
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_ILLEGAL_DATA_VALUE

        public static final int EXCEPTION_CODE_ILLEGAL_DATA_VALUE
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_SLAVE_DEVICE_FAILURE

        public static final int EXCEPTION_CODE_SLAVE_DEVICE_FAILURE
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_ACKNOWLEDGE

        public static final int EXCEPTION_CODE_ACKNOWLEDGE
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_SLAVE_DEVICE_BUSY

        public static final int EXCEPTION_CODE_SLAVE_DEVICE_BUSY
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_MEMORY_PARITY_ERROR

        public static final int EXCEPTION_CODE_MEMORY_PARITY_ERROR
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_GATEWAY_PATH_UNAVAILABLE

        public static final int EXCEPTION_CODE_GATEWAY_PATH_UNAVAILABLE
        See Also:
        Constant Field Values
      • EXCEPTION_CODE_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND

        public static final int EXCEPTION_CODE_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND
        See Also:
        Constant Field Values
      • BOOTLOADER_MODE_BOOTLOADER

        public static final int BOOTLOADER_MODE_BOOTLOADER
        See Also:
        Constant Field Values
      • BOOTLOADER_MODE_FIRMWARE

        public static final int BOOTLOADER_MODE_FIRMWARE
        See Also:
        Constant Field Values
      • BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT

        public static final int BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
        See Also:
        Constant Field Values
      • BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT

        public static final int BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
        See Also:
        Constant Field Values
      • BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT

        public static final int BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
        See Also:
        Constant Field Values
      • BOOTLOADER_STATUS_INVALID_MODE

        public static final int BOOTLOADER_STATUS_INVALID_MODE
        See Also:
        Constant Field Values
      • BOOTLOADER_STATUS_NO_CHANGE

        public static final int BOOTLOADER_STATUS_NO_CHANGE
        See Also:
        Constant Field Values
      • BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT

        public static final int BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
        See Also:
        Constant Field Values
      • BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT

        public static final int BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
        See Also:
        Constant Field Values
      • BOOTLOADER_STATUS_CRC_MISMATCH

        public static final int BOOTLOADER_STATUS_CRC_MISMATCH
        See Also:
        Constant Field Values
      • STATUS_LED_CONFIG_SHOW_HEARTBEAT

        public static final int STATUS_LED_CONFIG_SHOW_HEARTBEAT
        See Also:
        Constant Field Values
      • STATUS_LED_CONFIG_SHOW_STATUS

        public static final int STATUS_LED_CONFIG_SHOW_STATUS
        See Also:
        Constant Field Values
    • Constructor Detail

      • BrickletRS485

        public BrickletRS485​(java.lang.String uid,
                             IPConnection ipcon)
        Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
    • Method Detail

      • writeLowLevel

        public int writeLowLevel​(int messageLength,
                                 int messageChunkOffset,
                                 char[] messageChunkData)
                          throws TinkerforgeException
        Writes characters to the RS485 interface. The characters can be binary data, ASCII or similar is not necessary. The return value is the number of characters that were written. See setRS485Configuration(long, int, int, int, int) for configuration possibilities regarding baudrate, parity and so on.
        Throws:
        TinkerforgeException
      • setRS485Configuration

        public void setRS485Configuration​(long baudrate,
                                          int parity,
                                          int stopbits,
                                          int wordlength,
                                          int duplex)
                                   throws TinkerforgeException
        Sets the configuration for the RS485 communication.
        Throws:
        TinkerforgeException
      • setModbusConfiguration

        public void setModbusConfiguration​(int slaveAddress,
                                           long masterRequestTimeout)
                                    throws TinkerforgeException
        Sets the configuration for the RS485 Modbus communication. Available options: * Slave Address: Address to be used as the Modbus slave address in Modbus slave mode. Valid Modbus slave address range is 1 to 247. * Master Request Timeout: Specifies how long the master should wait for a response from a slave when in Modbus master mode.
        Throws:
        TinkerforgeException
      • setMode

        public void setMode​(int mode)
                     throws TinkerforgeException
        Sets the mode of the Bricklet in which it operates. Available options are * RS485, * Modbus Master RTU and * Modbus Slave RTU.
        Throws:
        TinkerforgeException
      • setCommunicationLEDConfig

        public void setCommunicationLEDConfig​(int config)
                                       throws TinkerforgeException
        Sets the communication LED configuration. By default the LED shows RS485 communication traffic by flickering. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is off.
        Throws:
        TinkerforgeException
      • setErrorLEDConfig

        public void setErrorLEDConfig​(int config)
                               throws TinkerforgeException
        Sets the error LED configuration. By default the error LED turns on if there is any error (see BrickletRS485.ErrorCountListener callback). If you call this function with the SHOW ERROR option again, the LED will turn off until the next error occurs. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is off.
        Throws:
        TinkerforgeException
      • setBufferConfig

        public void setBufferConfig​(int sendBufferSize,
                                    int receiveBufferSize)
                             throws TinkerforgeException
        Sets the send and receive buffer size in byte. In sum there is 10240 byte (10KiB) buffer available and the minimum buffer size is 1024 byte (1KiB) for both. The current buffer content is lost if this function is called. The send buffer holds data that was given by write(char[]) and could not be written yet. The receive buffer holds data that is received through RS485 but could not yet be send to the user, either by read(int) or through BrickletRS485.ReadListener listener.
        Throws:
        TinkerforgeException
      • getModbusCommonErrorCount

        public BrickletRS485.ModbusCommonErrorCount getModbusCommonErrorCount()
                                                                       throws TinkerforgeException
        Returns the current number of errors occurred in Modbus mode. * Timeout Error Count: Number of timeouts occurred. * Checksum Error Count: Number of failures due to Modbus frame CRC16 checksum mismatch. * Frame Too Big Error Count: Number of times frames were rejected because they exceeded maximum Modbus frame size which is 256 bytes. * Illegal Function Error Count: Number of errors when an unimplemented or illegal function is requested. This corresponds to Modbus exception code 1. * Illegal Data Address Error Count: Number of errors due to invalid data address. This corresponds to Modbus exception code 2. * Illegal Data Value Error Count: Number of errors due to invalid data value. This corresponds to Modbus exception code 3. * Slave Device Failure Error Count: Number of errors occurred on the slave device which were unrecoverable. This corresponds to Modbus exception code 4.
        Throws:
        TinkerforgeException
      • modbusSlaveReportException

        public void modbusSlaveReportException​(int requestID,
                                               int exceptionCode)
                                        throws TinkerforgeException
        In Modbus slave mode this function can be used to report a Modbus exception for a Modbus master request. * Request ID: Request ID of the request received by the slave. * Exception Code: Modbus exception code to report to the Modbus master.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadCoilsRequestLowLevel

        public void modbusSlaveAnswerReadCoilsRequestLowLevel​(int requestID,
                                                              int coilsLength,
                                                              int coilsChunkOffset,
                                                              boolean[] coilsChunkData)
                                                       throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read coils. * Request ID: Request ID of the corresponding request that is being answered. * Coils: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadCoilsRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterReadCoils

        public int modbusMasterReadCoils​(int slaveAddress,
                                         long startingAddress,
                                         int count)
                                  throws TinkerforgeException
        In Modbus master mode this function can be used to read coils from a slave. This function creates a Modbus function code 1 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first coil to read. For backwards compatibility reasons this parameter is called Starting Address. It is not an address, but instead a coil number in the range of 1 to 65536. * Count: Number of coils to read. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterReadCoilsResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadHoldingRegistersRequestLowLevel

        public void modbusSlaveAnswerReadHoldingRegistersRequestLowLevel​(int requestID,
                                                                         int holdingRegistersLength,
                                                                         int holdingRegistersChunkOffset,
                                                                         int[] holdingRegistersChunkData)
                                                                  throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read holding registers. * Request ID: Request ID of the corresponding request that is being answered. * Holding Registers: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadHoldingRegistersRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterReadHoldingRegisters

        public int modbusMasterReadHoldingRegisters​(int slaveAddress,
                                                    long startingAddress,
                                                    int count)
                                             throws TinkerforgeException
        In Modbus master mode this function can be used to read holding registers from a slave. This function creates a Modbus function code 3 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first holding register to read. For backwards compatibility reasons this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted. * Count: Number of holding registers to read. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterReadHoldingRegistersResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerWriteSingleCoilRequest

        public void modbusSlaveAnswerWriteSingleCoilRequest​(int requestID)
                                                     throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to write a single coil. * Request ID: Request ID of the corresponding request that is being answered. This function must be called from the BrickletRS485.ModbusSlaveWriteSingleCoilRequestListener listener with the Request ID as provided by the arguments of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterWriteSingleCoil

        public int modbusMasterWriteSingleCoil​(int slaveAddress,
                                               long coilAddress,
                                               boolean coilValue)
                                        throws TinkerforgeException
        In Modbus master mode this function can be used to write a single coil of a slave. This function creates a Modbus function code 5 request. * Slave Address: Address of the target Modbus slave. * Coil Address: Number of the coil to be written. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a coil number in the range of 1 to 65536. * Coil Value: Value to be written. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterWriteSingleCoilResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerWriteSingleRegisterRequest

        public void modbusSlaveAnswerWriteSingleRegisterRequest​(int requestID)
                                                         throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to write a single register. * Request ID: Request ID of the corresponding request that is being answered. This function must be called from the BrickletRS485.ModbusSlaveWriteSingleRegisterRequestListener listener with the Request ID, Register Address and Register Value as provided by the arguments of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterWriteSingleRegister

        public int modbusMasterWriteSingleRegister​(int slaveAddress,
                                                   long registerAddress,
                                                   int registerValue)
                                            throws TinkerforgeException
        In Modbus master mode this function can be used to write a single holding register of a slave. This function creates a Modbus function code 6 request. * Slave Address: Address of the target Modbus slave. * Register Address: Number of the holding register to be written. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted. * Register Value: Value to be written. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterWriteSingleRegisterResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerWriteMultipleCoilsRequest

        public void modbusSlaveAnswerWriteMultipleCoilsRequest​(int requestID)
                                                        throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to write multiple coils. * Request ID: Request ID of the corresponding request that is being answered. This function must be called from the BrickletRS485.ModbusSlaveWriteMultipleCoilsRequestListener listener with the Request ID of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterWriteMultipleCoilsLowLevel

        public int modbusMasterWriteMultipleCoilsLowLevel​(int slaveAddress,
                                                          long startingAddress,
                                                          int coilsLength,
                                                          int coilsChunkOffset,
                                                          boolean[] coilsChunkData)
                                                   throws TinkerforgeException
        In Modbus master mode this function can be used to write multiple coils of a slave. This function creates a Modbus function code 15 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first coil to write. For backwards compatibility reasons, this parameter is called Starting Address.It is not an address, but instead a coil number in the range of 1 to 65536. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterWriteMultipleCoilsResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerWriteMultipleRegistersRequest

        public void modbusSlaveAnswerWriteMultipleRegistersRequest​(int requestID)
                                                            throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to write multiple registers. * Request ID: Request ID of the corresponding request that is being answered. This function must be called from the BrickletRS485.ModbusSlaveWriteMultipleRegistersRequestListener listener with the Request ID of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterWriteMultipleRegistersLowLevel

        public int modbusMasterWriteMultipleRegistersLowLevel​(int slaveAddress,
                                                              long startingAddress,
                                                              int registersLength,
                                                              int registersChunkOffset,
                                                              int[] registersChunkData)
                                                       throws TinkerforgeException
        In Modbus master mode this function can be used to write multiple registers of a slave. This function creates a Modbus function code 16 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first holding register to write. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterWriteMultipleRegistersResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadDiscreteInputsRequestLowLevel

        public void modbusSlaveAnswerReadDiscreteInputsRequestLowLevel​(int requestID,
                                                                       int discreteInputsLength,
                                                                       int discreteInputsChunkOffset,
                                                                       boolean[] discreteInputsChunkData)
                                                                throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read discrete inputs. * Request ID: Request ID of the corresponding request that is being answered. * Discrete Inputs: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadDiscreteInputsRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterReadDiscreteInputs

        public int modbusMasterReadDiscreteInputs​(int slaveAddress,
                                                  long startingAddress,
                                                  int count)
                                           throws TinkerforgeException
        In Modbus master mode this function can be used to read discrete inputs from a slave. This function creates a Modbus function code 2 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first discrete input to read. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a discrete input number in the range of 1 to 65536. The prefix digit 1 (for discrete input) is implicit and must be omitted. * Count: Number of discrete inputs to read. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterReadDiscreteInputsResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadInputRegistersRequestLowLevel

        public void modbusSlaveAnswerReadInputRegistersRequestLowLevel​(int requestID,
                                                                       int inputRegistersLength,
                                                                       int inputRegistersChunkOffset,
                                                                       int[] inputRegistersChunkData)
                                                                throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read input registers. * Request ID: Request ID of the corresponding request that is being answered. * Input Registers: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadInputRegistersRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterReadInputRegisters

        public int modbusMasterReadInputRegisters​(int slaveAddress,
                                                  long startingAddress,
                                                  int count)
                                           throws TinkerforgeException
        In Modbus master mode this function can be used to read input registers from a slave. This function creates a Modbus function code 4 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first input register to read. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead an input register number in the range of 1 to 65536. The prefix digit 3 (for input register) is implicit and must be omitted. * Count: Number of input registers to read. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterReadInputRegistersResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • setFrameReadableCallbackConfiguration

        public void setFrameReadableCallbackConfiguration​(int frameSize)
                                                   throws TinkerforgeException
        Configures the BrickletRS485.FrameReadableListener listener. The frame size is the number of bytes, that have to be readable to trigger the listener. A frame size of 0 disables the listener. A frame size greater than 0 enables the listener and disables the BrickletRS485.ReadListener listener. By default the listener is disabled. .. versionadded:: 2.0.5$nbsp;(Plugin)
        Throws:
        TinkerforgeException
      • getSPITFPErrorCount

        public BrickletRS485.SPITFPErrorCount getSPITFPErrorCount()
                                                           throws TinkerforgeException
        Returns the error count for the communication between Brick and Bricklet. The errors are divided into * ACK checksum errors, * message checksum errors, * framing errors and * overflow errors. The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.
        Throws:
        TinkerforgeException
      • setBootloaderMode

        public int setBootloaderMode​(int mode)
                              throws TinkerforgeException
        Sets the bootloader mode and returns the status after the requested mode change was instigated. You can change from bootloader mode to firmware mode and vice versa. A change from bootloader mode to firmware mode will only take place if the entry function, device identifier and CRC are present and correct. This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
        Throws:
        TinkerforgeException
      • setWriteFirmwarePointer

        public void setWriteFirmwarePointer​(long pointer)
                                     throws TinkerforgeException
        Sets the firmware pointer for writeFirmware(int[]). The pointer has to be increased by chunks of size 64. The data is written to flash every 4 chunks (which equals to one page of size 256). This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
        Throws:
        TinkerforgeException
      • writeFirmware

        public int writeFirmware​(int[] data)
                          throws TinkerforgeException
        Writes 64 Bytes of firmware at the position as written by setWriteFirmwarePointer(long) before. The firmware is written to flash every 4 chunks. You can only write firmware in bootloader mode. This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
        Throws:
        TinkerforgeException
      • setStatusLEDConfig

        public void setStatusLEDConfig​(int config)
                                throws TinkerforgeException
        Sets the status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
        Throws:
        TinkerforgeException
      • getChipTemperature

        public int getChipTemperature()
                               throws TinkerforgeException
        Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature! The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.
        Throws:
        TinkerforgeException
      • reset

        public void reset()
                   throws TinkerforgeException
        Calling this function will reset the Bricklet. All configurations will be lost. After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
        Throws:
        TinkerforgeException
      • writeUID

        public void writeUID​(long uid)
                      throws TinkerforgeException
        Writes a new UID into flash. If you want to set a new UID you have to decode the Base58 encoded UID string into an integer first. We recommend that you use Brick Viewer to change the UID.
        Throws:
        TinkerforgeException
      • getIdentity

        public Device.Identity getIdentity()
                                    throws TinkerforgeException
        Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier. The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
        Specified by:
        getIdentity in class Device
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadCoilsRequest

        public void modbusSlaveAnswerReadCoilsRequest​(int requestID,
                                                      boolean[] coils)
                                               throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read coils. * Request ID: Request ID of the corresponding request that is being answered. * Coils: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadCoilsRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadHoldingRegistersRequest

        public void modbusSlaveAnswerReadHoldingRegistersRequest​(int requestID,
                                                                 int[] holdingRegisters)
                                                          throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read holding registers. * Request ID: Request ID of the corresponding request that is being answered. * Holding Registers: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadHoldingRegistersRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusMasterWriteMultipleCoils

        public int modbusMasterWriteMultipleCoils​(int slaveAddress,
                                                  long startingAddress,
                                                  boolean[] coils)
                                           throws TinkerforgeException
        In Modbus master mode this function can be used to write multiple coils of a slave. This function creates a Modbus function code 15 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first coil to write. For backwards compatibility reasons, this parameter is called Starting Address.It is not an address, but instead a coil number in the range of 1 to 65536. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterWriteMultipleCoilsResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusMasterWriteMultipleRegisters

        public int modbusMasterWriteMultipleRegisters​(int slaveAddress,
                                                      long startingAddress,
                                                      int[] registers)
                                               throws TinkerforgeException
        In Modbus master mode this function can be used to write multiple registers of a slave. This function creates a Modbus function code 16 request. * Slave Address: Address of the target Modbus slave. * Starting Address: Number of the first holding register to write. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted. Upon success the function will return a non-zero request ID which will represent the current request initiated by the Modbus master. In case of failure the returned request ID will be 0. When successful this function will also invoke the BrickletRS485.ModbusMasterWriteMultipleRegistersResponseListener callback. In this listener the Request ID provided by the listener argument must be matched with the Request ID returned from this function to verify that the listener is indeed for a particular request.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadDiscreteInputsRequest

        public void modbusSlaveAnswerReadDiscreteInputsRequest​(int requestID,
                                                               boolean[] discreteInputs)
                                                        throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read discrete inputs. * Request ID: Request ID of the corresponding request that is being answered. * Discrete Inputs: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadDiscreteInputsRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException
      • modbusSlaveAnswerReadInputRegistersRequest

        public void modbusSlaveAnswerReadInputRegistersRequest​(int requestID,
                                                               int[] inputRegisters)
                                                        throws TinkerforgeException
        In Modbus slave mode this function can be used to answer a master request to read input registers. * Request ID: Request ID of the corresponding request that is being answered. * Input Registers: Data that is to be sent to the Modbus master for the corresponding request. This function must be called from the BrickletRS485.ModbusSlaveReadInputRegistersRequestListener listener with the Request ID as provided by the argument of the listener.
        Throws:
        TinkerforgeException