In the following chapters you find a small C-Program for auto configure the TA-Omega. There is also the Makefile the startscript and the inputscript which is read from the C-program omeag.c.
Behind the frontpanel you find two Dip-switches. On the left side there is a switch numbered from 1 to 12 and on the right side there is a switch numbered from 1 to 8. Here are you find the settings for this two Dip-Switches in Oebb-Mode:
Switch 1-12 (left)
1-4 = ON
5,6 = OFF
7,8 = ON
9 = OFF
10-12 = ON
summary: ON = 1,2,3,4,7,8,10,11,12
OFF = 5,6,9
Switch 1-8 (right)
1-6 = ON
7 = OFF
8 = ON
summary: ON = 1,2,3,4,5,6,8
OFF = 7
/*
* omega.c
*
* input parser for PAD-configuration scripts
* ==========================================
*
#
# Copyright (C) 2001 Heimo Schön <heimo.schoen@gmx.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
int inputpid=0;
static int source_fh = 0; // Filehandle
static int input_fh = 0; // Filehandle
static int out_fh = 0; // Filehandle
static int log_fh = 0; // Filehandle
unsigned char stty_buffer[10000];
unsigned char out_buffer[10000];
unsigned char source_buffer[10000];
void p_usage()
{
fprintf(stderr, " \n");
fprintf(stderr, " omega <command-file> <device>\n");
fprintf(stderr, " \n");
fprintf(stderr, " <command-file> filename of a file with\n");
fprintf(stderr, " PAD-parameters; one command\n");
fprintf(stderr, " in each line\n");
fprintf(stderr, " \n");
fprintf(stderr, " <device> the serial device where omega can\n");
fprintf(stderr, " find the PAD\n");
fprintf(stderr, " \n");
fprintf(stderr, " example: omega test.cmd /dev/ttyW7\n");
fprintf(stderr, " \n");
}
void startinput()
{
unsigned char in_buffer[10000];
int rece = 0;
in_buffer[0] = 0;
if ( ( inputpid = fork() ) == 0 ) {
while (1) {
if ((rece = read(input_fh, in_buffer, 1024)) > 0) {
in_buffer[rece] = 0;
if (log_fh > 0)
write(log_fh, in_buffer, strlen(in_buffer));
fprintf(stdout, "%s", in_buffer);
// Flush the output that user can see something ;-)
fflush(stdout);
fflush(stderr);
in_buffer[0] = 0;
}
}
}
fprintf(stdout, "reader forked with pid %d\n", inputpid);
}
void p_io()
{
int rece = 0;
char command[10000];
int com_p = 0; // command-pointer
char sobuf[1024];
char sebuf[1024];
setvbuf(stdout, sobuf, _IONBF, 0);
setvbuf(stderr, sebuf, _IONBF, 0);
while ( (rece = read(source_fh, source_buffer, 1)) == 1) {
if (source_buffer[0] == '\n') {
command[com_p] = 0;
if (command[0] != '#') {
if ( ! strncmp(command, "sleep", 5)) {
fprintf(stdout, "sleeping %d seconds ...\n", atoi([5]));
// Flush the output that user can see something ;-)
fflush(stdout);
fflush(stderr);
sleep ( atoi([5]) );
} else {
sprintf(out_buffer, "%s\r",command);
write(out_fh, out_buffer, strlen(out_buffer));
sleep(1);
}
} else {
command[com_p] = '\n';
command[com_p+1] = 0;
if (log_fh > 0)
write(log_fh, command, strlen(command));
fprintf(stdout, "%s", command);
}
// reset Command-pointer
com_p = 0;
// Flush the output that user can see something ;-)
fflush(stdout);
fflush(stderr);
} else {
command[com_p] = source_buffer[0];
com_p++;
}
}
}
// -----------------------------------------------------------------------
int main (int argc, char *argv[])
{
if (argc >= 3) {
if (argc == 4)
log_fh = open (argv[3], O_WRONLY);
source_fh = open (argv[1], O_RDONLY);
out_fh = open (argv[2], O_WRONLY);
input_fh = open (argv[2], O_RDONLY);
sprintf(stty_buffer,
"stty 9600 -echo raw < %s ",
argv[2]);
fprintf(stdout,"%s\n",stty_buffer);
system(stty_buffer);
} else
out_fh = 0;
if (out_fh > 0) {
startinput(); // fork the reader process
p_io(); // the command process
kill(inputpid, SIGKILL);
} else {
p_usage();
}
}
The following listing should be copied into a file named Makefile. Afterwards you can type make clean ; make all ; make strip
#
# Makefile
#
# Makefile for TA-OMEGA Configuration Program
#
# Copyright (C) 2001 Heimo Schön <heimo.schoen@gmx.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
LDOPTIONS = -pedantic -Wall -g -DYY_SKIP_YYWRAP
CP = cp
STRIP = strip
# Objects and Sources:
OBJS = omega.o
SRCS = omega.c
all: omega
omega: $(OBJS) $(DEPLIBS)
$(RM) $@
$(CC) -o $@ $(LDENTRY) $(OBJS) $(LDOPTIONS) $(LIBS) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
omega.stripped: omega
$(CP) $< $@
$(STRIP) $@
strip:: omega.stripped
clean::
$(RM) omega *.o *~ omega.stripped
depend::
@if [ -n "$(SRCS)" ] ; then set -x;\
$(DEPEND) $(DEPENDFLAGS) $(SRCS) ;\
fi
tags::
etags *.[ch]
Copy the following lines into a file named makeomega. Dont´t forget to chmod the script: chmod a+x makeomega
#! /bin/bash
#
# makeomega - configuring a TA-OMEGA-PAD
#
# Copyright (C) 2001 Heimo Schön <heimo.schoen@gmx.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
if [ $1 ] ; then
if [ -e /dev/$1 ] ; then
echo Send OMEGA config to device /dev/$1
export DATDEV=/dev/$1
omega omega.cmd $DATDEV | tee omega.log
else
echo Could not find device /dev/$1
echo " example : $0 ttyS0"
fi;
fi;
Here you can find the complete Parameterscript for configuring the TA-Omega. Check if you didn´t delete blank lines in the following file.
#
# commandfile for configuring a TA-OMEGA for OeBB Applications
#
# With best regards to Mr. Mirlach at www.tdt.de
#
#
#
# Grundzustand herstellen
b s md:a
# Warmstart
w s md:a
sleep 5
#
# ?
s p md:8 ltc:3
# ?
s p md:9,10 prof:0
#
# ?
s c md:8 ch:1 md:9 ch:1 ACC:NO
s c md:9 ch:1 md:8 ch:1 ACC:NO
s c md:8 ch:2 md:10 ch:1 ACC:NO
s c md:10 ch:1 md:8 ch:2 ACC:NO
#
# neu vom 09.02.2001
s prof md:9,10 prof:0 1:16
# FDZR needs 19200 baud
s p md:9,10 SP:19200
#
# abschliessend noch einen Warmstart
w s md:a
sleep 5
#
#
# Action done - have a nice day
#
# =========================================