mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
17487f9ebe
- This should actually be a merge but we made a mistake on the initial repo creation and a merge was not possible. - Below there is a resumed log of the commit messages for the few steps, just for the record. - The merged commit messages for this work are: - Removing Portuguese doc content - Ignore folder names fixed on .gitignore - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined - Removing folder cache from git versioning - Removing folder dist from git versioning. The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore - Removed file - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Moving all files and folders to a working doc folder - Css updated - Index page added and CSS adjusts - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - files deleted - Changed function that creates functions submenus. - Menu inserted with árvore, CSS adjusts, google search - Changed past design to new design - CSS updated - initial import - The commit ids were also preserved but they are related to this "other" work done on Led Lab. We'll keep the repo just in case. 4dce3f77c47b0c3001a2075a946e80ee52759b49 - Removing Portuguese doc content 78d8847525cacf045fe7e672cff6bd1e058a6a4b Ignore folder names fixed on .gitignore 48dee6b7962168ab1098bf709ead6f3cfe6b7964 - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined 2aa2fe0c554db03dbc7029c34d0f4500fe625b37 - Removing folder cache from git versioning - Removing folder dist from git versioning The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore af6cc2890edf1855af319dc999a03feee5f9bee0 Removed file 6a180e72eb4f4860620cafc0685000e9f2174cfe Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git eb430112e78ae537459ab315e228ebca84bdf2d4 Moving all files and folders to a working doc folder d28a7c99489915630bd2625f3756fecf0d08ce37 Css updated 32836ffe382f04ab07c3e6f018c7b449a20d7a8d Index page added and CSS adjusts 1461d9957d9d25a1467cb57ab8717aa213a37e8d Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ae1934c04f35a29e25bb4495ae8a31cd9c000b5b Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> b5f31d70f1fac8d3fba325c9867a03f976775698 Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ec9ad8446b7ea38b252c6a416e70774349835e45 files deleted bd7a80151b2030720ba8d8a303467d8c25a4b4b2 Changed function that creates functions submenus. 6a7494acaec694fadbb13520bcbccc51a6b95dfe Inserido menu com árvore, ajustes no CSS, busca do google e979f1c259d425c9a3be83f9cda20eddffe073bb Changed past design to new design. 381459e95286886b052103a0253e60b29e064d7a CSS updated 4f81d2f1195efe733fe5f97517be325d75937bc3 initial import
91 lines
5.9 KiB
HTML
91 lines
5.9 KiB
HTML
$$HEADER$$
|
|
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
|
<h3>TCP/IP in eLua <span class="warning">(WIP)</span></h3>
|
|
<p><b>eLua</b>'s TCP/IP support was designed with flexibility and ease of use in mind. It
|
|
might not provide all the functions of a "full-fledged" TCP/IP stack, but it's
|
|
still fully functional, has a much smaller footprint and is probably easier to use than a "regular" (POSIX) TCP/IP
|
|
stack. These are the services provided by the TCP/IP stack:</p>
|
|
<ul>
|
|
<li>a set of functions for network access (defined in inc/elua_net.h)</li>
|
|
<li>a DHCP client</li>
|
|
<li>a DNS resolver</li>
|
|
<li>a module (<a href="refman_gen_net.html">net</a>) which can be used from Lua to access the network functions</li>
|
|
<li>a Telnet miniclient, which is used to support the eLua shell via TCP/IP instead of serial connections.</li>
|
|
</ul>
|
|
<br />
|
|
|
|
<h2>TCP/IP configuration</h2>
|
|
<p>To configure the TCP/IP subsystem, <i>edit src/platform/<name>platform_conf.h</i> and:</p>
|
|
<ol>
|
|
<li><b>#define BUILD_UIP</b> to enable TCP/IP support</li>
|
|
<li>if you'll be using the DHCP client, just <b>#define BUILD_DHCPC</b> to build the
|
|
DHCP client. In any case, you must also define a static network configuration:
|
|
|
|
<p><b>#define ELUA_CONF_IPADDR0 ... ELUA_CONF_IPADDR3</b> : the IP address<br>
|
|
<b>#define ELUA_CONF_NETMASK0 ... ELUA_CONF_NETMASK3</b> : the network mask<br>
|
|
<b>#define ELUA_CONF_DEFGW0 ... ELUA_CONF_DEFGW3</b> : the default gateway<br>
|
|
<b>#define ELUA_CONF_DNS0 ... ELUA_CONF_DNS3</b> : the DNS server </p>
|
|
|
|
<p>Note that you must define both <b>BUILD_DHCPC</b> and the <b>ELUA_CONF_*</b> macros. If the
|
|
DHCP client fails to obtain a valid IP address, the static configuration will
|
|
be used instead. To use only the static configuration (and make the eLua image
|
|
size a bit smaller) don't define the BUILD_DHCPC client.</p></li>
|
|
|
|
<li><b>#define BUILD_DNSM</b> if you want support for the DNS server.</li>
|
|
<li><b>#define BUILD_CON_TCP</b> if you want support for shell over telnet instead of
|
|
serial. Note that you must NOT define <b>BUILD_CON_GENERIC</b> in this case (see
|
|
<a href="arch_con_term.html">here</a> for details).</li>
|
|
</ol>
|
|
<p>You'll also need an uIP configuration file (<i>src/platform/<name>/uip-conf.h</i>) to configure the TCP/IP
|
|
stack. For an example, look at <i>src/platform/<lm3s>/uip-conf.h</i>. The header if quite self-explanatory, below
|
|
you have a list of parameters that you might want to change:</p>
|
|
<ul>
|
|
<li><b>u8_t, u16_t</b>: define these types to match your platform.</li>
|
|
<li><b>UIP_CONF_MAX_CONNECTIONS</b>: the maximum number of TCP connections that can be active at a given time.</li>
|
|
<li><b>UIP_CONF_UDP_CONNS</b>: same thing for UDP connections.</li>
|
|
<li><b>UIP_CONF_BYTE_ORDER</b>: <b>LITTLE_ENDIAN</b> or <b>BIG_ENDIAN</b>, it's very important to match this with your architecture.</li>
|
|
<li><b>UIP_CONF_BUFFER_SIZE</b>: the size of the buffer used by uIP for all its connections. You should keep it small to avoid memory consumption,
|
|
but doing so when you have to transfer large amounts of data will slow the transfer speed. 1k seems to be a good compromise.</li>
|
|
<li><b>UIP_CONF_UDP</b>: turn off UDP support. While <b>eLua</b> doesn't have support for UDP via its <b>net</b> module at this time, UDP can still
|
|
be used (for example by DNS/DHCP), so be careful if you disable this.</li>
|
|
<li><b>ELUA_DHCP_TIMER_ID</b>: the timer ID used for the TCP/IP subsystem. Note that this should be a dedicated timer, not available to the rest
|
|
of the system (or available in "read-only" mode).</li>
|
|
</ul>
|
|
<br />
|
|
|
|
<h2>TCP/IP implementation internals</h2>
|
|
<p>The TCP/IP support was designed in such a way that it doesn't require a specific
|
|
TCP/IP stack implementation. To work with <b>eLua</b>, a TCP/IP stack must simply
|
|
implement all the functions defined in the inc/elua_net.h file. This allows for
|
|
easy integration of more than one TCP/IP stack. Currently only uIP is used in
|
|
eLua, but lwIP (and possibly others) are planned to be added at some point.
|
|
Another key point of the TCP/IP implementation (and of the whole <b>eLua</b> design
|
|
for that matter) is that it should be as platform independent as possible: write
|
|
everything in a platform-independent manner, except for some functions (as few as
|
|
possible and as simple as possible) that must be implemented by each platform.
|
|
To illustrate the above, a short overview of the uIP integration is given below.</p>
|
|
|
|
<p><a href="http://www.sics.se/~adam/uip/index.php/Main_Page">uIP</a> is a minimalistic TCP/IP
|
|
stack designed specifically for resource constrained embedded systems. While the
|
|
design and implementation of uIP are an excellent example of what can be done
|
|
with a few kilobytes of memory, it has a number of quirks that make it hard to
|
|
integrate with <b>eLua</b>. First, it uses a callback approach, as opposed to the
|
|
sequential approach of "regular" TCP/IP stacks. It provides a "protosocket"
|
|
library that can be used to write uIP applications in a more "traditional" way,
|
|
but it's quite restrictive. So, to use it with <b>eLua</b>, a translation layer was
|
|
needed. It is implemented in <i>src/elua_uip.c</i>, and its sole purpose is to "adapt"
|
|
the uIP stack to the <b>eLua</b> model: implement the functions in <i>inc/elua_net.h</i> and
|
|
you're ready to use the stack. In this case the "adaption layer" is quite large
|
|
because of uIP's callback-based design.</p>
|
|
|
|
<p>To make the uIP implementation as platform-independent as possible, a special
|
|
<a href="arch_platform_eth.html">networking layer</a> is added to the <a href="arch_platform.html">platform interface</a>.
|
|
There are only 4 functions that must be implemented by a backend
|
|
to use the networking layer. They might change as more TCP/IP stacks are added
|
|
to eLua, but probably the networking layer won't get much bigger than it is now.<br>
|
|
For a more in-depth understanding of how the networking layer is implemented,
|
|
look at the LM3S implementation in <i>src/platform/lm3s/platform.c</i>.
|
|
</p>
|
|
$$FOOTER$$
|
|
|