SQUARE WAVE GENERATION
    in Non Real-Time Linux

      //
      // sqr.c
      //

      #include <stdio.h>
      #include <fcntl.h>
      #include <time.h>
      #include "lpv.h"

      void main(){

      int fd;
      short number = 0x1111;
      unsigned char buffer;

      struct timespec tiempo;

      tiempo.tv_sec = 0;
      tiempo.tv_nsec = 1 * 1000000;

      fd = open("/dev/lpv",O_RDWR); [ See NOTE ]
      if (fd<0) {
      perror("Could not open");
      exit(-1);
      }

      while(1){

      write(fd,"1",1);
      nanosleep(&tiempo,NULL);
      write(fd,"2",1);
      nanosleep(&tiempo,NULL);

      }

      close(fd);

      }

      [ NOTE ]
      /dev/lpv is a very simple parallel port driver.
      See code.