Class SerialPort


  • public class SerialPort
    extends Object
    • Constructor Detail

      • SerialPort

        public SerialPort()
    • Method Detail

      • getDefaultPort

        public static String getDefaultPort​(SystemInfo.BoardType board)
                                     throws UnsupportedBoardType
        Get the default serial port for the specified platform/model/board revision.
        Parameters:
        board - hardware board type
        Returns:
        com port device path REF: https://www.raspberrypi.org/documentation/configuration/uart.md By default, only UART0 is enabled. The following table summarises the assignment of the first two UARTs: ---------------------------------------------------------------- Model | first PL011 (UART0) | mini UART ---------------------------------------------------------------- Raspberry Pi Zero primary secondary Raspberry Pi Zero W secondary (Bluetooth) primary Raspberry Pi 1 primary secondary Raspberry Pi 2 primary secondary Raspberry Pi 3 secondary (Bluetooth) primary Raspberry Pi 4 secondary (Bluetooth) primary ---------------------------------------------------------------- Note: the mini UART is disabled by default, whether it is designated primary or secondary UART. Linux devices on Raspberry Pi OS: ---------------------------------------------------------- Linux device Description ---------------------------------------------------------- /dev/ttyS0 mini UART /dev/ttyAMA0 first PL011 (UART0) /dev/serial0 primary UART /dev/serial1 secondary UART ---------------------------------------------------------- Note: /dev/serial0 and /dev/serial1 are symbolic links which point to either /dev/ttyS0 or /dev/ttyAMA0.
        Throws:
        UnsupportedBoardType