#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>

#define MODEMDEVICE "/dev/ttyUSB0"

main()
{
  int fd,c;
  char buf[8192];

 fd = open(MODEMDEVICE, O_RDWR ); 
 if (fd <0) {perror(MODEMDEVICE); exit(-1); }

 memset (buf, 0, 8192);

 buf[0x00] = 0x1B; // Init Display
 buf[0x01] = 0x40;
 write (fd, buf, 2);

 buf[0x00] = 0x0C; // Clear Display
 write (fd, buf, 1);

 buf[0x00] = 0x1f; // Fixed
 buf[0x01] = 0x28; // Fixed
 buf[0x02] = 0x66; // Fixed
 buf[0x03] = 0x11; // Fixed
 buf[0x04] = 64;  // Size in 1 dot
 buf[0x05] = 0x00;
 buf[0x06] = 0x02; // Size in 8 dots
 buf[0x07] = 0x00;
 buf[0x08] = 0x01; // Fixed

 // fill full display with data
 for (c = 0; c < 128*4; c++) {
    buf[0x09+c] = c;
 }
 
 write (fd, buf, 9+(64*2));

 close (fd);
}
