textfiles/programming/m200tran.txt

435 lines
20 KiB
Plaintext

Having been the happy owner of a Tandy 200 for a long time, I've compiled some information that I've found useful for
uploading to a PC from a T200 or T100 WITHOUT A TERMINAL PROGRAM. After a description of uploading procedure and some
tips, I've included a TANDY 100/200 program which will upload all .DO and .BA files in a memory bank to a PC in one
concatenated process, and a PC GWBASIC program to reconstitute them.
T200/100 <-> IBM PC
FILE EXCHANGE
by Kent Nickerson
_____________________________________________________________________________________________________________________
1) TANDY File Types
Only 7-bit files can easily be transmitted and received by the T200/100. This means that only .DO files can be exchanged,
so that .BA files must be saved in .DO (ASCII) format for uploading. .CO files on the TANDY cannot be uploaded without
some sort of code/decode scheme. Multiplan spreadsheet files can be saved in SYLK format for upload and decoded by
importing into spreadsheets capable of decoding SYLK format (like Quattro Pro).
2) Upload/Download Procedure
File exchange between a T200/100 and a PC involves the following steps:
a) connect a null modem cable from the TANDY RS232 port and a RS232 (serial) port of the PC.
b) use the MODE command on the PC and the STAT command in TELCOM on the T100/200 to match communications parameters.
c) To download, go into TELCOM terminal mode on the T100/200, press "Down", then send the PC file out the appropriate port
using the COPY command on the PC. Press "Down" again when the file transfer is complete.
d) To upload, use the PC COPY command to direct its serial port input to a file. Go into terminal mode in TELCOM on the
T100/200, press "Up" and specify the .DO file to transfer. Press CTRL-Z when the transfer is finished.
I will expand on these points:
a) Null Modem Cable
A NULL MODEM cable is required with a 25-pin male connector on one end (to mate with the TANDY female RS232 port
connector) and a 9 or 25 pin connector on the other end to mate with a PC serial (RS232) port. Such a cable can be made
from a normal RS232 cable with a NULL MODEM adapter available from computer shops for about $10.
A null modem cable can be made at home from a pair of connectors (preferably with "solder cup" connections) and a 7
conductor cable. For neatness, one should use a ribbon cable or jacketed cable with 7 or more wires. The connectors are
wired in the following way:
2 --------------------------- 3 (2)
3 --------------------------- 2 (3)
4 -,------------------------- 8 (7)
5 -' ,- 4 (8)
8 -------------------------'- 5 (1)
7 --------------------------- 7 (5)
6 --------------------------- 20 (4)
20 --------------------------- 6 (6)
Pin numbers are for 25-pin connectors, while those in brackets are for 9-pin connectors. Note that pins 4 and 5 are
shorted together on each connector. The pin numbers will be printed beside the connector pins (they will be hard to see!).
b) Setting Up Communications
When the cable has been installed, go into TELCOM on the laptop and select communications parameters which match those of
the PC's serial port. Personally, I've experienced the occasional error at baud rates greater than 1200. There are many
parameter permutations possible, but the one that I use is 1200 baud, even parity. Set this up on the TANDY by pressing
"Stat" and typing:
57e1enn (on the T200)
or
57e1e (on the T100)
To set up the PC communications parameters, type:
mode comx: 1200,e,7,1
where "comx" is the PC serial port the null modem cable is hooked into (com1 or com2). If other comm parameters are
desired, see the end of this document.
After the comm parameters are set and matched, press "Term" on the laptop to prepare for up/download. More details on
communications parameters are included at the end of this document.
c) Download from PC to T200/100:
Press "Down" on the Tandy. When it turns reverse video, type on the PC:
copy filename comx:
where "comx" is the PC serial port used and "filename" the PC file to download. When transfer is complete (the transfer
will appear on the laptop screen), push "Down" again to terminate.
NOTE: If there are many errors in download, decrease the baud rate.
Conversely, one may try a higher baud rate if no problems are experienced at 1200 baud.
d) Upload from T200/100 to PC:
On the PC, type:
copy comx: filename
where "filename" is the file you want to upload data to. Press "Up" and enter the name of .DO file to upload (extension
not required). The "Width" parameter, if one is entered, specifies a maximum uploaded line length and will cause lines
exceeding the length you specify to be cut into several lines less than or equal to it. If you do not specify this
parameter, lines will be sent without any breaks other than those
already in the file. Generally, specifying no width is ok, but sometimes will cause a PC buffer overflow and abort if
there are lines exceeding 255 characters.
After pressing Enter, the "Up" label should go into reverse video, indicating that upload is progressing. When it returns
to normal video, the upload is finished. If the "Up" label is still in reverse video after a time (in seconds) of about
the ten times the size of the file in bytes divided by the baud rate (e.g. about 20 seconds for a 2000 byte file at 1200
baud), there is something wrong with the cable or the communications parameters are not matched. You may have to reboot
the
PC in this case to break it out of its reverie. If the upload has been performed, press CTRL-Z on the laptop (Hold down
CTRL and press Z) to close the connection to the PC. The PC should save the file and return with a screen prompt. To abort
an upload, press the reset switch in the back ot the laptop, enter TELCOM again, press "Term", then CTRL-Z to close the PC
connection.
On most PCs, uploading in this manner will create files which have only line feeds for line breaks, resulting in lines
which appear without carraige returns, like this, or in lines which overwrite when displayed because they have carriage
returns but no line feeds. You can make your T100/200 send <CR><LF> pairs by modifying a specific byte by going into BASIC
on the laptop and typing:
POKE 61243,1 (for the T200), or
POKE 63066,1 (for the T100)
The default value is 0 (for sending <LF> only). The new value will stay in effect as long as the computer is not cleared
(by memory reset or by being without batteries for a long time). This modification may cause null characters (ASCII 0) to
be added to the beginning and end of the document, but these are easily removed and indeed are ignored and stripped by
some processors like WordPerfect.
3) Memory Bank Upload Utility
For those who wish to upload whole memory bank(s) at a time, I've written the following programs: BK.BA for the T100/200,
and a PC GWBASIC parser. Program BK will upload all .DO and .BA files on a bank to a single concatenated file on the PC.
The component (ASCII) files will be separated with a header with a marker line and the filename, like so:
!@#$!@#$
FILENAME
The component files can then be separated with a word processor or automatically parsed by the PC GWBASIC program UNPACK,
which is listed further on in this document.
Because of the Usenet's 80 column limitation, program lines 90, 100, and 180 are broken. Download the program as described
above to the TANDY and restore the broken lines (without spaces) on the T100/200. It must be converted to a .BA file and
named "BK" for use. To do this, go into BASIC and type:
load "filename"
where filename is the TANDY .DO program file. When the "Load" label stops flashing, type:
save "bk
The .DO file can then be erased (KILLed).
Once the program is on the laptop (it must be in the bank you want to upload), type "copy comx: filename" on the PC and
run the program. The PC should automatically be released at the end of the transfer.
Notes: Sometimes this program will close the PC file after a BASIC (*.BA) file has been sent up from the TANDY. See
comment on line 100 if you have this problem. Program BK.BA was derived in large part from a program written and
distributed on CompuServe by James Yi (73327,1653 01/16/88)
_____________________________________________________________________________________________________________________
10 ' Saves all .BA and .DO type files in the current ram bank to RS232.
20 ' If program stopped, running again will save next file, but POKE Q,0
30 ' will cause it to start over. WARNING: Run program from .BA format.
40 MAXFILES=2:CLEAR600
45 IFPEEK(1)=171THENSL=62122:KB=64798:LF=61243 ELSESL=63919:KB=65450:LF=63066 50 POKE LF,1:OPEN "COM:57e1enn" FOR OUTPUT AS 2
60 Q=SL+3:F=PEEK(Q):IFF>48THENF=0
70 F=F+1:POKEQ,F:RD=F*11+SL:S=PEEK(RD)
75 IFS=255THENPOKE Q,0: PRINT #2,CHR$(26):PRINT"Done.":BEEP:END
80 IFS=0THEN70
90 F$="":FORM=RD+3TORD+10:F$=F$+CHR$(PEEK(M)):NEXT:FP$=LEFT$(F$,6):F$=FP$+ "."+RIGHT$(F$,2)
100 IFS<>192ANDS<>128THENPRINT"File is binary or not recognized --";S;F$:GOTO70
110 IFF$="BK .BA"THEN70
120 IFS=128THEN180 ' BASIC file
150 GOSUB230:OPEN F$ FOR INPUT AS 1
160 A$=INPUT$(1,1):PRINT #2,A$;
170 IFNOTEOF(1)THEN160ELSECLOSE1:GOTO70
180 GOSUB230:Q$=CHR$(34):K$=CHR$(127)+"Loadf$"+CHR$(13)+"Save"+Q$ +"com:57e1enn"+CHR$(13)+"Run"+Q$+"BK"+CHR$(13)
190 ' Activate Keyboard Buffer
200 FORL=1TOLEN(K$):POKEKB+L*2-1,ASC(MID$(K$,L,1)):NEXT
210 POKE KB,L-1
220 END
230 PRINT"Saving:";CHR$(27)+"p"+F$+CHR$(27)+"q"
240 PRINT #2," ":PRINT #2,"!@#$!@#$":PRINT#2,F$:PRINT#2," "
250 RETURN
_____________________________________________________________________________________________________________________
Some documentation:
Line 45 - Location 1 identifies a Model 100 or 200 (PEEK(1)=171 for a 200).
File directory, keyboard buffer, line feed enable locations assigned.
50 - The line feed patch is enabled. Normally, the TANDY does not issue LF characters on file transfers. This patch is
useful for most computers, but some PCs' (HP150) will terminate receiving at the first carraige return if it is invoked.
In such a case, change the first statement of this line to POKE lf,0. The RS-232 port is set as an output device at 1200
baud. Edit this segment if you want comm parameters changed.
60 - Location Q serves to count the number of files transferred, and to supply an index to byte RD, which contains a file
type code (128=BASIC file, 192=text file). Since there is a maximum of 48 files, any greater number implies this program
has not been run, and the file number is reset. Q is not an internal because all such variables are lost when the program
calls itself in line 180-210.
70 - Head of program loop.
75 - Code = 255 indicates no more files. CTRL-Z sent to terminate PC receive.
80 - Provision for empty entry.
90 - Q is file name pointer.
100 - This program handles transfer of text and BASIC files only. Some PC's will stop receiving data from this program at
the end of transmission of a BASIC file. If this is the case, change line 140 to:
140 IFS=128THEN70:' BASIC file (e.g. jump to 70 instead of 180)
(Lines 180 to 210 inclusive can be removed in this case, but will do no harm otherwise). If transfer of BASIC files are
desired in this event, they must first be saved in ASCII format before invoking this program.
110 - Prevents transmission of the program file itself (save in .DO format if file copy desired).
120 - Escape (chr$(27)) sequences cause file name display in reverse video. 130 - Print file separation header to the PC
file. If sequence changed, modify program UNPACK as well.
180-210: Load keyboard buffer with instructions to load .BA file, and save in ASCII form to RS232 port, and invoke BK
again. Marker set in 60,70 gives restart point.
If the program is aborted, type POKE Q,0 to reset it fully.
Do not change the name of this program from "BK" without similarly changing all references to itself in the program. At
any rate, the name cannot be longer than two letters, given keyboard buffer size limit in line 180.
The (concatenated) PC file can then be separated by a word processor, using the component file headers or else by using
the GWBASIC program below on the PC. The program will check against overwriting existing files.
_____________________________________________________________________________________________________________________
10 REM ******************** PROGRAM "UNPACK" *****************************
20 REM
30 REM This program unpacks a composite text file composed of a number of
40 REM files delimited by a three line header. The first header line is
50 REM the string:
60 REM !@#$!@#$ (e.g. a distinct marker)
70 REM followed by the file name and a blank line. These headers are
80 REM stripped and the separate files reconstituted.
90 REM
100 DIM BUFFER$(1001) 'A buffer is used to reduce disk file writes.
110 REM
120 ON ERROR GOTO 800
130 INPUT "Enter name of composite file >",C$
140 OPEN C$ FOR INPUT AS #1
150 EOFFL=0: ERRFL=0
160 REM
170 REM If a drive is specified (second character = ":"), set the drive
180 REM as a filename prefix. Unpacked files will go to this drive as well.
190 REM
200 PREFIX$=""
210 IF MID$(C$,2,1)=":" THEN PREFIX$=LEFT$(C$,2)
220 REM
230 REM Go through the file line by line until the first file header is found.
240 REM The first header usually is right at the file beginning, but "junk"
250 REM characters may precede it - hence the initial search using INSTR.
260 REM
270 LINE INPUT #1, A$
280 IF INSTR(A$,"!@#$!@#$")<>0 THEN 560
290 IF NOT EOF(1) THEN 270
300 PRINT "End of file reached - No file bounds found":END
310 REM
320 REM Read lines of the composite file until:
330 REM 1) 1000 lines are read
340 REM 2) the "!@#$!@#$" delimiter line is found, or
350 REM 3) end of file is reached.
360 REM In case 2), the counter is reduced by 1 to omit the delimiter line
370 REM
380 FOR I=1 TO 1000
390 LINE INPUT #1, BUFFER$(I)
400 IF NOT EOF(1) GOTO 430
410 EOFFL=1 'End of file flag
420 GOTO 540
430 IF LEFT$(BUFFER$(I),8)="!@#$!@#$" THEN I=I-1: GOTO 540
440 NEXT I
450 REM
460 REM If 1000 lines read, write them to the output file, and resume reading 470 REM
480 FOR J=1 TO 1000: PRINT #2, BUFFER$(J): NEXT J
490 GOTO 380
500 REM
510 REM Case of delimiter encoutered. Variable FIRST prevents "close #2"
520 REM statement on first pass, since no output file is open then.
530 REM
540 FOR J=1 TO I: PRINT #2, BUFFER$(J): NEXT J 'Write final data
550 CLOSE #2 'Close file
560 IF EOFFL<>0 GOTO 770 'End program if input file exhausted
570 LINE INPUT #1,F$ 'Read file name
580 F$ = PREFIX$+F$ 'Add directory
590 OPEN F$ FOR INPUT AS #2 'Attempt to open file
600 REM
610 IF ERRFL<>0 THEN 720 'File does not exist if no error
620 BEEP 'Case of file already existing
630 PRINT "File ";F$;" exists. Overwrite? (Y,y=yes) >";
640 INPUT ANS$
650 IF ANS$="y" OR ANS$="Y" THEN 720
660 INPUT "Enter alternative file name (No entry will skip file) >",F$ 670 REM
680 REM A null file name will initiate search for the next file header.
690 REM Otherwise, an existence check is performed on the new file name.
700 REM
710 IF F$="" THEN 150 ELSE GOTO 580
720 ERRFL=0:CLOSE #2
730 OPEN F$ FOR OUTPUT AS #2 'Open new output file
740 PRINT "Restoring file ";F$
750 LINE INPUT #1, A$ 'Ignore blank header line
760 GOTO 380
770 CLOSE
780 END
790 REM Error Handler. Primarily used to detect an error condition in 520.
800 ERRFL=ERR:RESUME NEXT 'Set error flag in case of error (ERR <> 0)
______________________________________________________________________________________________________________________________
4) Communications Parameters for T100/200 and PC
While I have settled on 1200 baud even parity as my standard communications parameters, others may want to experiment with
different parameters.
a) PC Communications Parameters
Command Syntax:
mode comx: b,p,d,s,r
where
comx: "x" can be any number from 1 to 4, depending on the port the null modem cable is attached to.
b=baud rate (110, 150, 300, 600, 1200, 2400, 4800, 9600, 19200) p=parity (e,o for "even" and "odd". Other options
available, but they do not match T100/200 options)
d=data (number of dat bits - can be 5,6,7,8. Use 7 with the T100/200)
s=stop (number of stop bits - 1,1.5, or 2. Use 1 with T100/200) r=retry (I've not tried playing with this one)
Given the restrictions on the T100/200 communications parameters, and the fact that using even or odd parity is arbitrary,
the generic PC communications parameter set command is (the retry parameter doesn't have to be specified):
mode comx: b,e,7,1
with x and b being adjustable.
b) T100/200 Communications Parameters:
The generic TANDY 200 communications parameter set command ("Stat") has 9 fields. Note there is a comma between fields 7,8
and 8,9. The T100 comm parameters are the same (I beleive) except there are no fields 6 and 7.
1st character:
M : 300 baud modem is the communications port
For the following, the communications takes place through the RS-232 port:
1 = 75 baud, 2 = 110, 3 = 300, 4 = 600, 5 = 1200, 6= 2400
7 = 4800, 8 = 9600, 9 = 19200
2nd character:
7 = 7 bit character length
8 = 8 bit character length (don't be fooled. You can't send 8 bit data)
3rd Character: Parity:
E = Even, O = Odd, N = None, I = Ignore
4th Character:
Stop bits: 1 or 2
5th Character:
Xon/Xoff data enable/disable:
E = Enable, D = Disable
6th Character:
Control code filter:
I = Ignore control codes, N = Normal
7th Character:
Line Feed for incoming data only (not outgoing):
N = C/R = C/R
I = C/R = C/R + L/F
(comma)
8th character:
Modem Mode:
O = Originate Mode, A = Answer Mode
(comma)
9th Character(s):
10, 20, or T for 10, 20 pps pulse dialing, or tone dialling.
The generic parameter set command for the T100/200 is
B7E1ENN for the T200 (last two fields not necessary)
B7E1E for the T100
where "B" can take on any value from 1 to 9 (as described above) to match the PC communications parameters.
_____________________________________________________________________________________________________________________
I waive any claims against using or modifying the above programs and appeal to standard disclaimers regarding the use of
the programs and this information. I hope that this, as a distillation of my satisfactory experience with the T200 serves
as a complete guide and utility for TANDY to PC file exchanges.
Truly,
Kent Nickerson
nickerso@mcmaster.ca