Portable software for connecting remote microcomputers and a central minicomputer

Portable software for connecting remote microcomputers and a central minicomputer

Portable software for connecting remote microcomputers and a central minicomputer It is u s e f u l for s t a n d - a l o n e m i c r o c o m p u t e ...

287KB Sizes 0 Downloads 106 Views

Portable software for connecting remote microcomputers and a central minicomputer It is u s e f u l for s t a n d - a l o n e m i c r o c o m p u t e r s to be a b l e to c o m m u n i c a t e w i t h c e n t r a l c o m p u t e r s m o r e c h e a p l y t h a n by laying d o w n t i e l i n e s . Communication s o f t w a r e w h i c h n e e d s o n l y an R S 2 3 2 port a n d a C P / M based microcomputer r u n n i n g B A S I C is d e s c r i b e d by B J S p a r l i n g A number o f programs which allow communication between remote microcomputers and a central computing centre are described. The software is written in BASIC for the microcomputer (an Equinox) and in PASCAL for the rain-computer (Nord 100). The requirement for the microcomputer to run the software is that it is CP/M-based and has a spare R5232 port. Data/s transferred in blocks o f 40 byte to the remotes sites via modems through the telephone lines. The datarate is 300 baud. Examples o f the communication software are given. microsystems

communication

software

For a university with several remote satellite departments, i.e. at a distance of 1 km or more from the centre of the campus, communication between departmental microcomputers and the main resourses of the computer centre is desirable. The computer centre at Reading University has three Nord 100 minicomputers, all interlinked, and a Nord 500. There is also an ICL 1904S running GEORGE3 which is linked to one of the Nord 100s (Figure 1). This article presents a small suite of programs which permits a remote microcomputer to act as a terminal to the central computers and also to pass files in both directions between microcomputer and computer centre. A software handshake is implemented in the file passing protocol which sends blocks of 40 byte, preceded by a known 'data' byte and followed by a checksum byte. The next block will not be sent until a 'ready' byte has been received from the other end. The proposed communication medium to outlying departments is standard telephone lines with modems, at 300 baud. The main user requirements are: • •



to allow a microcomputer with an integral keyboard and display to act as a terminal to the Nord to pass data collected at the remote site by a microcomputer, up to the Nord system at the computer centre for processing to return results from the Nord to the microcomputer; many users also have other files on the Nord which they wish to transfer to their own microcomputer system

Microprocessor Unit, University of Reading, Whiteknights, Reading, Berks RG6 2AX, UK

vol 7 no l january/february 1983

I

Consoleond

I t

keyboard

I

I s~iol

Ports Microcomputer ports

16, 17 I

running CP/M I 18,19

Telephone/

I I I No~d500 I I I

I No,~Ioo I I I ,

,\

I ICL 1904SI I I

/ I I

Nord I00

I No~Ioo I

,

I

I

Figure I. Hardware configuration between the computer centre resources and a microcomputer running CP/M A further extension of the two-way link between microcomputers and the computer centre is that any two microcomputers with this facility can transfer data between themselves, regardless of the microprocessor system configurations, using the larger computers as intermediaries. The only requirements made of the microcomputer are that a spare RS232 port (this can be the printer port) is available and that it uses BASIC.

SO F T W A R E The major demand within the university is not merely for a link between microcomputer and Nord but, more specifically, for a link between CP/M and Nord's operating system, SlNTRAN. CP/M is the most common operating system on 8-bit, Z80/8080 8085-based microcomputers 1-3 and thus ensures that programs for microprocessors will be portable in as much as most CP/M systems have an implementation of Microsoft BASIC4 . The microcomputer must have a spare serial port to connect to the incoming telephone line from the Nord. In the system described in this paper, the microcomputer

0141-9331/83/070025-28 $03.00 © 1983 Butterworth &Co (Publishers) Ltd

25

is an Equinox s and the larger computer is tile Nord 100 The Equinox has two serial ports. One for the console device and the second one, nominally, as a list device. Here, the list device is used as a two-way channel to the Nord. The serial ports actually consist of two logical ports, one for data and one for status and commands. In the Equinox, the console is allocated port 16 for status and port 17 for data. Similarly, the list device is assigned port 18 for status and port 19 for data. The transfer program on the microcomputer has two separate tasks:



to use the microcomputer's console and keyboard as a terminal to the Nord to transfer files in both directions between microcomputer and the Nords



The transfer program uses sense status input from the console rather than interrupt control because it is working at slow speeds over telephone lines. During input, the keyboard is monitored for a Control C which is the standard CP/M 'break'. If the break key is detected, then a CP/M break-in is implemented, regardless of CP/M or Nort activity. Optionally, Control C could be arranged to Iogout of Nord before actually performing the CP/M break. I-he routine to input characters from the Nord must check for the presence of a character before trying to read a character. Figure 2 shows the input subroutine which includes calls to two library routines: INP(port no.) : inputs a byte from the specified port AS=IN KEYS : returns either a one character string read f?om the terminal or a null string if there is no character pending at the terminal INP waits until a character is present at the specified port, consequently the status port must be checked first to prevent the program halting if there is no character pending from the Nord. The status byte of the input port is shown in Table 1, although this will vary slightly for different microcomputers. 10 AS=IN KEYS 20 25 30 32 34

IF AS =' " ' T H E N 32 IF ASC(AS)=3 THEN 1200 OUT 19, ASC(AS) A=INP(18) I F ( A A N D 1)=OTHEN 10

36 A=INP(19) 38 OUT 17,A 50 GOTO 10

;get char from keyboard ;if no char present then go to 32 ;if char=CTRL C then END ;output char to NORD ;input from NORD status port ;if no char present then go back to 10 ;input from NORD data port ;output char to monitor

1200 END

Figure 2. Nord terminal handling program (the righthand side explains the program operation) T a b l e 1. Status b y t e o f the i n p u t p o r t Status ( i n p u t )

Command byte

(output) Bit 0

Receive data ready

Parity inhibit

Bit 1

Transmit register empty

Even parity enable

Bit 2

Parity error

Stop bit select

Bit 3

Framing error

Word length (Isb)

Bit 4

Overrun error

Word length (msb)

26

Algorithm outlines are given in Figure 3 for the reception and transmission of files. Data are always sent in blocks of 40 byte and are padded with spaces if necessary. 40 byte blocks is an arbitrary choice, comfortably less than the size of the Nord type ahead buffer. Data bytes either incoming or outgoing, are also sent to the monitor so that the user can check the progress of the transmission. The subroutine characters from the Nord is shown in Figure 4. This is a sense status routine which will not return until either a character has been received from the Nord or an Escape has been detected at the keyboard. In the latter case, Escape is implemented as a break to Nord and terminates the Nord program currently running.

NORD TRANSFER SOFTWARE The Nord programs, one for file transmission and one for file reception, are written in PASCAL. The main bodies of these programs are presented in Figures 5 and 6. The program to transfer files from Nord to CP/M uses the procedure 'fetchblock' to get 40 byte of data from a file. The parameters returned are: • • •

the number of bytes in the block - this may be less than 40 if the end of file has been reached a Boolean variable denoting whether end of file has been reached a byte array containing the data bytes

The procedures 'readbyte' and 'writebyte' are used to GET characters from the 'terminal' and PUT characters to the 'terminal', respectively. During normal operation, the Nord will echo characters sent to it, but during file transmission, the echo mode is turned off so that protocol and data bytes are not echoed back to the microcomputer. The Nord believes that it is talking to a simple terminal and all characters sent are of type BYTE which is defined as 0 . . . 255. Receive: get DATA from NORD FOR i:= 1 TO 40 DO get char from NORD checksum:=checksum +char

Transmit: get 40 bytes from disc or until end of file pad with spaces if necessary send DATA

OD get checksum from NORD IF checksum correct THEN copy 40 byte block to disc send NEXT ELSE send AGEN FI

FOR i:=1 TO 40 Do send char to NORD checksum:=checksum+ char OD send checksum Wait for Next/AGEN

Figure 3. Algorithms for transmission and reception of files 1100 A=INP(18) 1110 I F ( A A N D 1 ) < > THEN 1120 1112 B$=INKEY$ 1113 IF B$ =' ~''THEN 1100 1114 IF ASC(B$)< >27 THEN 1116 OUT 19,27 1118 R=I 1119 GOTO 1140 1120 A=INP(19) 1 1 3 0 A = A M O D 128 1140 RETURN

;input from NORD status port ;if no character present ;then input from keyboard if no character present then retry else if character is escape then output escape to NORD and set a flag ;else input character from NORD ; strip off parity

Figure 4. To input characters from the Nord; checking for Escape from the keyboard

microprocessors and microsystems

FOR i:=1 TO 5 DO write(outfile,i); REPEAT writebyte (SOM); readbyte (returncode) UNTI L returncode=SOM; retu rncode:=N EXT; REPEAT IF returncode=NEXT THEN fetchblock (numbytes, result, byteblock); IF numbytes < 40 THEN FOR i:=numbytes+l TO 40 DO byteblock[i] :=0; writebyte (DATA); checksum:=O; FOR i:=1 TO 40DO BEGIN writebyte(byteblock [i] ); checksum:=checksum+byteblock[i] END; checkbyte:=checksum MOD 128; writebyte (checkbyte); readbyte (returncode) UNTIL result AND (returncode=NEXT); writebyte (EOMI: Figure 5. Nord PASCAL program to send files to CP/M

FOR i:=1 TO 5 DO write(outfile, i); REPEAT writebyte(SOM); readbyte(returncode) UNTIL returncode=SOM; REPEAT writebyte(NEXT); readbyte(retu rncode); I F returncode=DATA THEN BEGIN checksum:=0; FOR i:=1 TO 40 DO BEGIN readbyte(charcode); byteblock[i] :=charcode; checksum:=checksum+byteblock [i] END; checkbyte:=checksum MOD 128; readbyte (charcode); I F charcode-checkbyte THEN BEGIN FOR i'=1 TO 40 DO write(dfile, byteblock[i] END END UNTI L returncode=EOM; Figure 6. PASCAL program to receive files from CP/M For file transfers at 300 baud, no characters are likely to be lost, even using the Nord type-ahead facility when data are being sent from Nord to CP/M. Tests suggest that the maximum rate which can be handled reliably, is 1200 baud.

FILE TRANSMISSION PROTOCOL The mechanism for transferring from terminal mode to file transmission mode is triggered by the Nord sending the sequence 01H-05H to the CP/M system. Before any data blocks are sent, start of message (SOM) bytes are exchanged to initialize the transmission. All data passing between the two computers is sent as an ASCII representation. Once file transmission has been established, a simple protocol is used to transfer files in blocks of 40 byte. Each block is preceded by a byte denoting either the presence of data (DATA) or the end of a message (EOM). Data blocks are followed by a checksum byte. No further data blocks will be sent until the acknolwedgement code,

vol 7 no 1 january/february 1983

NEXT, is received, signifying that the previous block has been correctly received at the other end. If the checksum is wrong then the receiver sends the code AGEN, indicating that the previous block should be repeated. Protocol codes are given in Table 2 and the sequence of the file transfer is shown in Figure 7.

CONCLUSIONS A successful link has been established between an Equinox microcomputer system and the Nord minicomputers, using a standard telephone line as the communication medium. The transmission rate of 300 baud is capable of supporting full duplex communication with no character loss. A similar link has also been installed between a Sorcerer microcomputer and the Nords, and between an Apple and the 1904S. To date, several Mbyte of file data have been transferred with virtually no repetion of blocks. To the user, the microcomputer merely appears as a standard terminal to the computer centre machines. To invoke the file transmission process, the relevant program is run, just as any other Nord package would be run. The user is asked to specify source and destination file names on each system depending on the direction of file transfer. Once this is done, file transfer proceeds with no further action required from the user. Upon termination, control is returned to the Nord console as would be normal at the termination of any program run. The comolete BASIC program on the microcomputer consists of less than 100 lines and contains no nonstandard software. For microcomputer systems which do not have compatible disc formats, the simplest method of establishing portability is to type in the BASIC program, editing port numbers and taking into account any change in format of status and command bytes. Since the program is so

Table 2. Protocol codes and values

Command

Hex Code

Comment

SOM

06

Start of message

EOM

07

End of message

NEXT

08

Send next block

DATA/ AGEN

09

Data block header or return code signifying corrupted block

Nord

CP/M

Send 1,2,3,4,5

Receive 1,2,3,4,5

Send SOM Send DATA Send 40 byte Send checksum

Receive NEXT/AGEN

Receive SOM Receive DATA Receive 40 byte Receive checksum If checksum correct

then send NEXT else send AGEN

Send EOM Receive EOM

Figure 7. File transmission protocoL Exactly the same protocol is observed for transmission in the other direction

27

small, this is no great hardship for any implementer and provides the opportunity for minor modifications to suit a particular individual.

2 Zaks, R 'CP/M, the standard operating system for business applications' Micro Forecast (18 November 1980) 3 CP/M 2.2 User's Guide Digital Research, USA (1979) 4 Microsoft BASIC Reference Book Microsoft, USA

REFERENCES 1 Kildall, O 'A family of 8- and 16-bit operating systems' Byte (June 1981).

28

(1979) 5 Equinox Documentation Industrial Micro Systems, Inc.,

USA (1981)

microprocessors and microsystems