Package com.pi4j.util
Class CommandArgumentParser
- java.lang.Object
-
- com.pi4j.util.CommandArgumentParser
-
public class CommandArgumentParser extends Object
-
-
Constructor Summary
Constructors Constructor Description CommandArgumentParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Pin
getPin(Class<? extends PinProvider> pinProviderClass, Pin defaultPin, String... args)
This utility method searches for "--pin (#)" or "-p (#)" in the command arguments array and returns a Pin instance based on the pin address/number specified.static PinPullResistance
getPinPullResistance(PinPullResistance defaultPull, String... args)
This utility method searches for "--pull (up|down|off)", "--l (up|down|off)", "--up", or "--down" in the command arguments array and returns a PinPullResistance instance based on the option value provided.static SerialConfig
getSerialConfig(SerialConfig defaultConfig, String... args)
This utility method searches for the following options: "--device (device-path)" [DEFAULT: /dev/ttyAMA0] "--baud (baud-rate)" [DEFAULT: 38400] "--data-bits (5|6|7|8)" [DEFAULT: 8] "--parity (none|odd|even)" [DEFAULT: none] "--stop-bits (1|2)" [DEFAULT: 1] "--flow-control (none|hardware|software)" [DEFAULT: none] in the arguments array and returns a SerialConfig instance based on the option values detected.
-
-
-
Method Detail
-
getPin
public static Pin getPin(Class<? extends PinProvider> pinProviderClass, Pin defaultPin, String... args)
This utility method searches for "--pin (#)" or "-p (#)" in the command arguments array and returns a Pin instance based on the pin address/number specified.- Parameters:
pinProviderClass
- pin provider class to get pin instance fromdefaultPin
- default pin instance to use if no --pin argument is foundargs
- the argument array to search in- Returns:
- GPIO pin instance
-
getPinPullResistance
public static PinPullResistance getPinPullResistance(PinPullResistance defaultPull, String... args)
This utility method searches for "--pull (up|down|off)", "--l (up|down|off)", "--up", or "--down" in the command arguments array and returns a PinPullResistance instance based on the option value provided.- Parameters:
defaultPull
- default pin pull resistance to apply if no option/argument is foundargs
- the argument array to search in- Returns:
- pill pull resistance enum
-
getSerialConfig
public static SerialConfig getSerialConfig(SerialConfig defaultConfig, String... args)
This utility method searches for the following options: "--device (device-path)" [DEFAULT: /dev/ttyAMA0] "--baud (baud-rate)" [DEFAULT: 38400] "--data-bits (5|6|7|8)" [DEFAULT: 8] "--parity (none|odd|even)" [DEFAULT: none] "--stop-bits (1|2)" [DEFAULT: 1] "--flow-control (none|hardware|software)" [DEFAULT: none] in the arguments array and returns a SerialConfig instance based on the option values detected.- Parameters:
defaultConfig
- default serial configuration to apply if no option/arguments are foundargs
- the argument array to search in- Returns:
- serial config object
-
-