use of util.Serial 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 util.Serial in project jop by jop-devel.
the class Tal method main.
/**
* Start all threads and enter forever loop.
*/
public static void main(String[] args) {
// we provide a null pointer in Startup.java for JOP
simpc = args != null;
evn = true;
run = true;
// will be UDP...
if (simpc) {
Dbg.initSer();
} else {
Dbg.init();
}
//
// start TCP/IP
//
Ejip ejip = new Ejip();
net = new Net(ejip);
net.getUdp().addHandler(Tftp.PORT, new Tftp(ejip));
int[] outReg = new int[1];
outReg[0] = 0;
HtmlBaseio http = new HtmlBaseio();
// register the simple HTTP server
net.getTcp().addHandler(80, http);
http.setOutValArray(outReg);
// don't use CS8900 when simulating on PC
if (!simpc) {
int[] eth = { 0x00, 0xe0, 0x98, 0x33, 0xb0, 0xf8 };
int ip = Ejip.makeIp(192, 168, 0, 123);
ipLink = new CS8900(ejip, eth, ip);
}
// use instead Slip for PC simulation
// LinkLayer ipLink = Slip.init(Const.IO_UART_BG_MODEM_BASE,
// (192<<24) + (168<<16) + (1<<8) + 2);
//
// start device driver threads
//
new RtThread(5, 10000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
net.run();
if (!simpc)
ipLink.run();
}
}
};
par = new Param();
fwp = new Fwp(ejip, net);
if (simpc) {
ser = new Serial(Const.IO_UART_BG_MODEM_BASE);
} else {
ser = new Serial(Const.IO_UART1_BASE);
}
if (evn) {
modem = Modem.getInstance(5, 100000, ser);
} else {
new Modbus(5, 10000, ser, outReg);
}
new RtThread(10, 3000) {
public void run() {
for (; ; ) {
waitForNextPeriod();
ser.loop();
}
}
};
loop = new Loop(7, 5000);
RtThread.startMission();
forever();
}
use of util.Serial in project jop by jop-devel.
the class MainPpp method main.
/**
* Start network and enter forever loop.
*/
public static void main(String[] args) {
Ejip ejip = new Ejip();
//
// start TCP/IP
//
net = new Net(ejip);
//
// use second serial line for simulation
// with JopSim and on the project usbser
//
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.run();
}
}
};
ipLink = new Ppp(ejip, ser, pppThre);
new RtThread(20, 100000) {
public void run() {
int i = 0;
for (; ; ) {
waitForNextPeriod();
net.run();
++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();
for (; ; ) {
int t = Timer.getTimeoutMs(800);
while (!Timer.timeout(t)) {
RtThread.sleepMs(10);
}
System.out.print("M");
}
}
use of util.Serial 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 = 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);
ser = new Serial(Const.IO_UART1_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, 3000) {
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 util.Serial in project jop by jop-devel.
the class Server method main.
public static void main(String[] args) {
// inits 10 packet buffers with 1500B each
PacketPool.init(10, 1500);
Serial ser;
if (TWO_SERIAL) {
// serial debug output
Dbg.initSer();
// simulator
ser = new Serial(10, 1000, Const.IO_UART_BG_MODEM_BASE);
} else {
// sends debug output over the network to 192.168.2.1:10000 (see init method)
DbgUdp.init();
// one byte every ~400us at 19200 baud
ser = new Serial(10, 1000, Const.IO_UART1_BASE);
}
// initializes a routing table with 3 routes
Router.init(3);
LinkLayer slip = Slip.init(9, 10000, ser, Ip.Ip(192, 168, 1, 2), 1500);
// ip (and therefore icmp and tcp) loop thread: period 50ms
Ip.init(6, 50000);
Router.addRoute(new Route(Ip.Ip(192, 168, 2, 0), Ip.Ip(255, 255, 255, 0), slip));
// where should packets go which are not matched by a route?
Router.setDefaultInterface(slip);
Dbg.wr("Starting Mission");
Dbg.lf();
RtThread.startMission();
Router.print();
Dbg.wr("Starting Server");
Dbg.lf();
Server server = new Server();
server.run();
}