忘れないように貼っておく.

あー,stdio.hなんて使ったの何ヶ月ぶりだろう.
おー,termios.hなんて使ったの何年ぶりだろう.

/* gscenner.c
  * Use like: ./gscanner /dev/cu.usbserial0
  */
#include <stdio.h>
#include <fcntl.h>
#include <termios.h>

int
main(int argc, char** argv)
{
  int fd;
  struct termios options;
  unsigned char c;
  unsigned char cmd_start = 0xca;
  int i;
  int er;

  fd = open(argv[1], O_RDWR);
  er = fcntl(fd, F_SETFL, 0);
  er = tcgetattr(fd, &options);
  cfmakeraw(&options);
  er = cfsetispeed(&options, B38400);
  er = cfsetospeed(&options, B38400);
  options.c_cflag |= (CS8) | (CLOCAL);
  options.c_cflag &= ~((CRTSCTS) | (PARENB) | (CSTOPB));
  er = tcsetattr(fd, TCSAFLUSH, &options);


  er = write(fd, &cmd_start, 1);
  printf("--\r");
  fflush(stdout);
  while(1) {
    do {
      er = read(fd, &c, 1);
//		printf("%02x\r", c);
//		fflush(stdout);
    } while (c != 0xff);
    for (i = 0; i < 5; i++) {
      er = read(fd, &c, 1);
      printf("%02x", c);
    }
    printf("\r");
    fflush(stdout);
  }

  return -1;
}

エラーチェック? なにそれ知らない.;-(