Example program for the lwIP TCP/IP stack (library lwip_1_4_0_rc2) and the QP state machine framework (library qp). This program demonstrates use of lwIP in hard real-time applications, in which the TCP/IP stack is used to monitor and configure the embedded device as well as to provide remote user interface (e.g., by means of a web browser). In particular, the lwIP stack, which is not reentrant, is strictly encapsulated inside a dedicated QP state machine object (active object in QP), so interrupt locking around calls to lwIP is unnecessary. Also, the Ethernet interrupt service routine (ISR) runs very fast without performing any lengthy copy operations. All this means that hard-real-time processing can be done at the task level, especially when you use the preemptive QK kernel built into QP for executing your application. No external RTOS component is needed to achieve fully deterministic real-time response of active object tasks prioritized above the lwiP task. The lwIP-QP integration uses exclusively the event-driven lwIP API. The heavyweight Berkeley-like socket API requiring a blocking RTOS and is not used, which results in much better performance of the lwIP stack and less memory consumption. NOTE: This example compiles cleanly, but does not run just yet because the low-level Ethernet driver in the lwIP library needs to be completed. See comments in the lwip_1_4_0_rc2 library for more information.

Dependencies:   mbed

Committer:
QL
Date:
Sun Mar 27 16:50:21 2011 +0000
Revision:
0:84f3d3d7e5d9
0.9

Who changed what in which revision?

UserRevisionLine numberNew contents of line
QL 0:84f3d3d7e5d9 1 //////////////////////////////////////////////////////////////////////////////
QL 0:84f3d3d7e5d9 2 // Product: DPP example with lwIP
QL 0:84f3d3d7e5d9 3 // Last Updated for Version: 4.0.03
QL 0:84f3d3d7e5d9 4 // Date of the Last Update: Mar 16, 2009
QL 0:84f3d3d7e5d9 5 //
QL 0:84f3d3d7e5d9 6 // Q u a n t u m L e a P s
QL 0:84f3d3d7e5d9 7 // ---------------------------
QL 0:84f3d3d7e5d9 8 // innovating embedded systems
QL 0:84f3d3d7e5d9 9 //
QL 0:84f3d3d7e5d9 10 // Copyright (C) 2002-2009 Quantum Leaps, LLC. All rights reserved.
QL 0:84f3d3d7e5d9 11 //
QL 0:84f3d3d7e5d9 12 // This software may be distributed and modified under the terms of the GNU
QL 0:84f3d3d7e5d9 13 // General Public License version 2 (GPL) as published by the Free Software
QL 0:84f3d3d7e5d9 14 // Foundation and appearing in the file GPL.TXT included in the packaging of
QL 0:84f3d3d7e5d9 15 // this file. Please note that GPL Section 2[b] requires that all works based
QL 0:84f3d3d7e5d9 16 // on this software must also be made publicly available under the terms of
QL 0:84f3d3d7e5d9 17 // the GPL ("Copyleft").
QL 0:84f3d3d7e5d9 18 //
QL 0:84f3d3d7e5d9 19 // Alternatively, this software may be distributed and modified under the
QL 0:84f3d3d7e5d9 20 // terms of Quantum Leaps commercial licenses, which expressly supersede
QL 0:84f3d3d7e5d9 21 // the GPL and are specifically designed for licensees interested in
QL 0:84f3d3d7e5d9 22 // retaining the proprietary status of their code.
QL 0:84f3d3d7e5d9 23 //
QL 0:84f3d3d7e5d9 24 // Contact information:
QL 0:84f3d3d7e5d9 25 // Quantum Leaps Web site: http://www.quantum-leaps.com
QL 0:84f3d3d7e5d9 26 // e-mail: info@quantum-leaps.com
QL 0:84f3d3d7e5d9 27 //////////////////////////////////////////////////////////////////////////////
QL 0:84f3d3d7e5d9 28 #ifndef dpp_h
QL 0:84f3d3d7e5d9 29 #define dpp_h
QL 0:84f3d3d7e5d9 30
QL 0:84f3d3d7e5d9 31 enum DPPSignals {
QL 0:84f3d3d7e5d9 32 EAT_SIG = Q_USER_SIG, // published by Table to let a philosopher eat
QL 0:84f3d3d7e5d9 33 DONE_SIG, // published by Philosopher when done eating
QL 0:84f3d3d7e5d9 34 BTN_DOWN_SIG, // published by ISR_SysTick when user button is pressed
QL 0:84f3d3d7e5d9 35 BTN_UP_SIG, // published by ISR_SysTick when user button is released
QL 0:84f3d3d7e5d9 36
QL 0:84f3d3d7e5d9 37 DISPLAY_IPADDR_SIG, // published by lwIPMgr to display IP addres
QL 0:84f3d3d7e5d9 38 DISPLAY_CGI_SIG, // published by lwIPMgr to display CGI text
QL 0:84f3d3d7e5d9 39 DISPLAY_UDP_SIG, // published by lwIPMgr to display UDP text
QL 0:84f3d3d7e5d9 40 TERMINATE_SIG, // published by BSP to terminate the application
QL 0:84f3d3d7e5d9 41 MAX_PUB_SIG, // the last published signal
QL 0:84f3d3d7e5d9 42
QL 0:84f3d3d7e5d9 43 HUNGRY_SIG, // posted direclty to Table from hungry Philosopher
QL 0:84f3d3d7e5d9 44 SEND_UDP_SIG, // posted directly to lwIPMgr to send text via UDP
QL 0:84f3d3d7e5d9 45 MAX_SIG // the last signal
QL 0:84f3d3d7e5d9 46 };
QL 0:84f3d3d7e5d9 47
QL 0:84f3d3d7e5d9 48 struct TableEvt : public QEvent {
QL 0:84f3d3d7e5d9 49 uint8_t philoNum; // philosopher number
QL 0:84f3d3d7e5d9 50 };
QL 0:84f3d3d7e5d9 51
QL 0:84f3d3d7e5d9 52 #define MAX_TEXT_LEN 16
QL 0:84f3d3d7e5d9 53 struct TextEvt : public QEvent {
QL 0:84f3d3d7e5d9 54 char text[MAX_TEXT_LEN]; // text to deliver
QL 0:84f3d3d7e5d9 55 };
QL 0:84f3d3d7e5d9 56
QL 0:84f3d3d7e5d9 57 // number of philosophers
QL 0:84f3d3d7e5d9 58 #define N_PHILO 5
QL 0:84f3d3d7e5d9 59
QL 0:84f3d3d7e5d9 60 extern QActive * const AO_Philo[N_PHILO]; // "opaque" pointers to Philo AO
QL 0:84f3d3d7e5d9 61 extern QActive * const AO_Table; // "opaque" pointer to Table AO
QL 0:84f3d3d7e5d9 62 extern QActive * const AO_LwIPMgr; // "opaque" pointer to LwIPMgr AO
QL 0:84f3d3d7e5d9 63
QL 0:84f3d3d7e5d9 64 #ifdef Q_SPY
QL 0:84f3d3d7e5d9 65 enum AppRecords { // application-specific trace records
QL 0:84f3d3d7e5d9 66 PHILO_STAT = QS_USER, // traced by Philo to display status
QL 0:84f3d3d7e5d9 67 LWIP_SLOW_TICK, // traced by lwIPMgr for each slow tick
QL 0:84f3d3d7e5d9 68 LWIP_IPADDR, // traced by lwIPMgr to display IP addres
QL 0:84f3d3d7e5d9 69 LWIP_CGI, // traced by lwIPMgr to display CGI text
QL 0:84f3d3d7e5d9 70 LWIP_RECV_UDP, // traced by lwIPMgr when receiving UDP
QL 0:84f3d3d7e5d9 71 LWIP_SEND_UDP, // traced by lwIPMgr when sending UDP
QL 0:84f3d3d7e5d9 72 };
QL 0:84f3d3d7e5d9 73 #endif
QL 0:84f3d3d7e5d9 74
QL 0:84f3d3d7e5d9 75 #endif // dpp_h