Program Examples

 

"example/example.c" contains extensive examples of programming tips in the uClinux environments. Build the program and transfer it to the target device as /usr/example. To run the example:

*          login with Telnet console

*          cd /usr

*          ./example 0

*          ./example 1

*          ./example ¡K.

 

 

Example 00 Hello World

 

The simple "Hello World" program. Print messages to console.

 

Example 01 Debugging Outputs

 

Print "Hello World" to debugging outputs (/dev/ttyS0, /dev/vdd0, /var/run/syslog.log)

 

Example 02 LED Control

 

Set LED1, LED2 on and off.

 

Example 03 Serial Port

 

Open, read, write, close serial port.

 

Example 04 Interval Timer

 

Linux interval timer function setitimer().

 

Example 05 TCP Echo Server

 

TCP server socket.

 

Example 06 TCP Client

 

Use TCP client socket to read a web page from Internet.

 

Example 07 Multi-thread

 

Linux multi-thread model.

 

Example 08 Process Pipe

 

Use popen() to access shell "ls -l /" output.

 

Example 09, 10 Shared Memory

 

Example 09 - set contents of shared memory

Example 10 - read contents of shared memory which set by other process.

 

First run "./example 9 &" as a background process, then run "./example 10" to see the result.

 

Example 11 External Bus Access

 

Access external bus for embedded controller applications.

 

 

Example 12 Run External Process by Shell

 

Use system() function to run an external process.

 

 

Example 13 Run External Process by vfork(), execlp()

 

Use vfork() and execlp() functions to run an external process.