Search in sources :

Example 1 with CS8900

use of ejip.CS8900 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 2 with CS8900

use of ejip.CS8900 in project jop by jop-devel.

the class Lift 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);
    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); 
        new RtThread(5, 10000) {

            public void run() {
                for (; ; ) {
                    waitForNextPeriod();
                    net.run();
                    ipLink.run();
                }
            }
        };
    }
    /* there is some problem with the ACEX board and paramter in Flash ???
 
 
		par = new Param();
		fwp = new Fwp();
		Serial ser;
		if (simpc) {
			ser = new Serial(Const.IO_UART_BG_MODEM_BASE, 10, 3000);
		} else {
			ser = new Serial(Const.IO_UART1_BASE, 10, 3000);
		}
		if (evn) {
			modem = Modem.getInstance(5, 100000, ser);
		} else {
			new Modbus(5, 10000, ser, outReg);
		}
		
		loop = new Loop(7, 20000);
*/
    ctrl = new LiftControl();
    RtThread.startMission();
    forever();
}
Also used : CS8900(ejip.CS8900) HtmlBaseio(ejip.HtmlBaseio) RtThread(joprt.RtThread) Ejip(ejip.Ejip) Net(ejip.Net)

Example 3 with CS8900

use of ejip.CS8900 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();
}
Also used : Tftp(ejip.Tftp) Ejip(ejip.Ejip) CS8900(ejip.CS8900) Serial(util.Serial) HtmlBaseio(ejip.HtmlBaseio) RtThread(joprt.RtThread) Net(ejip.Net)

Aggregations

CS8900 (ejip.CS8900)3 Ejip (ejip.Ejip)3 Net (ejip.Net)3 RtThread (joprt.RtThread)3 HtmlBaseio (ejip.HtmlBaseio)2 Serial (util.Serial)2 Tftp (ejip.Tftp)1