APD-2 + ÖBB X25 HOWTO <author> <name> Heimo Schön <htmlurl url="mailto:heimo.schoen@gmx.at" name="<heimo.schoen@gmx.at>"> </author> <date>Version 0.7 , 14. October 1999 <abstract> Setup a <htmlurl url="http://www.rad.com" name="RAD"> PAD <htmlurl url="http://www.rad.com/products/family/apd-2/apd-2.htm" name="APD-2"> to work in a ÖBB X25 environment </abstract> </titlepag> <sect>Overview <sect1>About this HOWTO <p> This document describes how to use the PAD built by <htmlurl url="http://www.rad.com" name="RAD">. We use the <htmlurl url="http://www.rad.com/products/family/apd-2/apd-2.htm" name="APD-2"> in a special configuration for the Austrian Federal Railways <htmlurl url="http://www.oebb.at" name="Ö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. <p> 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". <p> Special thanks to Ing. Johann Berger <htmlurl url="mailto:j.berger@online.edvg.co.at" name="<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). <p> For details to the ÖBB X25 specification you should contact Johann Berger. <p> Thanks to Michael Smutka <htmlurl url="mailto:michael.smutka@teleweb.at" name="<michael.smutka@teleweb.at>"> for his ideas and reviewing this document and the code. <p> If you have any suggestions to this document, than feel free to contact me: <p> <itemize> <item>Heimo Schön <htmlurl url="mailto:heimo.schoen@gmx.at" name="<heimo.schoen@gmx.at>"> <item><htmlurl url="http://fly.to/heimo.schoen" name="http://fly.to/heimo.schoen"> </itemize> <p> Have a lot of fun with this easy to use, easy to configure and very small X.25 PAD APD-2 from RAD. <p> <sect1>Test configuration <p> For testing the configuration in this document I used the following testequipment: <p> <tscreen><verb> +-------+ +-------+ | |-| | 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 </verb></tscreen> <p> 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. <p> <sect1>Version History <p> <itemize> <item> 0.1 01 Oct 1999 Cable Pin Diagram <item> 0.2 02 Oct 1999 First Pictures <item> 0.3 03 Oct 1999 Comparison Datus-Parameter with RAD-Parameter and description of how configuring the RAD-PAD <item> 0.4 07 Oct 1999 description of the c-programm and the parameter-input-script rad.cmd <item> 0.5 11 Oct 1999 Textfile to SGML <item> 0.6 12 Oct 1999 Minor text changes and release <item> 0.7 14 Oct 1999 Changes, corrections and ideas from Michael Smutka. Candidat for version 1.0 </itemize> <p> <sect>HW connection to your RAD-PAD <sect1>Cable for RAD-PAD <p> Build a cable with the following pinout: <p> <tscreen><verb> 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 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) </verb></tscreen> <p> <sect1>Description of the RJ45 Pins <p> <tscreen><verb> 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) </verb></tscreen> <p> 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. <p> <sect>SW connection to your RAD-PAD <sect1>Terminalemulation minicom <p> Start minicom on your linuxbox. You can type minicom com2, when you create the following minicom configuration file: <p> <tscreen><verb> # 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 </verb></tscreen> <sect>Entering into your RAD-PAD <sect1>main menu <p> 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 "*". <p> 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 <tscreen><verb> CLR<CR> to disconnect the call. </verb></tscreen> <p> Now verify that the PAD is free by typing the command <tscreen><verb> STAT<CR> </verb></tscreen> <p> When you can see the PAD-Prompts * sign you can connect to the main-menue by typing <tscreen><verb> CON 00<CR> </verb></tscreen> or <tscreen><verb> C 0<CR> </verb></tscreen> <p> Now you receive the following screen: <p> <tscreen><verb> ---------------------------------------------------------------------------------- MAIN MENU ----------- 1) CONFIGURE 2) SYSTEM CONTROL 3) DIAGNOSTICS 4) STATUS and STATISTICS 5) LOGOUT Select: ---------------------------------------------------------------------------------- </verb></tscreen> <sect1>system status <p> You can few your PADs status by choosing 4: <tscreen><verb> ---------------------------------------------------------------------------------- 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: ---------------------------------------------------------------------------------- </verb></tscreen> <sect1>link 1 status <p> For example the link 1 should bring: <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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 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: ---------------------------------------------------------------------------------- </verb></tscreen> <p> <sect1>link 2 status <p> and link 2 should look like: <tscreen><verb> ---------------------------------------------------------------------------------- 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: ---------------------------------------------------------------------------------- </verb></tscreen> <sect1>device status <p> and on device 0 the channel 0 you should see this: <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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: ---------------------------------------------------------------------------------- </verb></tscreen> <p> <sect>Configuration for OeBB PAD Mode <sect1>Warning <p> 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. <p> <sect1>start configuration <p> Enter the configuration menue with typing <p> <tscreen><verb> 1<CR> </verb></tscreen> <p> You should receive the following view: <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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: ---------------------------------------------------------------------------------- </verb></tscreen> <p> 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. <p> <sect1>Channel configuration <p> Press <p> <tscreen><verb> 1<CR> </verb></tscreen> <p> to enter the channel configuration <p> Press <p> <tscreen><verb> 5<CR> </verb></tscreen> <p> to check channel types. You should see the following: <tscreen><verb> ---------------------------------------------------------------------------------- Chan | 2 | 3 | -----|-----|-----| Prot |X.28 |X.28 | ---------------------------------------------------------------------------------- </verb></tscreen> <p> 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 <p> <tscreen><verb> 3<CR> </verb></tscreen> <p> and enter channelnumber <p> <tscreen><verb> 2<CR> </verb></tscreen> <p> <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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 ---------------------------------------------------------------------------------- </verb></tscreen> <p> Change the parameters to the above settings. <p> Attention: Don´t foreget to save the changes with <p> <tscreen><verb> S<CR> !!! </verb></tscreen> <p> <p> After changing the parameters, duplicate line 2 to line 3 by typing <p> <tscreen><verb> ---------------------------------------------------------------------------------- 1<CR> duplicate channel 2<CR> source channel 3:3<CR> destination channel range ---------------------------------------------------------------------------------- </verb></tscreen> <p> This commands duplicate channel 2 to the range of channels 3 to channel 3. <sect1>Profile configuration <p> Enter the profile configuration for profile 1 with typing <p> <tscreen><verb> 2<CR> </verb></tscreen> <p> and <p> <tscreen><verb> 3<CR> </verb></tscreen> <p> in the configuration menue. You get the following view: <tscreen><verb> ---------------------------------------------------------------------------------- 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 ---------------------------------------------------------------------------------- </verb></tscreen> <p> When you changed all parameters of profile 1, than save the profile with <p> <tscreen><verb> S<CR> </verb></tscreen> <p> and leave to the profile configuration menue. <sect1>Link configuration <p> Enter the link configuration for link 1 by activating fuction "3 Link" in the configuration menue and function "3 Update Link parameters" in the link configuration menue. You get the following view: <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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 ] ---------------------------------------------------------------------------------- </verb></tscreen> <p> When you changed all parameters of link configuration, than save the configuration with <tscreen><verb> S<CR> </verb></tscreen> and leave to the link configuration menue. <p> <sect1>Systemparameter configuration <p> Enter the systemparameter configuration by choosing function "4 System parameters" in the configuration menue. You get the following view: <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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: ---------------------------------------------------------------------------------- </verb></tscreen> <p> Normaly there should be nothing to change. If you checked the systemparameters leave this screen and go back to the main menue. <p> <sect1>PVC configuration <p> Enter the PVC configuration by choosing "5 PVC" in 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" in the PVC configuration menue. You should receive the following picture: <p> <tscreen><verb> ---------------------------------------------------------------------------------- par \ PVC | ------------------| Source Link | Source Channel/LCN| Destination Link | Destination LCN | Press <RETURN> to continue ---------------------------------------------------------------------------------- </verb></tscreen> <p> 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. <p> 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. <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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 ---------------------------------------------------------------------------------- </verb></tscreen> <p> By choosing "4 Display PVC s" in the PVC configuration menue you should receive the following configuration: <p> <tscreen><verb> ---------------------------------------------------------------------------------- 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 ---------------------------------------------------------------------------------- </verb></tscreen> <p> <sect1>Call ID configuration <p> Normaly we don´t use Call IDs! Nothing to change here. <p> <sect1>NUI configuration <p> Normaly we don´t use NUI! Nothing to change here. (NUI = Network User ID) <sect1>Alias configuration <p> Normaly we don´t use aliases! Nothing to change here. <sect1>Routing table configuration <p> Normaly we don´t use routing tables! Nothing to change here. <sect1>Funnel configuration <p> Normaly we don´t use the funnel facility! Nothing to change here. <sect1>X.32 support configuration <p> Normaly we don´t use X.32! Nothing to change here. <sect1>Management configuration <p> Normaly we don´t use SNMP or Event-Reporting! Nothing to change here. <sect1>X.25 Mulit Cast configuration <p> Normaly we don´t use X.25 Multi Cast! Nothing to change here. <sect1>IP Routing configuration <p> Normaly we don´t use IP addresses! Nothing to change here. <sect1>ISDN configuration <p> Normaly we don´t use ISDN! Nothing to change here. <sect>Resetting / Troubleshooting <p> 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: <p> <itemize> <item>plug off all connectors from your PAD (realy all: even the powersupply) <item>unscrew the housing of your PAD <item>switch jumper to possition INT <item>connect power-supply and wait approx. 1 Minute till the sync-LED starts blinking <item>plug off power-supply <item>switch jumper to position NORMAL <item>reconnect all your connectors and the power supply </itemize> <p> 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 "clean" RAD-PAD. <p> <sect>automatic configuring <sect1>Overview <p> 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. <sect1>rad.c <p> <tscreen><verb> /* * 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(); } } </verb></tscreen> <sect1>Makefile <p> The following listing should be copied into a file named Makefile. Afterwards you can type make clean ; make all ; make strip <tscreen><verb> 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 </verb></tscreen> <sect1>configuration script makerad <p> Copy the following lines into a file named makerad. Dont´t forget to chmod the script: chmod a+x makerad <tscreen><verb> #! /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; </verb></tscreen> <sect1>Parameterscript <p> 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. <tscreen><verb> # # 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 1 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 # # ========================================= </verb></tscreen> <sect>Disclaimer <sect1>Comments <p> 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. <sect1>Copyright <p> Dieses Dokument ist urheberrechtlich geschützt. Das Copyright liegt bei Heimo Schön. <p> 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. <p> 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. <p> 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. <p> 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. <p> </article> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-exposed-tags:nil sgml-local-catalogs:("/usr/lib/sgml-tools/dtd/catalog") sgml-local-ecat-files:nil End: -->