Nut/OS Samples
This document provides an overview of the samples included in the Nut/OS distribution.
All tests had been done with Nut/OS 4.4.
More Nut/OS examples are available in our NutWiki.
Do not miss Ernst Stippl's Ethernut Info Page , which provides:
Information about the build of various Ethernut versions and different avr-gcc and arm-gcc compiler versions
A query tool to retrieve information about contents and size of Ethernut libraries
Cross-reference information about Nut/OS and Nut/Net based on Andrew M. Bishop's cxref program
Supported Platforms
basemon | caltime | canbus | cppdemo | events | ftpd | httpd | inetq | isp2 | logtime | |
---|---|---|---|---|---|---|---|---|---|---|
ATmega103 | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
ATmega128 | Yes | Yes | No | Yes | Yes | Yes | Yes | Yes | ? | Yes |
AT90CAN128 | ? | ? | Yes | ? | ? | ? | ? | ? | ? | ? |
ATmega2561 | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
GBA | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
AT91R40008 | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
AT91SAM7X | No | Yes | No | No | Yes | Yes | Yes | Yes | ? | Yes |
AT91SAM7SE | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM9260 | No | Yes | No | Yes | Yes | No | Yes | Yes | No | Yes |
nutpiper | playmp3 | portdio | pppc | rs232d | simple | tcps | threads | timers | uart | |
---|---|---|---|---|---|---|---|---|---|---|
ATmega103 | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
ATmega128 | No | Yes | Yes | Yes | ? | ? | Yes | Yes | Yes | Yes |
AT90CAN128 | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
ATmega2561 | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
GBA | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91R40008 | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM7X | No | No | No | No | No | No | Yes | Yes | Yes | Yes |
AT91SAM7SE | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM9260 | No | No | Yes | No | Yes | Yes | Yes | Yes | Yes | Yes |
Tested Target Boards
basemon | caltime | canbus | cppdemo | events | ftpd | httpd | inetq | isp2 | logtime | |
---|---|---|---|---|---|---|---|---|---|---|
Ethernut 1 (mega103) | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
Ethernut 1.3 F | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
Ethernut 1.3 G/H | Yes | Yes | No | Yes | Yes | Yes | Yes | Yes | ? | Yes |
MMnet01 | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Ethernut 2.1 B | Yes | Yes | No | Yes | Yes | Yes | Yes | Yes | ? | Yes |
Ethernut 2.1 B (mega2561) | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Ethernut 3.0 E | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
Gameboy Advance SP | ? | ? | No | ? | ? | ? | ? | ? | ? | ? |
AT91EB40A | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM7X(C)-EK | No | Yes | No | No | Yes | Yes | Yes | Yes | ? | Yes |
EIR 1.0 C | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM9260-EK | No | No | No | No | Yes | NoFS | Yes | Yes | ? | No |
nutpiper | playmp3 | portdio | pppc | rs232d | tcps | threads | timers | uart | |
---|---|---|---|---|---|---|---|---|---|
Ethernut 1 (mega103) | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Ethernut 1.3 F | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Ethernut 1.3 G/H | NO | Yes | ? | Yes | ? | Yes | Yes | Yes | Yes |
MMnet01 | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Ethernut 2.1 B | NO | Yes | Yes | Yes | ? | Yes | Yes | Yes | Yes |
Ethernut 2.1 B (mega2561) | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Ethernut 3.0 E | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Gameboy Advance SP | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91EB40A | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM7X(C)-EK | No | No | No | No | No | Yes | Yes | Yes | Yes |
EIR 1.0 C | ? | ? | ? | ? | ? | ? | ? | ? | ? |
AT91SAM9260-EK | No | No | No | No | No | Yes | No | Yes | No |
FS File system failure.
Supported Compilers
Currently evaluated.
The following versions had been used:
- avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
- arm-elf-gcc (GCC) 4.2.1 (YAGARTO)
- ICCAVR Version 7.14 Built Aug 17 2007
basemon | caltime | canbus | cppdemo | events | ftpd | httpd | inetq | isp2 | logtime | |
---|---|---|---|---|---|---|---|---|---|---|
CrossWorks ARM | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
GCC AVR | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes |
GCC ARM | No | Yes | No | Yes | Yes | Yes | Yes | Yes | ? | Yes |
ICC AVR | ? | ? | No | No | ? | ? | ? | ? | ? | ? |
nutpiper | playmp3 | portdio | pppc | rs232d | simple | tcps | threads | timers | uart | |
---|---|---|---|---|---|---|---|---|---|---|
CrossWorks ARM | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
GCC AVR | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
GCC ARM | ? | ? | ? | ? | Yes | Yes | Yes | Yes | Yes | Yes |
ICC AVR | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? |
Prebuild Binaries
nut470-at91sam9260ek-bin.zip
Atmel AT91SAM9260 Evaluation Kit
Nut/OS 4.7.0 (CVS snapshot)
arm-elf-gcc (GCC) 4.2.1 on Windows 2000
nutconf 2.0.3 on Windows 2000
Complexity Levels
One of the following levels of complexity had been assigned to each
application:
Basic Should work on all targets without problem. Code can be easily
understood and modified.
Advanced Should work on most targets without problem. Some programming
experience will help to understand the code.
Expert Should work on most targets. Some specific knowledge may be
required. Experience with IP configurations, for example.
Guru May not work without specific configuration. Understanding all code
requires deep knowledge of system internals.
IP Configuration
Nut/Net provides several ways to configure its IP interface. Typically, the provided application samples will use DHCP, if a server is available in your local network.
Some applications display the current IP settings at the RS-232 interface, but others don't. When DHCP is used, it may be difficult to determine the correct settings, specially when you are not able to query the status of your DHCP server. One possibility is to send a broadcast ping and then check the local ARP table entries for the correct MAC/IP relation. Here's an example for Windows:
C:\>ping 192.168.1.255 192.168.1.255: Bytes=32 Zeit<10ms TTL=64 192.168.1.255: Bytes=32 Zeit<10ms TTL=64 192.168.1.255: Bytes=32 Zeit<10ms TTL=64 192.168.1.255: Bytes=32 Zeit<10ms TTL=64 C:\>arp -a Schnittstelle: 192.168.1.3 Internetadresse Physikal. Adresse Typ 192.168.1.1 10-a0-57-11-ab-e1 dynamisch 192.168.1.136 00-06-98-21-26-9b dynamischThe second entry is the one we are looking for.
However, the most simple way is to use a fixed IP address with your taget board. For AVR based boards use basemon, which allows to enter the IP address with a terminal emulator.
As basemon is not available for ARM based target boards, try the httpd sample instead. This application includes the discovery service. When it is running on your board, start the Nut/OS Discoverer on your PC (included in the distribution). It allows you to scan the local network for Nut/OS nodes and modify the IP settings of discovered boards.
Once configured, IP settings are preserved in board specific non-volatile memory. Thus, they are available until explicitly erased and will be used by all network applications. For AVR targets, the settings are stored in the on-chip EEPROM. Make sure, that the EEPROM will not be erased while uploading a new application by programming the fuse EESAVE to 0.
Check the Nut/OS Software Manual for more information about IP configuration.
basemon
Complexity Level: Guru
Target Devices: ATmega103, ATmega128, ATmega256
General test for AVR based boards, which detects most hardware failures. System configurations can be manually entered and will be stored in non-volatile memory.
Prerequisites
The application is able to run on targets without or not working external memory.
- AVR target board with serial port
- PC with serial port
- Terminal emulator running on the PC
Usage
The serial interface may be set to any rate betwenn 9600 and 115200 Baud.
Select the terminal emulator window in the PC and keep the space bar pressed. After resetting the target board, the following output should appear:
BaseMon 4.2.0 Nut/OS 4.4.0.0 Compiled by AVRGCC for ATmega128 Baudrate select = 7 External RAM Test... 44800 bytes Banked RAM Test... 30 banks, 16384 bytes ea. Serial FLASH... 540672 bytes Detecting NIC... LAN91C111 Testing NIC... OK I/O Port Test... OK Press any of the following keys: B - Send broadcasts E - Ethernet controller read/write J - Jump to bootloader S - SRAM read/write X - Exit BaseMon, configure network and start WebServerIf no output appears, set the baud rate of the terminal emulator to 38400 and do not press the space bar while resetting the target. The output should appear after about 1 minute.
Suggested Modifications and Enhancements
This sample should not be used as a template for user applications.
caltime
Complexity Level: Advanced
Target Devices: All
Demonstrates date and time functions. Uses hardware RTC, if available. This application can be used to set the hardware clock.
Prerequisites
- Target board with serial port
- PC with serial port
- Terminal emulator running on the PC
On ARM boards connect to the target's UART0 port, not DBGU.
Usage
When started, a menu is displayed on the serial port.
Calendar Time x.y running on Nut/OS X.Y.Z 0 - Display seconds counter 1 - Display universal time 2 - Display local time 3 - Calculate weekday S - Set local time Y - Toggle DST calculation Z - Set timezone What is thy bidding, my master?
In the terminal emulator window first press
0 to continously display a second counter
Pressing any key will exit this loop.
Next press
Z to set your time zone (-1 for Germany):
Enter time difference in format HH:MM (+05:00):
Then press
S to set the local system time:
Enter date, use format YYYY/MM/DD (1970/01/01): Enter time, use 24h format HH:MM:SS (01:02:26):
2 to continously display the current local time:
[\] Local time: Thursday, 2008/07/31, 13:55:07 DST UTC+02:00
Try the other menu items.
Known Problems and Limitations
On systems without hardware RTC, the Universal Time is set to Jan. 1st, 1970 after each restart.
When entering date and time, there is no echo.
Suggested Modifications and Enhancements
A more advanced version may regularily query a time server to update the local system time. See logtime sample.
canbus
Complexity Level: Expert
Target Devices: AT90CAN128
Demonstrates the use of the CAN bus and the ATCAN driver on the AT90CAN128 AVR CPU with built-in CAN controller.
This program receives CAN messages and logs them on the serial port via devDebug0. It also continuously broadcasts a CAN frame.
Prerequisites
- AVR Target board with serial port and CAN Bus
- PC with serial port
- Any other CAN hardware to communicate with
Known Problems and Limitations
Currently GCC for 8-bit AVR targets is supported only.
cppdemo
Complexity Level: Basic
Target Devices: All
Demonstrates the usage of Nut/OS with C++.
Prerequisites
- Target board with serial port
- PC with serial port
- Terminal emulator running on the PC
On ARM boards connect to the target's UART0 port, not DBGU.
Usage
When started, it expects an input on the serial port.
C++ Demo on Nut/OS 4.4.0.0 ready. Counter value = 10 Unknown command.Enter + to increment the counter value.
Enter - to decrement the counter value.
Enter r to reset the counter value to zero.
After each valid command the current counter value is displayed.
Counter value = 0 Unknown command.
Known Problems and Limitations
The ImageCraft Compiler supports C only, not C++.
Suggested Modifications and Enhancements
You should carefully think about using C++ with tiny embedded systems. This sample just proofs, that it basically works. Using more complex C++ code on ARM platforms may require modifications of the linker script.
events
Complexity Level: Basic
Target Devices: All
This sample demonstrates the usage of Nut/OS event queues. It further shows how an event queue can be used as a mutual exclusion semaphore.
Two additional threads are started, one with a higher and another one with a lower priority than the main thread.
Prerequisites
- Target board with serial port
- PC with serial port
- Terminal emulator running on the PC
Set the terminal emulator to 115200 Baud, 8 data bits, no parity and 1 stop bit. Disable all handshakes.
On ARM boards DBGU is used for the serial port.
Usage
The results are printed on the debug device. Each thread prints the current action in one of three columns. The first column is used by the highest priority, the last column by the lowest priority thread.
Nut/OS Event Queue Demo High Main Low 01 Request 02 Request 03 Acquired 04 Request 05 Release 06 Acquired 07 Request 08 Timeout 09 Request 10 Timeout 11 Release 12 Acquired 13 Request 14 Request 15 Timeout 16 Request 17 Timeout 18 Release 19 Acquired
Here is a description of the sequence above:
01 Main request the lock.
02 High request the lock.
03 Main acquired the lock, because it was earlier.
04 Low request the lock, which is still acquired by Main.
05 Main released the lock. High and Low are still waiting.
06 High acquired the lock because of higher priority.
07 Main request the lock.
08 Low timed out while waiting for the lock.
09 Low tries to request the lock again.
10 Main timed out while waiting for the lock.
11 High released the lock. Low is still waiting.
12 Low acquired the lock.
13 Main tries to request the lock again.
14 High request the lock also.
15 Main timed out again.
16 Main tries to request the lock again.
17 High timed out while the lock is still with Low.
18 Low released the lock.
19 Main acquired the lock.
ftpd
Complexity Level: Advanced
Target Devices: All
Simple ftp server.
Prerequisites
-
Target board with serial port and Ethernet interface
-
Preformatted MMC, when used with Ethernut 3
-
PC with serial port and Ethernet interface
-
Terminal emulator running on the PC
-
FTP client running on the PC
-
HUB, Switch or Cross Link Cable
Set the terminal emulator to 115200 Baud, 8 data bits, no parity and 1 stop bit. Disable all handshakes.
On ARM boards DBGU is used for the serial output.
This application requires a file system with write access on the target. For Ethernut 2 a RAM file system will be used by default, while the FAT file system on a MultiMedia Card or SD Card is used on Ethernut 3.
Usage
When started, the following output will appear on the serial port.
FTP Server Sample - Nut/OS 4.4.0.0 - AVRGCC Configure eth0...OK IP Addr: 192.168.192.237 IP Mask: 255.255.255.0 IP Gate: 192.168.192.1 Query time from 130.149.17.21...OK Date: 19.09.2007 Time: 15:10:01 Register file system...OK Register FTP root...OK Waiting for an FTP client... Waiting for an FTP client... Waiting for an FTP client...On the PC start the ftp client and connect to the target's IP address. For example, a command line version will be started with
ftp 192.168.192.237Try to send files to and retrieve files from the target.
The following internal FTP commands are supported:
- CWD <pathname> - Change working directory.
- DELE <pathname> - Delete a file.
- LIST | NLST [<pathname>] - Send list of files in a directory.
- [X]MKD <pathname> - Make a directory.
- NOOP - No operation.
- PASS <password> - Check user password.
- PASV - Prepare passive transfer.
- PORT <hostport> - Set data connection.
- [X]PWD - Send name of current working directory.
- QUIT - Terminate session.
- RETR <pathname> - Send a file to the client.
- [X]RMD <pathname> - Remove a directory.
- STOR <pathname> - Receive a file from the client.
- SYST - Send system identifier.
- TYPE <type-code> - Receive transfer mode.
- USER <username> - Check user name.
Known Problems and Limitations
When using a RAM file system, all stored files will be lost after restart.
httpd
Complexity Level: Advanced
Target Devices: All
Simple multithreaded HTTP daemon.
Prerequisites
- Target board with serial port and Ethernet interface
- PC with serial port and Ethernet interface
- Terminal emulator running on the PC
- Web browser running on the PC
- HUB, Switch or Cross Link Cable
Usage
When started, the following output will appear on the serial port.
Nut/OS 4.4.0.0 HTTP Daemon...Configure eth0...OK 192.168.1.237 readyConnect the target using a web browser. For example use the following URL:
http://192.168.1.205Replace the IP address with the one assigned to your target (see output on the serial port).
More information about the Hypertext Transfer Protocol are available at Wikipedia.
Known Problems and Limitations
Due to its code size and the limitations of the demo version, this applications requires a registered compiler, when used with ImageCraft.
Suggested Modifications and Enhancements
Create additional HTML documents in the sample subdirectory. and use the crurom utility to create or update a C source file named urom.c. It is then required to rebuild the application.
Several options had been excluded from the ICCAVR build in order to get it running with the demo compiler. This failed. You may re-enable these options if you own a valid registration:
#define USE_DHCP #define USE_DISCOVERY
By default, the UROM filesystem is used to store the web contents. It is located in the CPU's program memory. For Ethernut 3 the UROM file system used by default may be replaced by the FAT file system. In the source specify:
#define USE_PHATMake sure to insert a pre-formatted MMC or SD Card before starting the target.
inetq
Complexity Level: Advanced
Target Devices: All
Requests an URL from the Internet and transfers the HTML source code to the serial device.
This sample demonstrates DNS query and default route usage.
Prerequisites
- Target board with serial port and Ethernet interface
- PC with serial port
- Terminal emulator running on the PC
- Internet connectivity
Connect the RS232 port of the Ethernut with a free COM port of your PC and run a terminal emulator at 115200 Baud.
Your local Ethernet network must provide Internet access. If your local network does not support DHCP, it may be required to modify the MY_IP, MY_MASK and MY_GATE in the source code.
Usage
When started, the following output appears on the serial port.
InetQuery 1.0 Configuring Ethernet interface 192.168.1.216 ready Connecting 211.48.62.77:80 HTTP/1.1 200 OK
More information about the Hypertext Transfer Protocol are available at Wikipedia.
Known Problems and Limitations
Quite often the application fails during DNS query. Try to run the application again.
isp2
Complexity Level: Guru
Target Devices: ATmega103, ATmega128, ATmega256
This application updates the SISP Adapter firmware, which is totally outdated. Nevertheless, it demonstrates, how to program the FLASH memory of an external AVR chip (AT90S2312).
Prerequisites
- AVR target board with serial port
- PC with serial port
- Terminal emulator running on the PC
- SISP adapter hardware or similar AT90S2313 board
Usage
Connect the SPI programming lines of the external AVR to the SPI port of the target board and hold the external AVR in reset state (nRESET = low). When powering up both, the target board and the external AVR, then the target board will re-program the external AVR.
Known Problems and Limitations
The Configurator does not copy the files Makedefs.isp and Makerules.isp to the new sample tree. Thus, building the application fails with
makefile:55: Makedefs.isp: No such file or directory makefile:70: Makerules.isp: No such file or directory make: *** No rule to make target `Makerules.isp'. Stop.To fix this, manually copy the two files from the source tree to your target specific application directory.
Suggested Modifications and Enhancements
This application is quite hardware specific and probably requires some modifications for programming other devices than the AT90S2313.
logtime
Complexity Level: Expert
Target Devices: All
Shows how to use syslog and SNTP.
Prerequisites
- Target board with serial port and Ethernet interface
- Preformatted MMC, when used with Ethernut 3
- PC with serial port and Ethernet interface
- Terminal emulator running on the PC
- syslog server running on the PC
- Internet connectivity or local SNTP server
Usage
TimeLog 1.0.1 Nut/OS 4.4.0.0 Compiled by GCC Configure network Query time from 130.149.17.21 Initialize syslog <14>Sep 19 15:27:22 ethernut logtime: TimeLog 1.0.1 started on Nut/OS 4.4.0.0 <14>Sep 19 15:27:22 ethernut logtime: IP 192.168.192.237 <14>Sep 19 15:27:23 ethernut logtime: Gate 192.168.192.1 <14>Sep 19 15:27:23 ethernut logtime: Timed 130.149.17.21 <14>Sep 19 15:27:24 ethernut logtime: Syslogd 192.168.192.222 <15>Sep 19 15:27:24 ethernut logtime: 27889 bytes free
More information about the Syslog Protocol and the Network Time Protocol ise available at Wikipedia.
nutpiper
Complexity Level: Expert
Target Devices: All AVR, ARM not tested
Simple Shoutcast Internet Radio.
Prerequisites
- Target board with serial port and Ethernet interface
- Medianut Board attached to the target
- PC with serial port
- Terminal emulator running on the PC
- Internet connectivity
A minimum of 384 kBytes RAM is required to play higher bitrates and to deal with Internet latencies. Running on systems with 32 kBytes is still possible, though. Specially when used with radio servers located in a local network.
Usage
[IDLE]ready [CNCT 212.187.204.62:80][CERR=10060]
Known Problems and Limitations
The list of stations is hard coded.
Suggested Modifications and Enhancements
Update the list of radio stations in config.c.
playmp3
Complexity Level: Advanced
Target Devices: All AVR, ARM not tested
To run this example code, you need to attach the Medianut Board to the Ethernut or use a similar hardware design based on the VS1001K MP3 decoder.
This sample application plays MP3 files from the UROM filesystem. It demonstrates how to use the global segmented buffer and the MP3 decoder driver and can provide a basis for talking equipment, alarm sound output etc.
The UROM filesystem is located in the CPU's flash ROM. No external file storage device is required. Use the crurom utility to create a C source file named urom.c from the MP3 files located in subdirectory sounds.
Prerequisites
- Target board with serial port
- Medianut board attached to the target
- PC with serial port
- Terminal emulator running on the PC
Usage
Done, 30391 bytes free Play UROM:sound1a.mp3: OK [B.RST][B.RD16384][B.CMT2821][P.KICK][B.RD13563][EOF][P.FLUSH][P.RST]
Suggested Modifications and Enhancements
Here's how to call crurom:
crurom -r -ourom.c soundsThe created file will then be compiled and linked to the application code.
portdio
Complexity Level: Advanced
Target Devices: ATmega103, ATmega128, ATmega2561
This a simple TCP server, which allows to monitor and control digital I/O lines.
Usage
The application will not use the serial port.
On the PC start a telnet session
telnet 192.168.1.36 12345replacing 192.168.1.36 with the IP address of your target board. When connected, the following banner will be displayed:
200 Welcome to portdio. Type help to get help.Entering help will show the following response:
400 List of commands follows memory Queries number of RAM bytes free query Query digital i/o status reset# Set output bit 1..4 low set# Set output bit 1..4 high threads Lists all created threads timers Lists all running timers wait Waits for digital i/o change .Entering query will display the current status of PORTD.
210 0FThe application allows to set or reset individual bits of the upper half of PORTD. Enter set1 followed by query.
210 OK 210 1FA second telnet session can be used to wait for any change. Start telnet once more, again replacing 192.168.1.36 with the IP address for your board.
telnet 192.168.1.36 12345In the new telnet window enter wait. As this was the first query since our new connection, the server will respond immediately.
210 1FHowever, when entering wait once again, there will be no response until the port status changes again. To initiate this, return to the first telnet session and enter reset1. Now waiting session will return a response
210 0F
Known Problems and Limitations
On some boards a not initialized serial port may produce garbage output, caused by a floating transmit line. Close the terminal emulator or disconnect the RS-232 plug.
Though, using human readable commands and responses, the command interface had been created for application programs in the first place. Characters typed are intentionally not echoed. However, most telnet clients allow to generate a local echo. Furthermore, line editing is not support. If you mistyped a command, press enter and try again.
pppc
Complexity Level: Guru
Target Devices: AVR (ARM not tested)
PPP client. Similar to the TCP server sample, but uses PPP over RS232.
Prerequisites
- Target board with 1 or 2 serial ports
- PC with 1 or 2 serial ports and PPP server
Usage
The default settings in this sample may be used to connect to a standard RAS server on a Windows PC. When adding a similar modem script, it will also work with a Linux PC nearly out of the box. At least you need to change the PPPUSER and PPPPASS.
CLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENT CLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENTCLIENT
Known Problems and Limitations
Session shutdown is not implemented.
rs232d
Complexity Level: Advanced
Target Devices: All
Simple RS232 server. Use a serial cable to connect the RS232 port of the Ethernut Board with a COM port of a PC. Start a terminal program and a telnet client on the PC. Telnet should connect to the Ethernut Board.
Prerequisites
- Target board with serial port
- PC with serial port
- Terminal emulator running on the PC
Usage
Characters typed in the telnet window will appear in the terminal program window and vice versa. Baudrate is 9600.
Known Problems and Limitations
Serial port settings are hard coded.
Suggested Modifications and Enhancements
The application may be enhanced by a user interface. This could be either done by adding a web server (see httpd sample) or by entering a configuration mode if, for example, three escape characters had been received after reset.
simple
Complexity Level: Basic
Target Devices: All
This sample is the most simple application that could be build with Nut/OS. It doesn't do anything but running in a loop.
Only a minimal Nut/OS kernel with thread, timer and memory management is loaded, occupying less than 4 kBytes of code space and about 50 bytes of RAM.
Usage
Beside compiling, linking and checking the map file for the memory footprint of the bare Nut/OS kernel there isn't much to do here.
It doesn't make sense to load the binary on the target board, except for debugging.
Suggested Modifications and Enhancements
There isn't much to modify. In case you add additional C code, make sure to add the right header files.
tcps
Complexity Level: Advanced
Target Devices: All
Simple TCP server.
Usage
Program Ethernut with tcps.hex and enter
telnet x.x.x.xon a command prompt, replacing x.x.x.x with the IP address of your target board. Enter help for a list of available commands.
TCP Server Sample - Nut/OS 4.4.0.0 - AVRGCC Configure eth0...OK IP: 192.168.1.237 Waiting for a telnet client...
Suggested Modifications and Enhancements
The application can be used as a template for specialized TCP servers, like SMTP.
threads
Complexity Level: Basic
Target Devices: All
This sample demonstrates Nut/OS multithreading.
Usage
When started, the following output will appear at the serial port:
Thread Test MHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHLMHL
Suggested Modifications and Enhancements
Each thread is started with 192 bytes of stack. This is very low and doesn't provide much space for local variables.
timers
Complexity Level: Basic
Target Devices: All
This sample demonstrates the usage of Nut/OS system timer functions.
Usage
When started, the following output will appear at the serial port:
******************************************************************************* Timer sample running on 14.7453 MHz CPU Start periodic t1 Start peņiodic t2 Start periodic t3 Start periodic t4 Sleeping 3 seconds
Suggested Modifications and Enhancements
This is a good candidate to demonstrates Nut/OS debug output. You need the debug version of the Nut/OS libraries. To create them, you must enable the RTOS Kernel - OS Debug option in the Configurator. Then use the Build Menu in the Configurator to generate the build tree again and build Nut/OS.
Note, that the debug version consumes much more memory than the original version. If in doubt, check the map file.
uart
Complexity Level: Basic
Target Devices: All
This sample demonstrates basic RS-232 I/O using standard C.
Prerequisites
Target board with serial port
PC with serial port
Terminal emulator running on the PC
On ARM boards connect to the UART0 port, not DBGU.
Usage
Nut/OS UART Sample Press any key...1 Enter your name: Hello egnite!
Suggested Modifications and Enhancements
Enabling floating point will activate output of floating point values.
Nut/OS UART Sample Press any key... Enter your name: Hello Niels! FP 1.012500 Enter your name: Hello stranger! FP 2.025000 Enter your name: Hello stranger! FP 3.037500
More information about Nut/OS floating point support is available here.