![Phytec Linux-Kit phyCARD-M Quick Start Instructions Download Page 72](http://html1.mh-extra.com/html/phytec/linux-kit-phycard-m/linux-kit-phycard-m_quick-start-instructions_1554142072.webp)
phyCARD-M
Quick Start Instructions
68
© 2010 PHYTEC Messtechnik GmbH L-746e_1
3.4
Changing the Demo Application
Now we will extend the
myHelloWorld
application. The extended
myHelloWorld
application will write an output to the first serial interface as
well as to the standard output.
•
Open Eclipse if it is not opened yet.
•
Double-click
HelloWorld.c
in the
myHelloWorld
project.
•
First include the following two additional header files:
#include <unistd.h>
#include <fcntl.h>
•
Then add the function
write_tty(),
which writes
n
bytes to the first serial
interface (which, on the phyCARD-M, is connected to the system
console
/dev/console
):
void write_tty (char *buffer, int count) {
int out;
out = open ("/dev/console", O_RDWR);
write (out, buffer, count);
close (out);
}
•
Enter the following two lines in the
main()
function to declare the buffer
and call the
write_tty()
function.
char buf [] = { "Welcome to the World of the
phyCARD-M! (serial)\n" };
write_tty (buf, sizeof (buf) - 1);
In the next screenshot you can see the complete program.