4 #include <sys/select.h>
9 int i, fd, rdsz, count;
10 unsigned char buf[4096];
12 if((fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY)) == -1) {
13 perror("failed to open serial port /dev/ttyAMA0");
21 while((rdsz = read(fd, buf, sizeof buf)) > 0) {
22 for(i=0; i<rdsz; i++) {
23 printf("%04d: %02x\n", count, (unsigned int)buf[i]);