aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/felix.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-10-18 10:23:05 +0200
committerThomas White <taw@physics.org>2017-10-18 10:23:05 +0200
commit7f708ef255f068ef9e91941ac3a0a3d0e04e5ff8 (patch)
treee9298ce158cf2688b7a3af5892aa4f2ea7d379ec /libcrystfel/src/felix.c
parentf15f4b792826c917f258c2e6195f6994d3450754 (diff)
Add probe functions to indexing methods
Diffstat (limited to 'libcrystfel/src/felix.c')
-rw-r--r--libcrystfel/src/felix.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/libcrystfel/src/felix.c b/libcrystfel/src/felix.c
index 973b0513..5036ff74 100644
--- a/libcrystfel/src/felix.c
+++ b/libcrystfel/src/felix.c
@@ -716,3 +716,50 @@ void felix_cleanup(IndexingPrivate *pp)
free(p->readhkl_file);
free(p);
}
+
+
+const char *felix_probe(UnitCell *cell)
+{
+ pid_t pid;
+ int pty;
+ int status;
+ FILE *fh;
+ char line[1024];
+ int ok = 0;
+
+ if ( !cell_has_parameters(cell) ) {
+ return NULL;
+ }
+
+ pid = forkpty(&pty, NULL, NULL, NULL);
+ if ( pid == -1 ) {
+ return NULL;
+ }
+ if ( pid == 0 ) {
+
+ /* Child process: invoke DirAx */
+ struct termios t;
+
+ /* Turn echo off */
+ tcgetattr(STDIN_FILENO, &t);
+ t.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
+ tcsetattr(STDIN_FILENO, TCSANOW, &t);
+
+ execlp("Felix", "Felix", (char *)NULL);
+ _exit(1);
+
+ }
+
+ fh = fdopen(pty, "r");
+ fgets(line, 1024, fh);
+ if ( strncmp(line, "Felix", 5) == 0 ) {
+ ok = 1;
+ }
+
+ fclose(fh);
+ close(pty);
+ waitpid(pid, &status, 0);
+
+ if ( ok ) return "felix";
+ return NULL;
+}