APD-2 + ÖBB X25 HOWTO

Heimo Schön <heimo.schoen@gmx.at> Version 0.7 , 14. October 1999

Setup a RAD PAD APD-2 to work in a ÖBB X25 environment

1 Overview

1.1 About this HOWTO

This document describes how to use the PAD built by RAD. We use the APD-2 in a special configuration for the Austrian Federal Railways ÖBB. The ÖBB X25 protocol is described in the "ÖBB X25 Pflichtenheft". This protocol specifies the Layer 4 to 7 for vital and not-vital comunication between railway-station equipment (e. q. interlocking, etc.). The ÖBB X25 protocol specification uses the CCITT X.25 / X.21 communication and uses PVC 1 for channel A and PVC 2 for channel B transmission.

The two-channel transmission in channel A and channel B is used for raising the safety of the connection. In channel B the data is transmitted inverted. For more details cunsult the "ÖBB X25 Pflichtenheft".

Special thanks to Ing. Johann Berger <j.berger@online.edvg.co.at> for the help on getting the first APD-2 and a complete X.25 testconfiguration with Datus-PADs and X.25 Modems (Nokia SB64 and Siemens DAG64 types).

For details to the ÖBB X25 specification you should contact Johann Berger.

Thanks to Michael Smutka <michael.smutka@teleweb.at> for his ideas and reviewing this document and the code.

If you have any suggestions to this document, than feel free to contact me:

• Heimo Schön <heimo.schoen@gmx.at>

• http://fly.to/heimo.schoen

Have a lot of fun with this easy to use, easy to configure and very small X.25 PAD APD-2 from RAD.

1.2 Test configuration

For testing the configuration in this document I used the following testequipment:

                 +-------+ +-------+
                 |       |-|       |
      ch. A -----|       |V|MIC-24T|     +-----+
                 | APD-2 |2| /21C  |-----|Modem|~~~~~~~~~~~~~~~+
      ch. B -----|       |4|       |     +-----+               |
                 |       |-|       |                           |
                 +-------+ +-------+               2-wire      |
                                                   longdistance|
                 +-------------+                   connection  |
                 |             |                               |
      ch. A -----|             |         +-----+               |
                 | Datus-PAD   |---------|Modem|~~~~~~~~~~~~~~~+

   ch. B -----|             |         +-----+
              |             |
              +-------------+
         APD-2 ........ PAD with two V.24(8pin-RJ45)/X.28 connectors
                        and one V.24(25pin-SUB-D)/X.25 connector
                        manufactored: RAD
         MIC-24T/21C .. Converter V.24(25pin-SUB-D) to
                        X.21(15pin-SUB-D) connector
                        manufactored: RAD
         Modem ........ X.21 Modem with 64 kBit/sec
                        e.q.: Nokia SB 64k
                              or
                              Siemens DAG 64
         Datus-PAD .... 5820 with 2 V.24 connectors and 1 X.21
                        connector

On channel A and B on both ends of the testconfiguration (Datus-PAD and APD-2) we connected the Testrechner TR application, which you also can find on my homepage. You may use any other applications with V.24 connection with 19.200 baud, no parity, 8 Bit, 1 Stopbit.

1.3 Version History

• 0.1 01 Oct 1999 Cable Pin Diagram

• 0.2 02 Oct 1999 First Pictures

• 0.3 03 Oct 1999 Comparison Datus-Parameter with RAD-Parameter and description of how configuring the RAD-PAD

• 0.4 07 Oct 1999 description of the c-programm and the parameter-input-script rad.cmd

• 0.5 11 Oct 1999 Textfile to SGML

• 0.6 12 Oct 1999 Minor text changes and release

• 0.7 14 Oct 1999 Changes, corrections and ideas from Michael Smutka. Candidat for version 1.0

2 HW connection to your RAD-PAD

2.1 Cable for RAD-PAD

Build a cable with the following pinout:

         RJ 45 connector             9-pin  D-SUB
              +----+                 female  male
   CTS        |  8 |------------------- 8      4
   Sig.Gnd. +-+  7 |------------------- 5      5
   DTR      |    6 |------------------- 4      8
   TxD      |    5 |------------------- 3      2
   DCD      |    4 |------------------- 1      7
   RxD      |    3 |------------------- 2      3
   RTS      +-+  2 |------------------- 7      1

2. HW connection to your RAD-PAD 3

Chass.Gnd. |  1 |-------------------- cover
+----+

RJ 45 connector              25-pin D-SUB
+----+                  female  male
CTS        |  8 |------------------- 5      20
Sig.Gnd. +-+  7 |------------------- 7       7
DTR      |    6 |------------------- 20      5
TxD      |    5 |------------------- 2       3
DCD      |    4 |------------------- 8       4
RxD      |    3 |------------------- 3       2
RTS      +-+  2 |------------------- 4       8
Chass.Gnd. |  1 |------------------- 1       1
+----+
(RJ45 connector view from frontside - cable goes into the paper)

2.2 Description of the RJ45 Pins

8  CTS          Clear to Send
A positive level vorm PAD indicates that
the terminal is allowed to send data.
(only for Hardware-Flow-Control; isn´ t
in use in this configuration)
7  Sig.Gnd.     Signal Ground
Common signal and DC power supply ground
6  DTR          Data Terminal Ready
Used for end-to-end flow control.
positive level from DTE, when it is ready
(not in use in this configuration)
5  TxD          Transmit Data (this is the PADs input!!!)
here the PAD receives the transmitted
data from the other source
4  DCD          Data Carrier Detect
Posoitive level from PAD whe the local
and remote system are synchronized
3  RxD          Receive Data (this is the PADs output!!!)
The other system receives on this pin
the data from the PAD
2  RTS          Received by PAD from DTE, controls DCD at
remote side.
1  Chass.Gnd.   Protective Chassis Ground
(may be isolated from signal, or connected
to it)

Connect the cable for example to CH2 of the RAD-PAD and on the other hand e.g. to ttyS1 (COM2) of your Linux box.

3 SW connection to your RAD-PAD

3.1 Terminalemulation minicom

Start minicom on your linuxbox. You can type minicom com2, when you create the following minicom configuration file:

     # file: /etc/minicrc.com2
     #
     # this minicom configuration file is used to make
     # a connection to a RAD-PAD via ttyS1 (COM2)
     #
     # Machine-generated file - use "minicom -s" to change parameters.
     #
     pr port             /dev/ttyS1
     pu baudrate         9600
     pu rtscts           No

4 Entering into your RAD-PAD

4.1 main menu

After you connected your cable as described above, and you started your minicom, you should receive a prompt from your RAD-PAD. It should be a single "*".

If you didn´ t receive this prompt, you should press CTRL+P to exit the transfer-mode and obtain the PAD-prompt. Now you should type

     CLR<CR> to disconnect the call.

Now verify that the PAD is free by typing the command

     STAT<CR>

When you can see the PAD-Prompts * sign you can connect to the main-menue by typing

     CON 00<CR>

or

     C 0<CR>

Now you receive the following screen:

     ----------------------------------------------------------------------------------
           MAIN MENU
          -----------

4. Entering into your RAD-PAD 5

   1) CONFIGURE
   2) SYSTEM CONTROL
   3) DIAGNOSTICS
   4) STATUS and STATISTICS
   5) LOGOUT
    Select:
----------------------------------------------------------------------------------

4.2 system status

You can few your PADs status by choosing 4:

----------------------------------------------------------------------------------
                              SYSTEM  STATUS
                    --------------------------------------
Device ID: 0
Device MAC ADDRESS: 0020 D209 1DFE
RAM Size:           512  KByte              Free DATA buffers:      270
NOVRAM Size:         8   KByte              MIN DATA buffers in pool:  263
NOVRAM Utilization: 8  %
Par\Lnk|  1  |  2  |  3  |
-------|-----|-----|-----|
PROTOC |X.25 |X.28 |X.28 |
Sync   | NO  |     |     |
S loss |  0  |     |     |
I Pkts |  0  |  4  |  0  |
--------------------------
                      MAIN  STATUS and STATISTIC MENU
 1 - 3) Sync Links  A) Async Channels  P) Protocols  R) Refresh  <CR>) Exit
 Select option:
----------------------------------------------------------------------------------

4.3 link 1 status

For example the link 1 should bring:

----------------------------------------------------------------------------------
 DEVICE ID: 0
                   X.25 Link 1 Statistics
                  ------------------------------------------
 Protocol: X.25          Sync Status: NOT SYNC      Transmission Mode: DTE
 DRIVER (L1):                          X.25  (L3):
-------------     Tx         Rx      -------------        Tx         Rx
  Frames          0          0             I Packets      0          0
  Error           0          0             Clear          0          0
  R_FRAMEs in pool     53                  Reset          0          0

4. Entering into your RAD-PAD 6

  Idle: OFF   CTS: ON                      Restart        0          0
                                           Packet size           128
 LAPB (L2):                                LGN                    0
-----------       Tx         Rx
  I Frames        0          0             LCN Type | LCNs  | Act | I Packets
  RR              0          0             ---------|-------|-----|----------
  RNR             0          0             Incoming | 1 - 5 |  0  |    0
  REJ             0          0             Two way  | 6 -10 |  0  |    0
  FRMR            0          0             Outgoing |11 -15 |  0  |    0
  N(S) errors     0
  State       DISCONNECTED PHASE
  Frame size            4108
  PRESS:  R - Refresh,         <CR> - EXIT:
----------------------------------------------------------------------------------

4.4 link 2 status

and link 2 should look like:

----------------------------------------------------------------------------------
 DEVICE ID: 0
                     Asynchronous    Channels   Status
-----------------------
 Param \ Chan |   2   |
--------------|-------|
Status        |  ENG  |
--------------|-------|
No of act LCNs|   1   |
I Packets     |  19   |
--------------|-------|
Autocall ID   | NONE  |
--------------|-------|
HW signal     |Unused |
--------------|-------|
BUFs to Netwrk|   1   |
BUFs to User  |   0   |
--------------|-------|
Tx Xoff       |  NO   |
Rx Xoff       |  NO   |
-----------------------
Enter Channel Number to Zoom,  R - Refresh,  NN:NN - Range,  <Q> - QUIT:
----------------------------------------------------------------------------------

4.5 device status

and on device 0 the channel 0 you should see this:

5. Configuration for OeBB PAD Mode 7

                                              DEVICE ID: 0
                          CHANNEL  0    SESSION  1
                        ----------------------------
  Sub address : 0    ,  0             Profile No : 1     Transmit Xoff  : NO
                                      Page wait : OFF    Received Xoff  : NO
ses| LCN | Connected to  | I Packets  HW sig : Unused    BUFs to Network: 0
---|-----|---------------|----------  Type : SVC         BUFs to User   : 0
> 1|LOCAL|               |     0                         BUFs Outstand  : 0
  2|    N O T   A C T I V E                        Autocall ID : 0
  3|    N O T   A C T I V E                        State : DATA TRANSFER
  4|    N O T   A C T I V E                        Connection status : ENG

                      Current profile parameters :
1)rec chr:1     8)dis_out:0    15)edit   :1     22)p_wait :0    106)ch_brk :0
2)echo   :1     9)cr_pad :0    16)ch_del :127  100)bit/ch :3    107)ch_supp:0
3)d forw :2    10)l_fold :0    17)l_del  :24   101)dv_part:0    108)ch_subs:0
4)idl_t  :0    11)speed  :14   18)l_dis  :18   102)stp_bit:0    109)FF_pad :0
5)dv_flw :2    12)pad_flw:1    19)e_ser_s:2    103)s_flow :0    110)inactiv:0
6)s_sig  :5    13)autolf :4    20)echo_m :0    104)cnt_for:0    111)options:0
7)brk    :4    14)lf_pad :0    21)part_tr:3    105)esc_del:0    112)clr_tim:0
  PRESS:  1..4 - Session No,    R - Refresh,    ? - Help,    <CR> - EXIT:
----------------------------------------------------------------------------------

5 Configuration for OeBB PAD Mode

5.1 Warning

In this chapter I want to show all parameters which have to be changed. But be carefully, the chapters follow the APD-2 Handbook and not the way how the configuration works really. The reason is, that if you would change the asynchronous link first, you would loose the connection to the configuration menue. Therefore you should use the automatic configuration tool I wrote, or you should read carefully what the automatic configuration program does really.

5.2 start configuration

Enter the configuration menue with typing

     1<CR>

You should receive the following view:

----------------------------------------------------------------------------------
      Configuration menu
     --------------------
   1) Channel
   2) Profile
   3) Link

 4) System parameters
 5) PVC
 6) Call ID
 7) NUI
 8) Alias
 9) Routing table
10) Funnel
11) X.32
12) Management
13) X.25 Multicast
14) IP Routing
15) ISDN configuration
CR) Exit
  Select:
----------------------------------------------------------------------------------

In the following chapters 4.1 to 4.15 I try to describe, which settings you need for a proper OeBB X25/X.25/X.21 Connection.

5.3 Channel configuration

Press

  1<CR>

to enter the channel configuration

Press

  5<CR>

to check channel types. You should see the following:

----------------------------------------------------------------------------------
Chan |  2  |  3  |
-----|-----|-----|
Prot |X.28 |X.28 |
----------------------------------------------------------------------------------

Change the channel types of link 2 and 3 if not X.28 Protocol set. Afterwards go back to configuration menue by pressing and change to menue update channel by typing

   3<CR>

and enter channelnumber

   2<CR>

----------------------------------------------------------------------------------
   Channel   2  configuration
  -----------------------------
1) Profile number ................. [  2  ] <===
2) Outgoing call profile number ... [  0  ]
3) Incoming call profile number ... [  0  ]
4) Remote profile number .......... [  0  ]
5) Autocall ID  ................... [  0  ]
6) Alternate autocall ID .......... [  0  ]
7) Autocall retries ............... [ 10  ]
8) Autocall retry interval ........ [  5  ]
9) Call alias ..................... [  0  ]
10) Sub address 1 ...................[  2  ]
11) Sub address 2 ...................[  0  ]
12) NUI Group ID ................... [  0  ]
13) Clear timer .................... [  0  ]
14) Options ........................ [128  ] <===
S) Save
CR) Exit
----------------------------------------------------------------------------------

Change the parameters to the above settings.

Attention: Don´ t foreget to save the changes with

  S<CR> !!!

After changing the parameters, duplicate line 2 to line 3 by typing

----------------------------------------------------------------------------------
     1<CR>           duplicate channel
     2<CR>           source channel
     3:3<CR>         destination channel range
----------------------------------------------------------------------------------

This commands duplicate channel 2 to the range of channels 3 to channel 3.

5.4 Profile configuration

Enter the profile configuration for profile 1 with typing

 2<CR>

and

 3<CR>

in the configuration menue. You get the following view:

----------------------------------------------------------------------------------
     Profile 1    configuration
    -----------------------------
1) Recall char ........... [0    ]        20) Echomask ............ [0    ]
2) Echo .................. [0    ]        21) Parity treat ........ [0    ]
3) Data forward char ..... [0    ]        22) Page wait ........... [0    ]
4) Idle timer............. [2    ] <===  100) Bits/char ........... [3    ]
5) Device flow control ... [0    ] <===  101) Dv_parity ........... [0    ]
6) Service signal ........ [0    ]       102) Stop bits ........... [0    ]
7) Break ................. [0    ] <===  103) Special flow ........ [0    ]
8) Discard output ........ [0    ]       104) Count fwd ........... [0    ]
9) CR padding ............ [0    ]       105) Esc_delay ........... [0    ]
10) Line folding .......... [0    ]       106) Character break ..... [0    ]
11) Speed ................. [15   ] <===  107) Character suppress .. [0    ]
12) Pad flow control ...... [0    ] <===  108) Character substitute  [0    ]
13) Linefeed insertion .... [0    ]       109) Form feed padding ... [0    ]
14) Linefeed padding ...... [0    ]       110) Inactivity .......... [0    ]
15) Editing ............... [0    ]       111) Options ............. [0    ]
16) Character delete ...... [0    ]       112) Clr Timer ........... [0    ]
17) Line delete ........... [0    ]       113) Subaddress in CUD ... [2    ]
18) Line display .......... [0    ]       114) DNIC ................ [0    ]
19) Edit service signals .. [0    ]         C) Copy
                                           S) Save      CR) Exit
----------------------------------------------------------------------------------

When you changed all parameters of profile 1, than save the profile with

    S<CR>

and leave to the profile configuration menue.

5.5 Link configuration

Enter the link configuration for link 1 by activating fuction "3 Linkïn the configuration menue and function "3 Update Link parametersïn the link configuration menue. You get the following view:

----------------------------------------------------------------------------------
   X.25 Link 1    configuration
  ------------------------------
1) Address ............... [0    ]
2) DCE (1) / DTE (0)...... [0    ]     17) LGN ...................... [0    ]
3) Extended mode ......... [0    ]     18) Lowest LCN (LIC) ......... [3    ] <===
4) T1 .................... [5    ]     19) Amount of Incoming LCNs .. [5    ]
5) T3 .................... [20   ]     20) Amount of Two Way LCNs ... [5    ]
6) N2 .................... [10   ]     21) Amount of Outgoing LCNs .. [5    ]
7) k ..................... [7    ]     22) Internal Clock ........... [0    ]
8) w ..................... [2    ]     23) LINE option .............. [1024 ]
9) T10 ................... [18   ]     24) Segment Size.............. [128  ]
10) T11 ................... [20   ]     25) Xid num .................. [0    ]
11) T12 ................... [18   ]     26) NUI Group ID ............. [0    ]
12) T13 ................... [18   ]     27) Physical interface option. [0    ]

13) Packet size ........... [128  ]     28) CUG subscription ......... [5    ]
14) In call options ....... [1    ]     S) Save
15) Out call options ...... [1    ]     CR) Exit
16) Subaddress length ..... [2    ]
----------------------------------------------------------------------------------

When you changed all parameters of link configuration, than save the configuration with

  S<CR>

and leave to the link configuration menue.

5.6 Systemparameter configuration

Enter the systemparameter configuration by choosing function "4 System parametersïn the configuration menue. You get the following view:

----------------------------------------------------------------------------------
   System parameters configuration
  ---------------------------------
1) Device ID............................. [0    ]
2) X.28 prompt .......................... [*    ]
3) User password ........................ [XXXXXXXXXX]
4) Super user password .................. [XXXXXXXXXX]
5) Herald ............................... [CHANNEL NUMBER ]
6) Bulletin ............................. [     ]
7) Command port sub-address ............. [0    ]
8) Command port alternate sub-address ... [0    ]
9) Inner communication length ........... [2    ]
10) Xon .................................. [17   ]
11) Xoff ................................. [19   ]
12) Max LCN .............................. [45   ]
13) Max AIDs per link .................... [251  ]
14) Async Handshake Sequence ............. [;    ]
S) Save
CR) Exit
              Select:
----------------------------------------------------------------------------------

Normaly there should be nothing to change. If you checked the systemparameters leave this screen and go back to the main menue.

5.7 PVC configuration

Enter the PVC configuration by choosing "5 PVCïn the configuration menue. In the first step you should check if there exists a empty pvc-configuration table. You can view the configured pvcs by choosing "4 Display PVC sïn the PVC configuration menue. You should receive the following picture:

par   \   PVC     |
------------------|
Source Link       |
Source Channel/LCN|
Destination Link  |
Destination LCN   |
   Press <RETURN> to continue
----------------------------------------------------------------------------------

If your PVC-configuration dosn´ t look like this you should follow the reset procedure described at the end of this document and reset all parameters in the PAD and start again from the beginning with the setup procedure.

For OeBB X25 we need on the X.25 link two PVCs. In the next step we connect logicaly the two physikal links 2 and 3 to the first two PVCs on the physokal link 1, which is the X.25 connector. Links 2 and 3 are V.24/X.28 PAD Links to the OeBB X25 Applikation.

----------------------------------------------------------------------------------
1<CR>                   add PVC
1<CR>                   PVC number 1
1<CR>                   Local PVC
1<CR>2<CR>              from channel 2
2<CR>1<CR>              to channel 1
3<CR>1<CR>              PVC 1
s<CR>                   save configuration
<CR>                    leave to pvc-config-menue
1<CR>                   add PVC
2<CR>                   PVC number 2
1<CR>                   Local PVC
1<CR>3<CR>              from channel 3
2<CR>1<CR>              to channel 1
3<CR>2<CR>              PVC 2
s<CR>                   save configuration
<CR>                    leave to pvc-config-menue
----------------------------------------------------------------------------------

By choosing "4 Display PVC sïn the PVC configuration menue you should receive the following configuration:

----------------------------------------------------------------------------------
par   \   PVC     | 1   | 2   |
------------------|-----|-----|
Source Link       |LOCAL|LOCAL|
Source Channel/LCN| 2   | 3   |
Destination Link  | 1   | 1   |
Destination LCN   | 1   | 2   |
   Press <RETURN> to continue
----------------------------------------------------------------------------------

5.8 Call ID configuration

Normaly we don´ t use Call IDs! Nothing to change here.

5.9 NUI configuration

Normaly we don´ t use NUI! Nothing to change here. (NUI = Network User ID)

5.10 Alias configuration

Normaly we don´ t use aliases! Nothing to change here.

5.11 Routing table configuration

Normaly we don´ t use routing tables! Nothing to change here.

5.12 Funnel configuration

Normaly we don´ t use the funnel facility! Nothing to change here.

5.13 X.32 support configuration

Normaly we don´ t use X.32! Nothing to change here.

5.14 Management configuration

Normaly we don´ t use SNMP or Event-Reporting! Nothing to change here.

5.15 X.25 Mulit Cast configuration

Normaly we don´ t use X.25 Multi Cast! Nothing to change here.

5.16 IP Routing configuration

Normaly we don´ t use IP addresses! Nothing to change here.

5.17 ISDN configuration

Normaly we don´ t use ISDN! Nothing to change here.

6 Resetting / Troubleshooting

If you configured your PAD in the above described way, and the PAD dosn´ t do what you indent that it should do, and you lost the connection to your PAD, because it is now a transparent PAD and dosn´ t accept your terminalemulation connection, then you should do the following steps:

7. automatic configuring 14

• plug off all connectors from your PAD (realy all: even the powersupply)

• unscrew the housing of your PAD

• switch jumper to possition INT

• connect power-supply and wait approx. 1 Minute till the sync-LED starts blinking

• plug off power-supply

• switch jumper to position NORMAL

• reconnect all your connectors and the power supply

With this steps all your configurations your did before, are lost. All RAD-PADs factory defaults are restored and you can restart configuration procedure with a cleanRAD-PAD.

7 automatic configuring

7.1 Overview

In the following chapters you find a small C-Program for auto configure the APD-2. There is also the Makefile the startscript and the inputscript which is read from the C-program rad.c.

7.2 rad.c

/*
* rad.c
*
* input parser for PAD-configuration scripts
* ==========================================
*
#
# Copyright (C) 1999 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, "  rad <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 rad can\n");
  fprintf(stderr, "                      find the PAD\n");
  fprintf(stderr, "  \n");
  fprintf(stderr, "  example:  rad test /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);
        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;
while ( (rece = read(source_fh, source_buffer, 1)) == 1) {
if (source_buffer[0] == '\n') {
  command[com_p] = 0;
  if (command[0] != '#') {
    sprintf(out_buffer, "%s\r",command);
    write(out_fh, out_buffer, strlen(out_buffer));
    com_p = 0;
    sleep(2);
  } else {
    command[com_p] = '\n';
    command[com_p+1] = 0;
    if (log_fh > 0)
      write(log_fh, command, strlen(command));
    fprintf(stdout, "%s", command);
    com_p = 0;
  }
} 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();

  }
}

7.3 Makefile

The following listing should be copied into a file named Makefile. Afterwards you can type make clean ; make all ; make strip

      LDOPTIONS = -pedantic -Wall -g -DYY_SKIP_YYWRAP

                    OBJS = rad.o
                    SRCS = rad.c
all:    rad
        sudo chown root rad
        sudo chmod a+srw rad
rad:  $(OBJS) $(DEPLIBS)
        $(RM) $@
        $(CC) -o $@ $(LDENTRY)  $(OBJS) $(LDOPTIONS)  $(LIBS) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
rad.stripped: rad
        $(CP) $< $@
        $(STRIP) $@
strip:: rad.stripped
clean::
        $(RM) rad *.o
depend::
        @if [ -n "$(SRCS)" ] ; then set -x;\
        $(DEPEND) $(DEPENDFLAGS) $(SRCS) ;\
        fi

7.4 configuration script makerad

Copy the following lines into a file named makerad. Dont´ t forget to chmod the script: chmod a+x makerad

#! /bin/bash
#
# makerad - configuring a RAD-PAD
#
# Copyright (C) 1999 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 DATUS config to device /dev/$1
    export DATDEV=/dev/$1
        rad rad.cmd $DATDEV | tee rad.log
  else
    echo Could not find device /dev/$1
    echo "    example : $0 ttyS0"
  fi;
fi;

7.5 Parameterscript

Here you can find the complete Parameterscript for configuring the APD-2. Check if you didn´ t delete blank lines in the following file. The blank lines are very importent, because they generate a single CARIAGE-RETURN for navigating in the PAD-Menues. After the configuration is finished you have no connection to the configuration menue. You have to reset the APD-2 and to connect it to the testapplication.

#
# commandfile for configuring a RAD - PAD
#
# Copyright (C) 1999 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.
#
#
# Switching the PAD to Configuration Mode
C0

1
#
# =========================================
#
# Configuring the X.25 Link
3
3
# Par 18 to 3 = Lowest incoming LCN = 3
18
3
# Par 14 to 16 = assume PVC down on sync
#14
#16
# save it
s

#
#
# =========================================
#
# Making the PVC configuration
5
# add PVC
1
# add PVC 1
1
# local PVC
1
# Line (channel) 2
1
2
# Link (channel) 1
2
1
# LCN logical channel number 1
3
1
# save and back again
s

#
#
#
# add PVC
1
# add PVC 2
2
# local PVC
1
# Line (channel) 3

3
# Link (channel) 1
2
1
# LCN logical channel number 1
3
2
# save and back again
s

#
#
# =========================================
#
# back to config menue
1
# Update Profile 2
2
3
2
# Par 4 auf 1
4
2
# Par 5 auf 0
5
0
# Par 7 auf 0
7
0
# Par 11 auf 15
11
15
# Par 12 auf 0
12
0
# Par 110 auf 1
#110
#1
# save and out
s

#
#
# =========================================
#

     # load channel 2 and 3 with Profile 2
     #
     # back to config menue
     1
     # load channel 2 with Profile 2
     1
     3
     2
     1
     2
     # save and out
     s

     # back to config menue
     1
     # load channel 3 with Profile 2
     1
     3
     3
     1
     2
     # save and out
     s

     # Action done
     #
     # =========================================

8 Disclaimer

8.1 Comments

I would appreciate (but do NOT REQUIRE) that any changes (bugs, new features or spelling errors) be sent to me for inspection, discussion and possible inclusion into the next version.

8.2 Copyright

Dieses Dokument ist urheberrechtlich geschützt. Das Copyright liegt bei Heimo Schön.

Das Dokument darf gemäß der GNU General Public License verbreitet werden. Insbesondere bedeutet dieses, daß der Text sowohl über elektronische wie auch physikalische Medien ohne die Zahlung von Lizenzgebühren verbreitet werden darf, solange dieser Copyright Hinweis nicht entfernt wird. Eine kommerzielle Verbreitung ist erlaubt und ausdrücklich erwünscht. Bei einer Publikation in Papierform ist der Autor zu informieren.

This howto is free documentation; 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 of the License, or (at your option) any later version.

This document 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 document; if not, write to the: Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.