Search in sources :

Example 1 with Serial

use of ejip123.util.Serial in project jop by jop-devel.

the class BgInit method main.

/**
*	Start network and enter forever loop.
*/
public static void main(String[] args) {
    Dbg.initSerWait();
    Ejip ejip = new Ejip();
    //
    //	start TCP/IP
    //
    net = new Net(ejip);
    net.getUdp().addHandler(Tftp.PORT, new Tftp(ejip));
    //
    //	use second serial line for simulation
    //	with JopSim and on the project usbser
    //
    ser = new Serial(Const.IO_UART_BG_MODEM_BASE);
    int ip = Ejip.makeIp(192, 168, 1, 2);
    ipLink = new Slip(ejip, ser, ip);
    //
    //	start device driver threads
    //
    new RtThread(5, 10000) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                net.run();
            }
        }
    };
    // Slip timeout (for windoz slip reply) depends on
    // period (=100*period) !
    new RtThread(9, 10000) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                ipLink.run();
            }
        }
    };
    new RtThread(10, 3000) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                ser.loop();
            }
        }
    };
    new Display(1, 5000);
    System.out.println("Bginit");
    RtThread.startMission();
    Display.write(0, "BG263 Init");
    //
    //	WD thread has lowest priority to see if every timing will be met
    //
    forever();
}
Also used : Serial(util.Serial) RtThread(joprt.RtThread)

Example 2 with Serial

use of ejip123.util.Serial in project jop by jop-devel.

the class Sms method main.

/**
*	Test main.
*/
public static void main(String[] args) {
    // that's the UDP version
    Dbg.init();
    init();
    ser = new Serial(Const.IO_UART1_BASE);
    new RtThread(1, 10000) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                ser.loop();
            }
        }
    };
    //
    //	start TCP/IP
    //
    Ejip ejip = new Ejip();
    net = new Net(ejip);
    // don't use CS8900 when simulating on PC or for BG263
    int[] eth = { 0x00, 0xe0, 0x98, 0x33, 0xb0, 0xf8 };
    int ip = Ejip.makeIp(192, 168, 0, 123);
    ipLink = new CS8900(ejip, eth, ip);
    //
    //	start device driver threads
    //
    new RtThread(5, 10000) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                net.run();
            }
        }
    };
    new RtThread(5, 10000) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                ipLink.run();
            }
        }
    };
    RtThread.startMission();
    int i, j;
    int[] text = { 'H', 'e', 'l', 'l', 'o', ' ', 'f', 'r', 'o', 'm', ' ', 'J', 'O', 'P', '!' };
    int[] nr = { '4', '3', '6', '9', '9', '1', '9', '5', '2', '0', '2', '2', '0' };
    int[] gotNr = new int[Sms.NR_MAX];
    int gotNrType;
    int timer = Timer.getTimeoutMs(1000);
    int sec = 0;
    boolean doit = true;
    for (; ; ) {
        loop();
        if (Timer.timeout(timer)) {
            timer = Timer.getTimeoutMs(1000);
            ++sec;
        }
        if (state == READY && doit) {
            Dbg.wr("ready to send");
            //	0x91 for intl. numbers (43...)
            Sms.send(text, nr, 0x91);
            doit = false;
        }
        if (gotSms) {
            //				tim();
            Dbg.wr("got SMS:");
            for (i = 0; i < rcvTxt.length; ++i) {
                j = rcvTxt[i];
                if (j == 0)
                    break;
                Dbg.wr((char) j);
            }
            Dbg.lf();
            Dbg.wr("from ");
            for (i = 0; i < rcvNr.length; ++i) {
                j = rcvNr[i];
                if (j == 0)
                    break;
                Dbg.wr((char) j);
            }
            Dbg.wr(" type: " + Sms.rcvNrType);
            Dbg.lf();
            Sms.strcpy(gotNr, Sms.rcvNr);
            gotNrType = Sms.rcvNrType;
            if (Sms.isFree()) {
                Dbg.wr("send replay");
                Dbg.lf();
                Sms.send(text, gotNr, gotNrType);
            } else {
                Dbg.wr("send buffer full!");
                Dbg.lf();
            }
            Sms.gotSms = false;
        }
    }
}
Also used : CS8900(ejip.CS8900) Serial(util.Serial) RtThread(joprt.RtThread) Ejip(ejip.Ejip) Net(ejip.Net)

Example 3 with Serial

use of ejip123.util.Serial in project jop by jop-devel.

the class HTTPServer method main.

/**
	*	Start network and enter forever loop.
	*/
public static void main(String[] args) {
    ejip = new Ejip(100, 1500);
    //
    //	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);
    int ip = Ejip.makeIp(192, 168, 1, 2);
    ipLink = new Slip(ejip, ser, ip);
    // create http server
    HTTPServer server = new HTTPServer();
    // register http server
    net.getTcp().addHandler(80, server);
    forever();
}
Also used : Serial(util.Serial)

Example 4 with Serial

use of ejip123.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) {
    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);
    int ip = Ejip.makeIp(192, 168, 1, 2);
    ipLink = new Slip(ejip, ser, ip);
    // register the simple HTTP server
    net.getTcp().addHandler(80, new HtmlBaseio());
    forever();
}
Also used : Serial(util.Serial)

Example 5 with Serial

use of ejip123.util.Serial in project jop by jop-devel.

the class SMTPClient method main.

/**
	*	Start network and enter forever loop.
	*/
public static void main(String[] args) {
    ejip = new Ejip(8, 256);
    //
    //	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);
    int ip = Ejip.makeIp(192, 168, 1, 2);
    ipLink = new Slip(ejip, ser, ip);
    // create smtp client
    String message = ("From: <jop@jopdesign.com>\r\n" + "To: <user@host>\r\n" + "Subject: Hello, world!\r\n" + "Happy happy, joy joy :-)");
    SMTPClient client = new SMTPClient("jopdesign.com", "jop@jopdesign.com", "user@host", message);
    // register smtp client
    net.getTcp().addHandler(10025, client);
    // get connection to smtp server 192.168.1.1 (postfix running on local PC)
    net.getTcp().startConnection(ipLink, Ejip.makeIp(192, 168, 1, 1), 25);
    forever();
}
Also used : Serial(util.Serial)

Aggregations

Serial (util.Serial)11 RtThread (joprt.RtThread)10 Serial (ejip123.util.Serial)9 CS8900 (ejip.CS8900)2 Ejip (ejip.Ejip)2 Net (ejip.Net)2 HtmlBaseio (ejip.HtmlBaseio)1 Tftp (ejip.Tftp)1