use of joprt.RtThread in project jop by jop-devel.
the class MainSlipUart2 method main.
/**
* Start network and enter forever loop.
*/
public static void main(String[] args) {
Dbg.initSerWait();
//
// start TCP/IP and all (four) threads
//
net = Net.init();
// don't use CS8900 when simulating on PC or for BG263
// LinkLayer ipLink = CS8900.init(Net.eth, Net.ip);
// don't use PPP on my web server
// Ppp.init(Const.IO_UART_BG_MODEM_BASE);
//
// use second serial line for simulation
// with JopSim
//
ser = new Serial(Const.IO_UART_BG_MODEM_BASE);
ipLink = Slip.init(ser, (192 << 24) + (168 << 16) + (1 << 8) + 2);
//
// start device driver threads
//
new RtThread(5, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
net.loop();
}
}
};
// Slip timeout (for windoz slip reply) depends on
// period (=100*period) !
new RtThread(9, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ipLink.loop();
}
}
};
new RtThread(10, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ser.loop();
}
}
};
//
// WD thread has lowest priority to see if every timing will be met
//
RtThread.startMission();
forever();
}
use of joprt.RtThread in project jop by jop-devel.
the class MainSlip method main.
/**
* Start network and enter forever loop.
*/
public static void main(String[] args) {
Dbg.init();
//
// start TCP/IP and all (four) threads
//
//net = Ip.init();
// don't use CS8900 when simulating on PC or for BG263
// LinkLayer ipLink = CS8900.init(Ip.eth, Ip.ip);
// don't use PPP on my web server
// Ppp.init(Const.IO_UART_BG_MODEM_BASE);
ser = new Serial(10, 3000, Const.IO_UART1_BASE);
ipLink = Slip.init(9, 10000, ser, (192 << 24) + (168 << 16) + (1 << 8) + 2, 1500);
//
// start device driver threads
//
new RtThread(5, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
// Ip.loop();
}
}
};
//
// WD thread has lowest priority to see if every timing will be met
//
RtThread.startMission();
forever();
}
use of joprt.RtThread in project jop by jop-devel.
the class MainPppLoop method main.
/**
* Start network and enter forever loop.
*/
public static void main(String[] args) {
Dbg.initSerWait();
//
// initialize TCP/IP
//
net = Net.init();
ser = new Serial(Const.IO_UART_BG_MODEM_BASE);
//
// Create serial and PPP
//
new RtThread(IPSER_PRIO, IPSER_PERIOD) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ser.loop();
}
}
};
RtThread pppThre = new RtThread(IPLINK_PRIO, IPLINK_PERIOD) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ipLink.loop();
}
}
};
ipLink = Ppp.init(ser, pppThre);
new RtThread(20, 100000) {
public void run() {
int i = 0;
for (; ; ) {
waitForNextPeriod();
net.loop();
++i;
if (i == 10) {
Timer.wd();
System.out.print('*');
i = 0;
}
Timer.loop();
}
}
};
ipLink.startConnection(new StringBuffer("*99***1#"), new StringBuffer("A1.net"), new StringBuffer("ppp@A1plus.at"), new StringBuffer("ppp"));
RtThread.startMission();
// forever();
for (; ; ) {
int t = Timer.getTimeoutMs(800);
while (!Timer.timeout(t)) {
RtThread.sleepMs(10);
}
System.out.print("M");
}
}
use of joprt.RtThread in project jop by jop-devel.
the class JopClient method main.
public static void main(String[] args) {
Dbg.initSerWait();
DsvmPacket.init();
receivedPacket = false;
state = BOOTSTATE;
sendcnt = 0;
info = false;
counter = 0;
// SVM data and the place to decide the size of the training set
// i, number of data
m = 100;
// j, dimensions
n = 2;
data_fp = new int[m][];
y_fp = new int[m];
// PC IP //130.226.36.11
destIp = (130 << 24) + (226 << 16) + (36 << 8) + 11;
destPort = 1234;
receivePort = 2345;
// 24-2-2006: Hack to get the thread to init now because "new UdpJop..."
// causes a stack overflow if the thread init is done in that
// call flow
new RtThread(0, 1000000000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
}
}
};
udpJop = new UdpJop(destIp, destPort, receivePort);
// new RtThread(20, 100000) {
// public void run() {
// for (;;) {
// if (SMOBinaryClassifierFP.printSMOInfo) {
// SMOBinaryClassifierFP.smoInfo();
// SMOBinaryClassifierFP.printSMOInfo = false;
// }
// waitForNextPeriod();
// }
// }
// };
//
// new RtThread(19, 100000) {
// public void run() {
// for (;;) {
// if (SMOBinaryClassifierFP.takeStepFlag
// && SMOBinaryClassifierFP.go) {
// SMOBinaryClassifierFP.takeStep();
// SMOBinaryClassifierFP.takeStepFlag = false;
// }
// waitForNextPeriod();
// }
// }
// };
// class Test extends SwEvent {
// static Test testsmo;
// public Test(int priority, int minTime) {
// super(priority, minTime);
// }
//
// public void handle() {
// test();
// }
// };
RtThread.startMission();
// System.out.println("about to sleep");
//RtThread.sleepMs(2000); // Waiting for alive packet to initialize arp
// System.out.println("slept");
/*
* DsvmPacket dp = new DsvmPacket(); dp.setData(new int[2]);
* System.out.println("about to send"); udpJop.send(dp);
* System.out.println("test packet sent"); okSend = true;
* System.out.println("HERE2");
*/
int cnt = 0;
// System.out.println("state " + state);
while (state != INITSTATE) {
RtThread.sleepMs(100);
}
System.out.println("INITSTATE");
RtThread.sleepMs(1000);
DsvmPacket.setCommand(DsvmPacket.INIT);
// System.out.println("about to send init");
// Training
udpJop.send();
RtThread.sleepMs(500);
System.out.println("TRAINING");
for (int i = 0; i < m; i++) {
// System.out.println("About to DsvmPacket.TRAININGDATAREQUEST" +
// i);
DsvmPacket.setCommand(DsvmPacket.TRAININGDATAREQUEST);
receivedPacket = false;
udpJop.send();
waitForReply();
// System.out.println("got training data i=" + i);
if (DsvmPacket.getCommand() != DsvmPacket.TRAININGDATA) {
System.out.println("Expected training data!");
System.exit(1);
}
//Creates a new object
data_fp[i] = DsvmPacket.getDataFP();
y_fp[i] = DsvmPacket.getLabelFP();
if (info) {
System.out.println((counter++) + " trainingData={");
for (int j = 0; j < n; j++) {
System.out.println("data_fp[" + i + "][" + j + "]=" + data_fp[i][j]);
}
System.out.println("}, y_fp[" + i + "]=" + y_fp[i]);
}
}
SMOBinaryClassifierFP.setData_fp(data_fp);
SMOBinaryClassifierFP.setY_fp(y_fp);
//SMOBinaryClassifierFP.smo.fire();
SMOBinaryClassifierFP.mainRoutine();
//while(!SMOBinaryClassifierFP.done)
// RtThread.sleepMs(500);
System.out.println("About to test");
test();
for (; ; ) {
System.out.println("cnt " + (cnt++));
// Timer.wd();
RtThread.sleepMs(1000);
if (state == NEVER)
break;
}
}
use of joprt.RtThread in project jop by jop-devel.
the class Periodic method main.
public static void main(String[] args) {
// use serial line for debug output
Dbg.initSerWait();
result = new int[CNT];
RtThread rt = new RtThread(10, 50) {
public void run() {
int ts, ts_old;
int i;
waitForNextPeriod();
waitForNextPeriod();
ts_old = Native.rd(Const.IO_US_CNT);
for (i = 0; i < CNT; ++i) {
waitForNextPeriod();
ts = Native.rd(Const.IO_US_CNT);
result[i] = ts - ts_old;
ts_old = ts;
}
result();
}
void result() {
int max = 0;
int min = 999999999;
int i;
for (i = 0; i < CNT; ++i) {
int diff = result[i];
if (diff < min)
min = diff;
if (diff > max)
max = diff;
Dbg.intVal(diff);
Dbg.wr('\n');
}
Dbg.intVal(min);
Dbg.intVal(max);
Dbg.wr('\n');
for (; ; ) waitForNextPeriod();
}
};
RtThread.startMission();
forever();
}
Aggregations