@MinDoc(copyright="Copyright 2021 A. Weinert", version="V.65", lastModified="3.06.2024", usage="start as Java application (-? for help)", purpose="a Frame4J program to test IO devices on a Pi via pigpioD") public class TestOnPi extends App implements PiUtil, TestOnPiMBean
-input select input gpio or pin (prefix P) and optional pull resistor
settings (postfix U D or N); P0 means no input
-output dto. for (non LED) output operations
-ON -OFF set selected (non LED) output ON respectively OFF
-val -v set (by next parameter) dutycycle 0..255 or servo pulse
width 0:off; 500 ..1500:middle.. 2500:clockwise for the output
-wait -w wait for about 1 second
-help help output. See for further command line options and more.
Additionally to command line arguments, the settings and functions might
be made or called via JMX/JConsole.
java de.weAut.TestOnPi -help
java TestOnPi -?
java TestOnPi -help -de
java TestOnPi -en -help
Help output, optionally using the the Starter application in the anonymous
package (for typing comfort), optionally choosing the output language.
-de (Deutsch) stands for German.
java TestOnPi -blink -south
java TestOnPi -west -east -blink 192.168.178.67
java TestOnPi raspi67 -north -blink -cycLim 3122
Blink the south cross road LEDs on the default Pi. If run on Pi with Java8
and Frame4J this is the Pi itself; on a non Pi machine like a Windows PC
(with Java(8) and Frame4J) this will be a Pi with the IPv4 address ending
with .67 in the same (W)LAN.
java TestOnPi -outPort 3 -winkServo -de -cycLim 89012
Test a RC servo attached to Pin 3 (and 5V and Gnd) by winking over almost
the whole (180°) range in many small steps.
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_
BlinkOnPi
,
TestOnPiMBean
,
PiUtil
,
TestOnPi.properties,
Raspi4testPinsPiUtil.Impl, PiUtil.LeTick
Modifier and Type | Field and Description |
---|---|
int[] |
ledGNpins
The LEDs to blink.
|
int[] |
ledRDpins
The LEDs to blink.
|
int[] |
ledYEpins
The LEDs to blink.
|
ThePi.Port |
portIn
The input or button.
|
ThePi.Port |
portOut
The GPIO respectively pin to use for (single / non LED) operations.
|
ano, appBase, appIO, appStartTime, appStartTimeMS, args, argsOrig, bgColor, err, fullClassName, help, icon, log, mainThread, myClass, myFrame, name, out, outMode, packName, prop, retCode, runFlag, shortClassName, title, verbose, verbosity
ERR_ASSIGN_PIN, ERR_CLOSE_WDOG, ERR_NoGPIOLOCK, ERR_NoLOCKFILE, ERR_NoLOCKPROC, ERR_NOT_LOCKED, ERR_OPEN_W_DOG, ERR_PIGPIOD_CON, lckPiGpioPth, lckWinGpioPth
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
ILLEGAL_TYPE, ILLEGAL_VALUE, NO_ATTRIBUTE, NO_KNOWN_ATTRIBUTE, NO_VALUE, OK, retVtext
Constructor and Description |
---|
TestOnPi() |
Modifier and Type | Method and Description |
---|---|
void |
blink()
Blink the LEDs.
|
int |
doIt()
The application's work.
|
Integer |
getCycCount()
The number of cycles.
|
Integer |
getCycLim()
The limit for the number of cycles.
|
Integer |
getCycOvr()
Get the number of spoiled delays.
|
String |
getInPort()
Get the port for input actions.
|
Boolean |
getLEDgn()
The state of the green LED(s).
|
Boolean |
getLEDrd()
The state of the red LED(s).
|
Boolean |
getLEDye()
The state of the yellow LED(s).
|
String |
getOutPort()
Get the output for (non LED) actions.
|
String |
getOutput()
The state of the output.
|
Integer |
getPiType()
Get the Pi type.
|
Integer |
getStepDelay()
Get delay / ms between two operations.
|
Integer |
getStepVal()
Get step between two PMW or servo values.
|
Integer |
getVal()
Get PMW or servo current value.
|
Integer |
getValLo()
Get PMW or servo value lower limit.
|
Integer |
getValUp()
Get PMW or servo value upper limit.
|
Boolean |
input()
Just input.
|
Boolean |
inToInvOut()
Input and set the output with the inverted result.
|
static void |
main(String[] args)
The application start.
|
boolean |
parsePartial()
Partial evaluation of start parameters by Prop.
|
void |
setCycCount(Integer cycCount)
Set the number of cycles.
|
void |
setCycLim(int cycLim) |
void |
setCycLim(Integer cycLim)
Set the limit for number of cycles.
|
void |
setInPort(String inPort)
Set the input for input actions.
|
void |
setLedGNpin(int index,
int pin)
Indexed property ledGNpin[], setter.
|
void |
setLedRDpin(int index,
int pin)
Indexed property ledRDpin[], setter.
|
void |
setLedYEpin(int index,
int pin)
Indexed property ledYEpin[], setter.
|
void |
setOutPort(String outPort)
Set the output for (non LED) actions.
|
void |
setOutput(String out)
Set the output.
|
void |
setStepDelay(int delay) |
void |
setStepDelay(Integer delay)
Set delay / ms between two operations.
|
void |
setStepVal(int stepVal) |
void |
setStepVal(Integer stepVal)
Set step between two PMW or servo values.
|
void |
setVal(int val) |
void |
setVal(Integer val)
Set PMW or servo current value.
|
void |
setValLo(int valLo) |
void |
setValLo(Integer valLo)
Set PMW or servo value lower limit.
|
void |
setValUp(int valUp) |
void |
setValUp(Integer valUp)
Set PMW or servo value upper limit.
|
void |
stopTask()
Stop the task.
|
void |
wink()
Servo wink respectively PWM up/down.
|
void |
winkPWM()
PWM continuously up and down over almost full range.
|
void |
winkServo()
Wink servo over almost full range.
|
actionPerformed, allowNoPropertiesFile, clientOrder, condHelpLog, connect, errMeld, errMeld, errorExit, errorExit, errorText, extraPropertiesFile, formMessage, formMessage, formMessage, getAbout, getAboutText, getActTime, getAppLogger, getAppStartTime, getArgs, getAuthor, getCopyright, getDbLogger, getExecTimeMs, getExecTimeMsL, getExecTimeString, getHelp, getHelpText, getIcon, getLanguage, getLogHandler, getMessageComponent, getMessageComponentsLength, getMyFrame, getName, getNameWithVersDate, getOutMode, getProp, getPurpose, getStartTime, getStateString, getTheCloser, getTitle, getUsage, getVerbose, getVerbosity, getVersDate, go, go, go, haveIcon, isDebug, isHelp, isHelpLog, isNormal, isRunFlag, isSilent, isTest, isVerbose, logVerbose, logVerbose, makeStatusTextEnd, makeStatusTextStart, messageFormat, normalExit, performeAction, queueAction, regAsStdMBean, repExc, setAboutText, setAttribute, setAttribute, setAuthor, setBgColor, setCodePages, setCopyright, setHelp, setLogOut2, setName, setOutMode, setOutMode, setPurpose, setTitle, setUsage, setVerbose, setVerbose, setVerbosity, setVerbosity, setVersDate, stop, threeLineEndMsg, toString, twoLineEndMsg, twoLineStartMsg, valueLang, valueLang, wakeMainThread
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
argHost, argPiType, argPort, argTimeout, closeLock, closeWatchdog, eightDigitHex, errorText, getDelCnt, getLastExcept, getLastExcMess, getLastLockFN, getOut, getOvrCnt, getUseLock, openLock, openLockPi, openWatchdog, regAsStdMBean, repExc, setArgHost, setArgPiType, setArgPort, setArgTimeout, setUseLock, systemExit, thrDelay, triggerWatchdog, twoDigitDec
getActTime, getArgs, getCopyright, getExecTimeMsL, getLanguage, getName, getPurpose, getStartTime, getVerbose, getVersDate, stop
retVtext
public int[] ledRDpins
public int[] ledYEpins
public int[] ledGNpins
public ThePi.Port portIn
PINig
resp. 0 : ignore no operation
and PI_PUD_KP
: keep pull up/down/none as ispublic ThePi.Port portOut
PINig
resp. 0 : ignore no operation
and PI_PUD_KP
: keep pull up/down/none as ispublic final boolean parsePartial()
App
Prop
object shall
evaluate and check the start parameters (see App.args
) only
partially. For the meaning of "partial evaluation" please see
Prop#parse(String[],CharSequence,boolean)
Prop.parse(String[], CharSequence, boolean)
.Prop
is a
fixed property of an application classes extending App must override this
method finally this methods default behaviour is not wanted.parsePartial
in class App
App(String[])
public void setLedRDpin(int index, int pin)
public void setLedYEpin(int index, int pin)
public void setLedGNpin(int index, int pin)
public final void setStepVal(int stepVal)
public final void setCycLim(int cycLim)
public final void setValUp(int valUp)
public void setValLo(int valLo)
public final void setStepDelay(int delay)
public void setVal(int val)
public final Integer getCycCount()
TestOnPiMBean
getCycCount
in interface TestOnPiMBean
TestOnPiMBean.setCycCount(Integer)
,
TestOnPiMBean.getCycOvr()
public void setCycCount(Integer cycCount)
TestOnPiMBean
setCycCount
in interface TestOnPiMBean
public final Integer getCycOvr()
TestOnPiMBean
getCycOvr
in interface TestOnPiMBean
PiUtil.thrDelay(int)
,
TestOnPiMBean.getCycCount()
public final Integer getCycLim()
TestOnPiMBean
setCycCount(0)
, if any, or the
application will stop.getCycLim
in interface TestOnPiMBean
TestOnPiMBean.setCycLim(Integer)
,
TestOnPiMBean.getCycCount()
public void setCycLim(Integer cycLim)
TestOnPiMBean
cycLim
and, also,
resets the number of cycles to 0.setCycLim
in interface TestOnPiMBean
cycLim
- the limit; 0 effectively means endlesspublic Boolean getLEDye()
TestOnPiMBean
getLEDye
in interface TestOnPiMBean
public Boolean getLEDgn()
TestOnPiMBean
getLEDgn
in interface TestOnPiMBean
public Boolean getLEDrd()
TestOnPiMBean
getLEDrd
in interface TestOnPiMBean
public Integer getPiType()
TestOnPiMBean
getPiType
in interface TestOnPiMBean
public final void setStepDelay(Integer delay)
TestOnPiMBean
setStepDelay
in interface TestOnPiMBean
delay
- 2 .. 29999 ms; default 10 mspublic final Integer getStepDelay()
TestOnPiMBean
getStepDelay
in interface TestOnPiMBean
public final void setStepVal(Integer stepVal)
TestOnPiMBean
setStepVal
in interface TestOnPiMBean
stepVal
- the value will be adjusted at use if not fittingpublic final Integer getStepVal()
TestOnPiMBean
getStepVal
in interface TestOnPiMBean
public void setVal(Integer val)
TestOnPiMBean
setVal
in interface TestOnPiMBean
val
- the value will be adjusted at use if not fittingpublic Integer getVal()
TestOnPiMBean
getVal
in interface TestOnPiMBean
public void setValUp(Integer valUp)
TestOnPiMBean
setValUp
in interface TestOnPiMBean
valUp
- the limit will be adjusted at use if not fittingpublic Integer getValUp()
TestOnPiMBean
getValUp
in interface TestOnPiMBean
public void setValLo(Integer valLo)
TestOnPiMBean
setValLo
in interface TestOnPiMBean
valLo
- the limit will be adjusted at use if not fittingpublic Integer getValLo()
TestOnPiMBean
getValLo
in interface TestOnPiMBean
public void stopTask()
TestOnPiMBean
TestOnPiMBean.blink()
or
TestOnPiMBean.wink()
etc.) if any is running. This will start the next task
pending. Otherwise it will act like App.stop()
.stopTask
in interface TestOnPiMBean
public void setOutPort(String outPort)
setOutPort
in interface TestOnPiMBean
outPort
- output pin (12N, e.g.) or gpio (with leading G; G18, e.g.)TestOnPiMBean.getOutPort()
,
TestOnPiMBean.getInPort()
,
TestOnPiMBean.setInPort(String)
public void setInPort(String inPort)
setInPort
in interface TestOnPiMBean
inPort
- input pin (7, e.g.) or gpio (with leading G; G4U, e.g.)TestOnPiMBean.getInPort()
,
TestOnPiMBean.setOutPort(String)
,
TestOnPiMBean.getOutPort()
public String getOutPort()
TestOnPiMBean
"07UG04"
. TestOnPiMBean.setOutPort(String)
; for the example
setOutPort("7U")
would be sufficient.getOutPort
in interface TestOnPiMBean
TestOnPiMBean.setOutPort(String)
,
TestOnPiMBean.getInPort()
,
TestOnPiMBean.setInPort(String)
public String getInPort()
TestOnPiMBean
getInPort
in interface TestOnPiMBean
TestOnPiMBean.setInPort(String)
,
TestOnPiMBean.setOutPort(String)
,
TestOnPiMBean.getOutPort()
public void blink()
blink
in interface TestOnPiMBean
public void winkServo()
winkServo
in interface TestOnPiMBean
public void winkPWM()
winkPWM
in interface TestOnPiMBean
public void wink()
portOut
allows no out nothing is done except a message.val
determines the mode: wink
in interface TestOnPiMBean
public void setOutput(String out)
TestOnPiMBean
String out
as does
ClientPigpiod.setOutput(gpio, out)
usually by implementing it so.setOutput
in interface TestOnPiMBean
out
- the output valueClientPigpiod.setOutput(int, String)
public Boolean inToInvOut()
TestOnPiMBean
inToInvOut
in interface TestOnPiMBean
TestOnPiMBean.input()
,
TestOnPiMBean.setOutput(String)
public Boolean input()
TestOnPiMBean
1/Hi
TRUE will be returned.input
in interface TestOnPiMBean
TestOnPiMBean.inToInvOut()
public String getOutput()
setOutput(value)
or other actions.getOutput
in interface TestOnPiMBean
public static void main(String[] args)
doIt()
).
Can be stopped by signal (cntlC), kill command and the like, as well as
by an MBean client, like e.g. JConsole, by operation App.stop()
.
Run by java TestOnPi [host [port]] [-option [-option ....-north 29 31 33; -east 36 38 40; -south 11 13 15; -west 16 18 22;
-LEDefault 11 22 13
-pi0 -pi1 -pi3 -pi4
(0, 1, 3 and 4 map to 3, the default)args
- start parameters.public int doIt()
doIt
in class App
Prop
,
App.go(String[])
,
App.go(String[], String, CharSequence)
,
App.mainThread