phyFLEX
®
-i.MX 6
22
PHYTEC Messtechnik GmbH 2015 L-781e_7
3.1.3
Modifying 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 phyFLEX-i.MX6, 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
PHYTEC!
(serial)\n"
},
write_tty(buf,
sizeof
(buf)
‐
1),
In the next screenshot you can see the complete program.
Содержание phyFLEX-i.MX 6
Страница 85: ...79...