Newsletter
January 19, 2016 - 10:12am, 4420 views
hi,
do anybody have a watchdog example (java midlet)?
Hi,
This example kicked the internal watchdog and the wachdog of the terminal BGS5 (PIN22)
Setup in Terminal wachdog ( look at at the documentation)
* WD= RST_GPIO,1500000,6
* WD= ALWAYS_ON, 300000,3 OK
* you should also configure WD=MIN_START_TIME,18000000,9
* WD=ON,1,1 OK
* command AT^SCFG="Userware/Watchdog",”1” enables internal WD (in module, not terminal)
Below you can find simple Java code with kicking those two WD (wd of module is kicking with Watchdog2 class, terminal wd is kicking with toggling the GPIO22)
import java.io.IOException;
import java.util.Vector; import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.cinterion.io.OutPort;
import com.cinterion.misc.Watchdog2;
public class Main extends MIDlet implements Runnable{
Watchdog2 wd;
OutPort op;
Vector WDpin;
Vector value;
public Main() {
System.out.println("Consrtuctor");
wd = new Watchdog2();
WDpin = new Vector(1);
value = new Vector (1);
WDpin.addElement("GPIO22");
value.addElement(Integer.valueOf("1"));
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
System.out.println("destroyApp");
wd.start(0);
try {
kick_terminalWD();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
op.release();
} catch (IOException e) {
// TODO Auto-generated catch block e.printStackTrace();
}
notifyDestroyed();
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
System.out.println("StartApp");
wd.start(90);
try {
op = new OutPort(WDpin,value);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new Thread(this).start();
}
public void run() {
int i =0;
while(i<10){
sleep(15000);
kick_moduleWD();
try {
kick_terminalWD();
} catch (IOException e) {
// TODO Auto-generated catch block e.printStackTrace();
}
}
try {
destroyApp(true);
}catch (MIDletStateChangeException e) {
// TODO Auto-generated catch block e.printStackTrace();
}
}
private void kick_terminalWD() throws IOException {
int i = op.getValue();
if (i>0)
op.setValue(0);
else
op.setValue(1);
System.out.println("WDpin value: " + op.getValue());
}
private void kick_moduleWD() {
wd.kick();
System.out.println("module WD kicked!");
}
private void sleep(int time)
{
try { Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Regards
Alopez
Somewhere over the rainbow!!! Looking for the Oz Land!!!
Hi,
Alopez gave you good example, I would just like to add GPIO for watchdog is dependet on firmware version of module and it's type. For example BGS5T has diffrent GPIO watchdog since firmware 1.50.3 and is now GPIO8. So check in the last Cinterion® Java Terminals Hardware Interface Description for the correct GPIO.
Regards,
Jure
Dear Jure,
You are rigth!!
Thank you for the tip!!
Regards
ALopez
Somewhere over the rainbow!!! Looking for the Oz Land!!!