blob: 34b9bad45debbf762b20e3ddae7504d1c9c01145 [file] [log] [blame]
Gordon Henderson25e4ec52012-12-06 21:49:41 +00001
2/*
3 * serialRead.c:
4 * Example program to read bytes from the Serial line
5 *
6 */
7
8#include <stdio.h>
9#include <string.h>
10#include <errno.h>
11
12#include <wiringSerial.h>
13
14int main ()
15{
16 int fd ;
17
18 if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0)
19 {
20 fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
21 return 1 ;
22 }
23
24// Loop, getting and printing characters
25
26 for (;;)
27 {
28 putchar (serialGetchar (fd)) ;
29 fflush (stdout) ;
30 }
31}