CompuServe "B" Protocol CompuServe "B" Protocol June 18, 1980 Key * not in TRS-80 videotex version, but required if a printer is to be used ** not in TRS-80 videotex version, but required if the system has high resolution graphics capabilities CompuServe "B" Protocol PAGE 2 Purpose: The CompuServe "B" Protocol is used to provide an error detecting and correcting means of exchanging information between a remote terminal or computer and a CompuServe host computer. Under the CompuServe "B" protocol the following control sequences are defined: This sequence requests the remote device to identify itself to the host by returning an ASCII string as follows: #name,options where name = name of the terminal (eg. GTB) and options identify the specific protocol elements which are supported (eg. B for CompuServe "B"). The # signifies that the remote is a terminal rather than a computer. If the remote is a computer, then the reply string is: lo,hi,hardware,ops,datamodes where lo and hi are the lowest and highest hex RAM locations; hardware identifies the specific mainframe (eg. TRS80 Level II); ops indicates the operating system (eg. TRSDOS 2.2); datamodes indicate the types of data exchanges supported (eg. B = direct to BASIC, D = direct to disk). Appendix A lists the currently recognized responses. CompuServe "B" Protocol PAGE 3 This is the error free data transmission sequence. The various fields are as follows: # = block number, ASCII 0 - 9 command = what to do with the text = transparent data The transparancy rule is to replace any control character within the or by the sequence . Thus, control-A (01H) becomes . Transparancy is used to allow all sequences of 8-bit data to be sent unambiguously over the communications link. On some communication systems, such as Tymnet, certain control characters invoke control functions on that link. ETX = ASCII End-of-text character (03H) checksum = a value computed as follows: The checksum is initialized to zero. Then for each character, starting with , the checksum is rotated left one bit, the new character is added, and if there is a carry, an extra one is added in. The following Z80 code calculates the checksum: LD A,C ; C holds checksum RCLA ADD A,B ; New byte is in B ADC A,0 ; Add possible carry LD C,A ; Store updated checksum The checksum is computed from real data only, not from any transparency sequences. This checksum algorithm is used because it will detect spurious nulls and even-numbers of identical bit changes. The maximum block length (including initial DLE and final checksum) is 512 characters. If the terminal does not detect an ETX within this length, the ETX has been lost due to line noise, and the block is bad. The host-to-remote field is as follows: CompuServe "B" Protocol PAGE 4 = Read data according to : = read single character response = read line of data terminated by

= read contents of page n The response to an command is a block back to the host with a command of (for "here it is"). The field is optional, and is present, the text is displayed on the bottom line of the screen.

= store this data on page n = character set information = make page n to be the current display page. <1> = enable encryption The user's terminal will prompt for an encryption key, which will be stored locally only, never transmitted. The details of the encryption algorithm remain to be specified. <0> = disable encryption <1> = enable data compression <0> = disable data compression Details of the data compression algorithm remain to be defined. In the event that a particular command cannot be handled by the remote computer, then the response of: is returned to the host, where is: = not implemented = capacity problem (not that many pages) CompuServe "B" Protocol PAGE 5 Handshaking By "handshaking" is meant the exchange of control signals between the remote device and a host computer. there are three possible signals returned upon completion of a block (ie, ETX sensed) as follows: ACK - positive acknowledgement () WACK - positive acknowledgement (<;>) NAK - negative acknowledgement () The ACK is returned if a valid block has been received; that is, the checksum agrees, the block number is as expected, and the command is recognized. If a valid block has been received, but the receiver cannot accept any more data, then a WACK is returned. The NAK is returned if the data block is invalid for any reason. If a WACK is returned, the host must wait for a specified time (transmit timeout) and send an (05 hex). The receiver then responds either with a valid ACK on the last corectly received block or another WACK. In addition to handshaking, it is necessary to define time-outs which allow the protocol to continue to function even if some control sequences get garbled. When the last character of a sequence has been transmitted, the sender initiates a 1-second timer. Note that it is necessary for the host computer to also take transmission time into account. If neither an ACK, WACK, or NAK has been received at the end of this time period, the sender issues an . When the remote receives a valid sequence, the block number is compared with the expected block number; if they match, an ACK or WACK is returned and the data is released to be processed. If the block number is one less than the expected number, the the receiver issues an ACK or WACK and ignores the received data because it has already been processed. The sender will attempt 10 retransmissions of an sequence before aborting its attempts and switching back to non-protocol communications. The same handshaking is utilized when the remote sends a reply to an "R" command from a sequence. CompuServe "B" Protocol PAGE 6 Summary of Protocol Control Characters begins an error-correcting data block terminates the body of a sequence <@ thru _> within the text of a block, signifies a transparent control character <#> informs the sender that a valid received <;> signifies that a valid block has been received, but the receiver is unable to receive more data. an incorrect block has been received sent when the sender has not received a response to a block, or after a time-out following receipt of a <;> APPENDIX A Responses The CompuServe "B" Protocol includes an sequence which informs the remote computer/terminal to respond with an ASCII string which identifies the computer/terminal and indicates what options, if any, are supported. The format of the response is as follows: #name,options where: "#" signifies the computer/terminal is compatible with the "B" protocol "name" identifies the manufacturer and hardware. The form of the name is two letters for the manufacturer and a number for the hardware. Current names are: RS1 = TRS-80 Level 1 RS2 = TRS-80 Level 2 RS3 = TRS-80 Model 2 RS4 = Tandy Videotex "options" indicate wheat optional features are present in the computer/terminal. The following options are currently defined: CC Cursor control; supports the following escape sequences: A = Cursor up B = Cursor down C = Cursor right D = Cursor left H = Home cursor to upper left J = Clear screen to end of page K = Clear screen to end of line Y = position cursor j = clear screen and home cursor (Form feed also does this) CW Has wide character mode. This implies the following escape sequences: Responses PAGE A-2 l = use wide characters m = use normal characters CS Has standard color control CE Has extended color control; implies and supported G4 Has 2x2 semigraphics; implies <4> supported GH Has hi-resolution graphics (256x192); implies supported GM Has medium resolution graphics (128x96); implies supported HC Has hard-copy printer; implies the following controls are also supported: = disable display = enable display = enable printer = disable printer Also implies and are recognized by keyboard input and treated as if they were received from the host computer. PA Supports "A" protocol error-correcting data transmission PB Supports "B" protocol error-correcting data transmission PL Supports the "L" Protocol for loading code segments APPENDIX B Videotex Escape Sequences The following escape sequences are defined to be emulated by all VIDEOTEX compatible software. Unmarked escape sequences are reserved by CompuServe Incorporated for future expansion. In each case, the given character is assumed to be prededed by an escape character (33 octal). It is assumed that the terminal is initially operating in a "dumb" mode, that is, like a Teletype. Only after the host determines that the device is running an emulator, and after getting a valid response to an , will specific features be enabled by the host. Char Octal equiv 0 - 100 Not defined A 101 cursor up B 102 cursor down C 103 cursor right D 104 cursor left E 105 F 106 G 107 Graphics mode control: <4> = SG 4 Data formats: bit 7 6 5 4 3 2 1 0 +-+-+-+-+-+-+-+-+ !0!x!x!x!x!x!x!x! = ASCII character +-+-+-+-+-+-+-+-+ !1!a!b!c!d!e!f!g! = graphics character +-+-+-+-+-+-+-+-+ For Graphic characters, bits "abc" define the color as follows: 000 = green 001 = yellow 010 = blue 011 = red 100 = buff or white 101 = cyan 110 = magenta 111 = orange Videotex Escape Sequences PAGE B-2 bits "defg" define the graphic character by having a 1 bit for each picture which is to assume the color given by bits "abc". The "defg" bits map to picture elements as follows: +-+-+ !d!e! +-+-+ !f!g! +-+-+ ** - Hi resolution graphics (256x192). Screen will clear; data will be in "run length encoded" format, where the data is transmitted as pairs of characters. The first character of a pair indicates a number of background bits and the second a number of foreground bits. Each character of a pair will be the count plus 40 octal; no count may exceed 127. Thus the ASCII sequence "0A" indicates sixteen background bits and 33 foreground bits. Movement to the next display line may be done by either a sequence of " " (i.e., 0 for background and forground) or by taking a line to the right-hand margin (256). ** = Medium resolution graphics (128x96) This mode is identical to the except for the resolution. The same run-length encoding is used. = return to "normal" mode (text only) H 110 Home cursor I 111 Interrogate emulator: Emulator returns an ASCII string to host as follows: #name,options where the # identifies the device as a VIDEOTEX compatible unit, name is spcific name of the terminal (eg. VIDTEX), and options gives a list of features supported (eg. G4 for SG4, GH for standard hi res graphics, CS for standard colors, P for has printer, H for hardware specific options, B implies CompuServe "B" protocol support). Videotex Escape Sequences PAGE B-3 If the H option is present, it must follow any standard options, and may itself be followed by manufacturer defined options. Such features must only be activiated by means of an sequence defined by the manufacturer. CompuServe Incorporated reserves the right not to support any such features in our host-level software. A typical response to an might be: #XYZ,G4,GH,CS For use by Tandy, "B" protocol Specific responses to the must be arranged by negotiations with CompuServe Incorporated in order to maintain compatiblility with our host-level software. A list of currently defined responses may be found in Appendix A of the this document. Videotex Escape Sequences PAGE B-4 K 112 Clear to end of line 114 - 130 Unused Y 131 Position cursor () 132 - 140 Unused a 141** set alternate foreground/background colors: (These colors apply to GRAPHIC, not text) <#>... where # = number of color pairs to set pair-1 = foreground/background colors (see "c" below) b 142 c 143** Set foreground/background colors: (These colors apply to TEXT only, not graphics) where pair = color pair as follows bit 7 6 5 4 3 2 1 0 +--+--+--+--+--+ !Chrom !Chrom! +--------+-----+ ! Fore ! Back! +--------+-----+ CHROM = Color: 0 = green 1 = yellow 2 = blue 3 = red 4 = buff 5 = cyan 6 = magenta 7 = orange 8 = black 9 = white 10-15 reserved Note: It is up to the emulator to map the given colors into those actually available. d 144 e 145** disable display f 146** enable display Note: and may be used in conjunction with and printer control to direct output to the printer without displaying it.