public interface PiUtil extends PiVals
ThePi
, ClientPigpiod
etc. must implement (inherit from) this interface PiUtil
. Modifier and Type | Interface and Description |
---|---|
static class |
PiUtil.Impl
Internal implementation class.
|
static class |
PiUtil.LeTick
A tick as mutable object.
|
Modifier and Type | Field and Description |
---|---|
static int |
ERR_ASSIGN_PIN
Pin assignment error.
|
static int |
ERR_CLOSE_WDOG
Can't close the watchdog.
|
static int |
ERR_NoGPIOLOCK
Program has no GPIO lock.
|
static int |
ERR_NoLOCKFILE
Lock file does not exist.
|
static int |
ERR_NoLOCKPROC
Lock process can not be started.
|
static int |
ERR_NOT_LOCKED
Lock file could not be locked.
|
static int |
ERR_OPEN_W_DOG
Can't open watchdog.
|
static int |
ERR_PIGPIOD_CON
Socket connecting error.
|
static String |
lckPiGpioPth
Common path to a lock file for Gpio use.
|
static String |
lckWinGpioPth
Common path to a lock file for use on Windows.
|
GPIO_INP, GPIO_OUT, GPIOmax, GPIOmin, GPIOutM, H1, HI, L0, LO, PI_PUD_DOWN, PI_PUD_DT, PI_PUD_KP, PI_PUD_OFF, PI_PUD_UP, PIN0, PIN00, PIN01, PIN02, PIN04, PIN06, PIN09, PIN0V, PIN1, PIN14, PIN17, PIN2, PIN20, PIN25, PIN3V, PIN4, PIN5V, PIN6, PIN9, PINig, PINix, PIO_ALT0, PIO_ALT1, PIO_ALT2, PIO_ALT3, PIO_ALT4, PIO_ALT5
AUTHOR, BLANK_STRING, cons, CONSOL_ENCODING, COPYRIGHT, D, D_NaN, D_NegInf, D_PosInf, EMPTY_INT_A, EMPTY_STRING, FILE_ENCODING, FRW_CLLD, FS, FSS, H, hasCons, HOST_IP, HOST_IPv4, HOST_NAME, INIT_ERROR, JAR_ENCODING, JH, JOB_DONE_OK, JRL, LOG_OUT_ERROR, M, MAIN_THREAD_EXC, NO_BYTES, NO_CLASSES, NO_DOUBLES, NO_OBJECTS, NO_PARS_ERROR, NO_STRINGS, NOT_WINDOWS, ON_PI, ONE_DAY, ONE_HOUR, ONE_LEAP_YEAR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR, OS, PROG_NAME, PROG_SHORT, PS, RUNTIME, S, SHY, UD, UL, UL_UR_da, UR
Modifier and Type | Method and Description |
---|---|
default String |
argHost()
Start argument getter.
|
default int |
argPiType()
Start argument getter.
|
default int |
argPort()
Start argument getter.
|
default int |
argTimeout()
Start argument getter.
|
default void |
closeLock()
Unlock the lock file.
|
default int |
closeWatchdog()
Close the watchdog.
|
static Appendable |
eightDigitHex(Appendable dest,
int value)
Format as eight digit hexadecimal number.
|
static String |
errorText(int errNum)
Get error text.
|
default int |
getDelCnt()
Get the number of thread delays.
|
default Throwable |
getLastExcept()
Get the last (recorded) exception.
|
default String |
getLastExcMess()
Get the last expection's message.
|
default String |
getLastLockFN()
Get the last lock file.
|
default PrintWriter |
getOut()
The standard output.
|
default int |
getOvrCnt()
Get the number of spoiled delays.
|
default boolean |
getUseLock()
Do use lock.
|
default int |
openLock(String lckPiGpioFil,
boolean verbose)
Open and lock lock file.
|
default int |
openLockPi(String lckPiGpioFil,
boolean verbose)
Open and lock lock file on Pi, only.
|
default int |
openWatchdog()
Initialise respectively start the watchdog.
|
default String |
regAsStdMBean()
Register this application as standard MBean.
|
default void |
repExc(Appendable out,
Throwable exc,
boolean trace)
Report an exception.
|
default void |
setArgHost(String argHost)
Start argument setter.
|
default void |
setArgPiType(int argPiType)
Start argument setter.
|
default void |
setArgPort(int argPort)
Start argument setter.
|
default void |
setArgTimeout(int argTimeout)
Start argument setter.
|
default void |
setUseLock(boolean use)
Do use lock.
|
default void |
systemExit(int ret)
System exit.
|
default void |
thrDelay(int millies)
Periodic delay.
|
default void |
triggerWatchdog()
Trigger the watchdog.
|
static Appendable |
twoDigitDec(Appendable dest,
int value)
Format as two digit decimal number with leading zero.
|
static final int ERR_NoLOCKPROC
PiUtil.Impl.lastExept
.static final int ERR_NoLOCKFILE
static final int ERR_NOT_LOCKED
static final int ERR_NoGPIOLOCK
openWatchdog()
) will be rejected
when the program is not owning the GPIO lock.static final int ERR_OPEN_W_DOG
static final int ERR_CLOSE_WDOG
static final int ERR_ASSIGN_PIN
static final int ERR_PIGPIOD_CON
static final String lckPiGpioPth
static final String lckWinGpioPth
default PrintWriter getOut()
default void systemExit(int ret)
out
, waits a few ms to let that
happen and then lets end all with System.exit(ret)
. ret
- the return codedefault String regAsStdMBean() throws JMException
JMException
- if the registering failsdefault void repExc(Appendable out, Throwable exc, boolean trace)
out
- the output for the reportexc
- the exception to report ontrace
- true: print also a stack trace
(and only if out is a PrintWriter or a PrrintStream)static Appendable twoDigitDec(Appendable dest, int value)
dest
is the two digit decimal representation of
value
if in the range 0..99's. Otherwise two blanks are appended
bits.TextHelper.twoDigitDec(Appendable, int)
. It is here to facilitate
using PiUtil
, ClientPigpiod
sources etc. without the
de.frame4j packages. But why should one want to do this?dest
- destination to append to; if null dest is made as
StringBuilder with initial capacity of 6value
- the numberstatic Appendable eightDigitHex(Appendable dest, int value)
dest
(generated StringBuilder if supplied as null)
is the six digit hexadecimal representation of value
's lower 24
bits. This representation is quite usual for 24 bit RGB colours.TextHelper.eightDigitHex(Appendable, int)
. It is here
to facilitate using PiUtil
, ClientPigpiod
etc. (sources)
without the de.frame4j packages. But why should one want to do this?dest
- destination to append to; if null dest is made as
StringBuilder with initial capacity of 14Color
,
twoDigitDec(Appendable, int)
,
getOut()
static String errorText(int errNum)
ERR_NoLOCKPROC
, ERR_NoLOCKFILE
, ERR_NOT_LOCKED
,
ERR_NoGPIOLOCK
, ERR_OPEN_W_DOG
,
ERR_CLOSE_WDOG
. Other Errors return "error -123"errNum
- the error number; 0: OK gets an empty Stringdefault boolean getUseLock()
setUseLock(boolean)
default void setUseLock(boolean use)
use
- true: usage will be set; false: will be ignoredgetUseLock()
default int openLock(String lckPiGpioFil, boolean verbose)
useLock
is false this method does nothing and
returns 0.lckPiGpioFil
- if not null or empty use this path instead of the
platform default one (/home/pi/bin/.lockPiGpio)verbose
- true: make the lock process verbose (by option -v) on
standard outputERR_NoLOCKFILE
,
ERR_NOT_LOCKED
default int openLockPi(String lckPiGpioFil, boolean verbose)
openLock(String, boolean)
.openLock(String, boolean)
,
#ERR_NOT_LOCKED
default void closeLock()
openLock(String, boolean)
or
openLockPi(String, boolean)
this method just does nothing.releasing
the outputs used.default int openWatchdog()
openLock(String, boolean)
. Additionally the watchdog will work only
when allowed (on the Pi) for non root.triggerWatchdog()
) at least every 16 s or closed
(by closeWatchdog()
). Otherwise the Raspberry Pi will be
reset and reboot.default void triggerWatchdog()
default int closeWatchdog()
default void thrDelay(int millies)
getDelCnt()
. millies
ms. The number of delays having been spoiled so can be
obtained by getOvrCnt()
. millies
- the number of ms to delay relativ to the last calldefault int getDelCnt()
#getOvrCnt()
default int getOvrCnt()
#getCycCnt()
default String getLastLockFN()
default Throwable getLastExcept()
getLastExcMess()
is
not threadsafe. Use onla in single threaded program phases like first
initialisation and final clean up.default String getLastExcMess()
getLastExcept()
default void setArgPiType(int argPiType)
default int argPiType()
default void setArgPort(int argPort)
default int argPort()
default void setArgTimeout(int argTimeout)
default int argTimeout()
default void setArgHost(String argHost)
default String argHost()