Package jmri.jmrix

Interface SerialPortAdapter

    • Method Detail

      • getPortNames

        default java.util.Vector<java.lang.String> getPortNames()
        Provide a vector of valid port names, each a String. This may be implemented differently in subclasses that e.g. do loopkac or use a custom port-access library.
        Returns:
        Valid port names in the form used to select them later.
      • openPort

        java.lang.String openPort​(java.lang.String portName,
                                  java.lang.String appName)
        Open a specified port.
        Parameters:
        portName - name tu use for this port
        appName - provided to the underlying OS during startup so that it can show on status displays, etc.
        Returns:
        null indicates OK return, else error message.
      • configure

        void configure()
        Configure all of the other jmrix widgets needed to work with this adapter.
        Specified by:
        configure in interface PortAdapter
      • status

        boolean status()
        Query the status of this connection. This is a question of configuration, not transient hardware status.
        Specified by:
        status in interface PortAdapter
        Returns:
        true if OK, at least as far as known
      • setPort

        void setPort​(java.lang.String s)
        Remember the associated port name.
        Parameters:
        s - name of the port
      • validBaudRates

        java.lang.String[] validBaudRates()
        Get an array of valid baud rate strings; used to display valid options in Connections Preferences.
        Returns:
        array of I18N display strings of port speed settings valid for this serial adapter, must match order and values from validBaudNumbers()
      • validBaudNumbers

        int[] validBaudNumbers()
        Get an array of valid baud rate numbers; used to store/load adapter speed option.
        Returns:
        integer array of speeds, must match order and values from validBaudRates()
      • defaultBaudIndex

        int defaultBaudIndex()
        Get the index of the default port speed for this adapter from the validSpeeds and validRates arrays.
        Returns:
        -1 to indicate not supported, unless overridden in adapter
      • configureBaudRate

        void configureBaudRate​(java.lang.String rate)
        Set the baud rate description by port speed description.

        Only to be used after construction, but before the openPort call.

        Parameters:
        rate - the baud rate as I18N description, eg. "28,800 baud"
      • configureBaudRateFromNumber

        void configureBaudRateFromNumber​(java.lang.String index)
        Set the baud rate description by port speed number (as a string) from validBaudRates[].

        Only to be used after construction, but before the openPort call.

        Parameters:
        index - the port speed as unformatted number string, eg. "28800"
      • configureBaudRateFromIndex

        void configureBaudRateFromIndex​(int index)
        Set the baud rate description by index (integer) from validBaudRates[].
        Parameters:
        index - the index to select from speeds[] array
      • getCurrentBaudNumber

        java.lang.String getCurrentBaudNumber()
        To store as XML attribute, get a string to represent current port speed.
        Returns:
        speed as number string
      • configureOption1

        void configureOption1​(java.lang.String value)
        Set the first port option. Only to be used after construction, but before the openPort call.
        Specified by:
        configureOption1 in interface PortAdapter
        Parameters:
        value - to set the option to
      • configureOption2

        void configureOption2​(java.lang.String value)
        Set the second port option. Only to be used after construction, but before the openPort call.
        Specified by:
        configureOption2 in interface PortAdapter
        Parameters:
        value - to set the option to
      • configureOption3

        void configureOption3​(java.lang.String value)
        Set the third port option. Only to be used after construction, but before the openPort call.
        Specified by:
        configureOption3 in interface PortAdapter
        Parameters:
        value - to set the option to
      • configureOption4

        void configureOption4​(java.lang.String value)
        Set the fourth port option. Only to be used after construction, but before the openPort call.
        Specified by:
        configureOption4 in interface PortAdapter
        Parameters:
        value - to set the option to
      • handlePortBusy

        java.lang.String handlePortBusy​(purejavacomm.PortInUseException p,
                                        java.lang.String portName,
                                        org.slf4j.Logger log)
        Error handling for busy port at open.
        Parameters:
        p - the exception being handled, if additional information from it is desired.
        portName - name of the port being accessed.
        log - where to log a status message.
        Returns:
        Localized message, in case separate presentation to user is desired.
        See Also:
        AbstractSerialPortController
      • setManufacturer

        void setManufacturer​(java.lang.String Manufacturer)
        Set the System Manufacturers Name.
        Specified by:
        setManufacturer in interface PortAdapter
        Parameters:
        Manufacturer - the manufacturer's name