#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <termios.h>

int main()
{
  fd_set set;
  struct timeval tv;
  struct termios t, t_orig;
  unsigned char c;

  memset(&tv, 0, sizeof(tv));

  tcgetattr(0, &t);
  memcpy(&t_orig, &t, sizeof(t_orig));
  cfmakeraw(&t);
  tcsetattr(0, TCSANOW, &t);

  while (read(0, &c, 1) > 0) {
    if (c == 'x')
      break;
    printf("0x%x\r\n", c);
  }

  tcsetattr(0, TCSANOW, &t_orig);

  return 0;
}
