Protocol Specification

The Disc Stakka controller typically listens on the following port

localhost:1501

Comms with the localhost is performed through a series of well structured packets. Actually, there are only three. They are:


Enumerate serials (Command 0x00)

Send: 00
      Command

Recv: NN NN NN NN   DD DD DD DD   DD DD DD DD   .......
      Num Devices   Serial 1      Serial 2

Description: This command obtains a list of devices that are registered with the server. 
             The serial numbers will be used for all other packet comms.

Read From Device (Command 0x01)

Send: 01        DD DD DD DD
      Command   Serial

Recv: RR RR RR RR   XX XX XX XX XX XX
      Return Value  6 Byte Data Block

Description: This command reads a block of data from the specified device.
             The structure of the data block is defined later.

Write To Device (Command 0x02)

Send: 02        DD DD DD DD   XX XX XX XX XX XX XX
      Command   Serial        7 Byte Data Block

Recv: RR RR RR RR
      Return Value

Description: This command writes a block of data to the specified device.
             The structure of the data block is defined later.

It should be noted that all the four byte integers are sent LSB first.

The structure of the data blocks are as follows:


Read data block (6 bytes)

1 Byte MessageID
1 Byte CommandCode
1 Byte X1
1 Byte X2
1 Byte X3
1 Byte X4

Write data block (7 bytes)

1 Byte MessageID
1 Byte CommandCode
1 Byte X1
1 Byte X2
1 Byte X3
1 Byte X4
1 Byte X5

Breakdown:

Unless otherwise specified, all values here are in hex

Command Code 01
Init? Ready to start operation?
Send: X1-X5 = 0 Unused?
Recv: X1 = 0 Unused?
      X2-X3 = Status flags?
      X4 = 0 Unused?
Desc: Only noticed when the unit is first initialised.

Command Code 03
??
Send: X1-X5 = 0 Unused?
Recv: X1 = 08 ??
      X2-X4 = 0 Unused?
Desc: This was seen when performing maintenance.
      Probably clears errors when trying to eject a slot with no disc.
      Should be followed by command code 14.

Command Code 04
Move carousel
Send: X1 = pos (0-64)
      X2 = eject (0 no, 1 eject)
      X3-X5 = 0 Unused?
Recv: X1 = pos (0-64)
      X2-X3 = status flags
      X4 = 0 Unused?
Desc: This will rotate the carousel to positions 0 to 0x64 (100 decimal).
      Yes, there are 101 (decimal) slots in the carousel.
      Slot 0 is used for alignment and will not accept a disc.
      If you do attempt to make it accept a disc prepare to get it jammed.

Command Code 05
Retract Disc
Send: X1-X5 = 0 Unused?
Recv: X1-X4 - 0 Unused?
Desc: Allows the unit to pull back a disc after it was ejected,
      but not removed from the bay.

Command Code 06
Set LED Flash rate
Send: X1 = On time (in approx 0.03sec units)
      X2 = Period (in units)
      X3-X5 = 0 Unused?
Recv: Unknown! (Never checked! Guess I never needed to.)
Desc: The LED is on for X1 time units, and off for (X2-X1) units.
      Hence if X1 >= X2 then the LED will always be on.

Command Code 0A
Diagnostics? Startup?
Send: X1-X5 = 0 Unused?
Recv: X1-X3 = 0 Unused?
      X4 = Seen 00 (when unit 0)
           Seen BF (when unit 1 when serial ending in BF)
           Seen AF (when unit 2 with serial ending in AF)
           Seen 6A (when unit 3 with serial ending in 6A)
           Appears to carry last byte of serial if unit pos not 0
Desc: Seen when the proprietary driver first communicates with a
      newly connected device.

Command Code 14
??
Send: X1-X5 = 0 Unused?
Recv: X1 = pos
      X2-X3 = status flags????
      X4 = 0 Unused?
Desc: This was seen when performing maintenance.
      Probably clears errors when trying to eject a slot with no disc.
      Only seen immediately following command code 03.

Command Code 1A
Request for some info?
Send: X1-X5 = 0 Unused?
Recv: X1-X4 = Seen 01 04 23 17
Desc: X1-X3 unknown (but they must have some significance...)
      X4 appears to be boot block version.

Command Code 1B
Request for some info?
Send: X1-X5 = 0 Unused?
Recv: X1-X4 = Seen 00 02 00 79
Desc: X1 unknown.
      X2 appears to be hardware version.
      X3-X4 appears to be firmware revision. 02.17.0079)

Command Code 1C
Request serial number
Send: X1-X5 = 0 Unused?
Recv: X1-X4 = Serial number
Desc: Obtains the devices serial number.
      It is NOT present where it should be in the USB specs.
      This is probably because the specs dont allow for units to
      "stack" on top of each other (but what do I know?)

Command Code 1D
Accept CD
Send: X1-X5 = 0 Unused?
Recv: X1 = pos
      X2-X3 = status flags
      X4 = 0 unused?
Desc: Tells the unit to accept the disc that was recently inserted.

Command Code CC
Uninitialised unit
Send: This command code is not sent to the unit
Recv: X1-X4 = Seen DD EE FF 00
Desc: Appears to indicate a freshly connected unit that needs to
      be acknowledged before it can be used.
      Note, this will be handled by the core so you should never
      see this response

The status flags are still a bit of a mystery. The following information may or may not be correct. However everything _seems_ to work ok.

Status flags

Bit Order:  0  1  2  3    4  5  6  7    8  9 10 11   12 13 14 15

 0 = 1 Unit busy
 1 = ? Ok?
 2 = ? Ok?
 3 = 1 CD detected in slot
 4 = New CD in slot awaiting ack
 5 = Timeout awaiting ack, cd ejecting, in bay
 6 = Timeout awaiting ack, cd removed from bay. Old errval
 7 = 
 8 = 1 Unit Busy
 9 = 
10 = 
11 = 
12 = 
13 = 
14 = 
15 = ? Ok?