/* C9525 IS A FUCKING BAD INSTRUMENT - disgrace for Hamamatsu */ #include /* Standard input/output definitions */ #include /* Standard libraries definitions */ #include /* String function definitions */ #include /* UNIX standard function definitions */ #include /* File control definitions */ #include /* Error number definitions */ #include /* POSIX terminal control definitions */ #define Wsize 100 /* The longest string has 27 characters */ int fd; int InitPort(void) { struct termios options; fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { fputs("Unable to open port\n", stdout); return 0; } else { tcgetattr(fd, &options); cfsetispeed(&options, B9600); /* Set the input baud rate */ cfsetospeed(&options, B9600); /* Set the output baud rate */ options.c_cflag |= (CLOCAL | CREAD); /* Enable receiver, set local */ options.c_cflag &= ~PARENB; /* Clear parity enable */ options.c_cflag &= ~CSTOPB; /* Remove 2nd stop bit */ options.c_cflag &= ~CSIZE; /* Clear data length */ options.c_cflag |= CS8; /* Character size = 8 bits */ options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* RAW input */ options.c_oflag &= ~OPOST; /* RAW output */ options.c_cflag &= ~CRTSCTS; /* Disable hardware flow control */ tcsetattr(fd, TCSAFLUSH, &options); /* clear buffers */ tcsetattr(fd, TCSANOW, &options); /* set attributes immediately */ return 1; } } int WritePort(char Command[], int Length) { char *BufPtr; int i; BufPtr = Command; for (i=0; i Vnew) Sign = 1; if (Vset < Vnew) Sign = -1; printf("initial setting %d, steps %d, speed %d\n", Vnew, Sign*Step, Ramp); for (k=0; k