Package com.pi4j.io.serial
Class SerialPort
- java.lang.Object
-
- com.pi4j.io.serial.SerialPort
-
public class SerialPort extends Object
-
-
Constructor Summary
Constructors Constructor Description SerialPort()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getDefaultPort()
Get the default serial port for the detected platform/model/board revision.static String
getDefaultPort(SystemInfo.BoardType board)
Get the default serial port for the specified platform/model/board revision.
-
-
-
Method Detail
-
getDefaultPort
public static String getDefaultPort() throws IOException, InterruptedException, UnsupportedBoardType
Get the default serial port for the detected platform/model/board revision.- Returns:
- com port device path
- Throws:
IOException
InterruptedException
UnsupportedBoardType
-
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
-
-