-
Notifications
You must be signed in to change notification settings - Fork 78
Apple II SP over SLIP
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:
- SLIP frames allow to detect packet boundaries without parsing the (variable sized) packets.
- 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.
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
| 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
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
| [N] | Block Data (if Status == 0x00) |
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status |
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
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 |
| 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 |
| 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
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
Example
AppleWin -> FujiNet c0 65 06 07 c0
FujiNet -> AppleWin c0 65 00 c0
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
Example
AppleWin -> FujiNet c0 6c 07 07 c0
FujiNet -> AppleWin c0 6c 00 c0
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 |
| 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 . .
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
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 |
| Size | Content |
|---|---|
| 1 | Request Sequence Number |
| 1 | Status Code |
Copyright 2024 Contributors to the FujiNetWIFI project.
Join us on Discord: https://discord.gg/7MfFTvD
- Home
- What is FujiNet?
- The Definition of Done
- Board bring up for FujiNet Platform.IO code
- The Complete Linux CLI Guide
- The Complete macOS CLI Guide
- Development Env for Apps
- FujiNet-Development-Guidelines
- System Quickstarts
- FujiNet Flasher
- Setting up a TNFS Server
- FujiNet Configuration File: fnconfig.ini
- AppKey Registry - SIO Command $DC Open App Key
- CP-M Support
- BBS
- Official Hardware Versions
- Prototype Board Revisions
- FujiNet Development Guidelines
- Atari Programming
- Apple Programming
- C64 Programming
- ADAM Programming
- Testing Plan
- Hacker List
- FujiNet VirtualMachine