Skip to content

Apple II SP over SLIP

Norman Davie edited this page Sep 9, 2024 · 30 revisions

SmartPort over Serial Line Internet Protocol (SP-over-SLIP) is related to Apple II Protocol Converter Bus (CBus). From a high-level perspective it transports almost the same data as CBus, but the actual coding of the data is pretty different. The primary difference in the transported data results from the fact that SP-over-SLIP runs on a point-to-point connection while CBus runs - nomen est omen - on a bus.

SP-over-SLIP can be used on any medium providing a transparent, duplex, lossless byte stream. Examples are a TCP connection or a USB CDC-ACM connection.

SP-over-SLIP strictly consists of request/response packets. Every packet is encapsulated in a SLIP frame for two reasons:

  1. SLIP frames allow to detect packet boundaries without parsing the (variable sized) packets.
  2. SLIP frames allow to detect incomplete packets caused by an Apple II Reset during packet transmission.

Every request/response packet starts with a Request Sequence Number for this reason: An Apple II Reset after sending a request but before receiving the response makes the response stay in some TCP or USB related buffer. Now the next send request / receive response sequence receives that wrong, old response. The Request Sequence Number allows to detect (and discard) that response.

A SLIP message consists of a message enclosed by $C0

  • if the contents of the message contains a $C0, transmit $DB $DC instead
  • if the contents of the message contains a $DB, transmit $DB $DD instead

Example dummy message

message:         01 DB    49 C0    15
message sent: C0 01 DB DD 49 DB DC 15 C0

Note that on the Apple II implementation, all block sizes are 512 bytes, but the interface is generic, so the size must be specified in the request.

Status Request (0x00)

The Status call returns information about a particular device or about the SmartPort itself. Only Status calls that return general information are listed here.

Size Content
1 Request Sequence Number
1 Command Number (0x00)
1 SmartPort Unit Number
1 Status Code
Status Code Meaning
$00 Return device status
$01 Return device control block
$02 Return newline status (character devices only)
$03 Return Device Information Block (DIB)

Example SLIP Status Request Message

                          Sequence Number
                          |  Status Command
                          |  |  SmartPort
                          |  |  |  Status Code
                          |  |  |  |
AppleWin -> FujiNet : c0 12 00 01 03 c0 

Status Response

Size Content
1 Request Sequence Number
1 Status Code
[n] Status List (if Status == $00)

General Status Byte

Bit Meaning
7 0=Character Device 1=Block Device
6 1=Write Allowed
5 1=Read Allowed
4 1=device on line or disk in drive
3 1=format allowed
2 1=media write-protected (block devices only)
1 Reserved; must=0
0 1=Device currently open (Character devices only
Type Subtype Device
$00 $00 Apple II memory expansion card
$01 $00 Apple 3.5 drive
$01 $40 UniDisk 3.5
$02 ProFile™ hard disk
3-9 Reserved
$0A 5.25-inch disk
B-F Reserved

Example Status Response Message

FujiNet -> AppleWin : c0 12 00 fc 18 01 00 0e 46 55 4a 49 4e 45 54 5f 44 49 53 4b 5f 30 20 20 01 40 01 0f c0
                          |  |  |  |     |  | |---16 bytes always---------------------------|  |  | |   | 
                          |  |  |  |     |  | |F  U  J  I  N  E  T  _  D  I  S  K  _ 0      |  |  | Firmware
                          |  |  |  |     |  String Length                                      |  | Version
                          |  |  |  |    /                                                      |  Subtype
                          |  |  |  Blocks on device (3 bytes)                              Device Type
                          |  |  General Status Byte
                          |  Status Code
                          Sequence Number

ReadBlock Request (0x01)

The ReadBlock call reads one 512-byte block from the block device specified by the unit number.

Size Content
1 Request Sequence Number
1 Command Number (0x01)
1 SmartPort Unit Number
2 Block Size*
3 Block Number

ReadBlock Response

Size Content
1 Request Sequence Number
1 Status Code
[N] Block Data (if Status == 0x00)

WriteBlock Request (0x02)

The WriteBlock call writes one 512-byte block to the block device specified by the unit number.

Size Content
1 Request Sequence Number
1 Command Number (0x02)
1 SmartPort Unit Number
2 Block Size*
3 Block Number
N Block Data

WriteBlock Response

Size Content
1 Request Sequence Number
1 Status

Format Request (0x03)

The Format call formats a block device. The formatting performed by this call is not linked to any operating system; it only prepares all blocks on the medium for reading and writing. Operating-system-specific catalog information, such as bit maps and directories, are not prepared by this call.

Size Content
1 Request Sequence Number
1 Command Number (0x03)
1 SmartPort Unit Number

Format Response

Size Content
1 Request Sequence Number
1 Status Code

Control Request (0x04)

The Control call sends control information to the device. The information may be either general or device specific.

Size Content
1 Request Sequence Number
1 Command Number (0x04)
1 SmartPort Unit Number
n Control List

FujiNet Specific Control List

Command Byte Content
'O' 0 Open
1-2 payload size
3 mode read, write or both
4 translation
5... url
'C' 0 Close
1-2 payload size of zero
'R' 0 Read
1-2 payload size
3... data
'W' 0 Write
1-2 payload size
3... data
'A' 0 Accept
1-2 payload size $00
'D' 0 udp destination
1-2 payload size
3... url

Control Response

Size Content
1 Request Sequence Number
1 Status Code

Example Message

AppleWin ->  FujiNet c0 66 04 07 4f 2b 00 0c 80 4e 3a 48 54 54 50 3a 2f 2f 61 70 69 2e 6f 70 65 6e 2d 6e 6f 74 69 66 79 2e 6f 72 67 2f 69 73 73 2d 6e 6f 77 2e 6a 73 6f 6e c0 
                      .  f  .  .  O  +  .  .  .  N  :  H  T  T  P  :  /  /  a  p  i  .  o  p  e  n  -  n  o  t  i  f  y  .  o  r  g  /  i  s  s  -  n  o  w  .  j  s  o  n  . 

 FujiNet -> AppleWin c0 66 00 c0 

Init Request (0x05)

The Init call causes SmartPort to execute its initialization sequence, causing a hardware reset of all devices and assigning a unit number to each device. This call is not made to a specific unit; rather, it is made to the SmartPort as a whole. This call is executed automatically on system startup or forced cold reset.

Size Content
1 Request Sequence Number
1 Command Number (0x05)
1 SmartPort Unit Number

Init Response

Size Content
1 Request Sequence Number
1 Status Code

Open Request (0x06)

The Open Request call prepares a character device for reading or writing.

Size Content
1 Request Sequence Number
1 Command Number (0x06)
1 SmartPort Unit Number

Open Response

Size Content
1 Request Sequence Number
1 Status Code

Example

AppleWin ->  FujiNet c0 65 06 07 c0 
 FujiNet -> AppleWin c0 65 00 c0 

Close Request (0x07)

The Close call tells a character device that a sequence of read or write operations has ended. For a printer, this call could have the effect of flushing the print buffer.

Size Content
1 Request Sequence Number
1 Command Number (0x07)
1 SmartPort Unit Number

Close Response

Size Content
1 Request Sequence Number
1 Status Code

Example

AppleWin ->  FujiNet c0 6c 07 07 c0 
 FujiNet -> AppleWin c0 6c 00 c0 

Read Request (0x08)

The Read Request reads the number of bytes specified by the byte count parameter.

Size Content
1 Request Sequence Number
1 Command Number (0x08)
1 SmartPort Unit Number
2 Byte Count
3 Address

Read Response

Size Content
1 Request Sequence Number
1 Status Code
[n] Read Data (if Status == $00)

Example

AppleWin ->  FujiNet c0 6b 08 07 0b 00 00 00 00 c0 
 FujiNet -> AppleWin c0 6b 00 31 37 32 35 38 38 34 32 36 30 0a c0 
                      .  k  .  1  7  2  5  8  8  4  2  6  0  .  . 

Write Request (0x09)

The Write call writes the number of bytes specified by the byte count to the device specified by the unit number.

Size Content
1 Request Sequence Number
1 Command Number (0x09)
1 SmartPort Unit Number
2 Byte Count
3 Address
n Write Data

Write Response

Size Content
1 Request Sequence Number
1 Status Code

Reset Request (0x0A)

The Apple II side of SP-over-SLIP is supposed to be implemented using some processor beside the 6502 main processor. This allows the Apple II - in contrast to CBus - to inform the connected devices about a 6502 reset. This can i.e. have a modem drop an active connection or a printer eject a partially printed page.

Size Content
1 Request Sequence Number
1 Command Number ($0A)
1 SmartPort Unit Number

Reset Response

Size Content
1 Request Sequence Number
1 Status Code

Clone this wiki locally