A Appendix

Sample Code

Included in the ‘/opt/samples/ directory are several files that show just some of the features available with the dimmPCI platform. The first sample application is a simple hello world pro- gram. Its sole purpose is to display a line of text that says “Hello World!” Basically it verifies that your compiler tools and development environment are functioning properly.

//hello.c

//A very simple program to demonstrate that the development

//environment is properly configured

#include <stdio.h> void main() {

printf(“Hello World!\n”);

}

The next sample application demonstrates how file I/O works in a GCC/Linux environment. This program will create a file and write “Hello World!” to it. If you do not have the JFFS functioning you can alternately create a file in the /var directory, since that is also writable.

//fileio.c

//A program to verify that the flash filesystem works

//properly.

//Upon completion a new file will be created /usr/hello_world

//that contains the text “Hello World!”

#include <stdio.h> void main ()

{

FILE *file_handle;

// create and open the file

file_handle = fopen (“/usr/hello_world”, “w+”);

//check if an error occured if (file_handle == NULL) {

www.amctechcorp.com

49

Page 49
Image 49
AMC 68VZ328 software manual Appendix, Sample Code