Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Serial transport

Most older dive computers, and many newer ones behind a USB cable, speak an asynchronous serial protocol. The host side is either a real UART, an OS-provided virtual port (USB-serial bridge or CDC-ACM with an OS driver), or a USB-serial bridge driven directly by the host (WebUSB, Android without kernel drivers). This document defines the abstract serial model the family documents use, and then shows how to implement it on top of raw USB for the four bridge types found in dive computer cables.

1. Abstract serial model

A serial transport provides:

OperationMeaning
configure(baud, data_bits, parity, stop_bits, flow)Set line coding. Families use 5..8 data bits only as 8; parity none/odd/even; 1 or 2 stop bits; flow control is always none in this specification.
set_dtr(on), set_rts(on)Drive the modem-control outputs. “on” means the line is asserted (RS-232 positive voltage, TTL low on most bridge chips).
set_break(on)Hold TX in the spacing (break) state while on.
purge(rx, tx)Discard bytes buffered in the host and, where possible, in the bridge chip.
write(bytes)Send all bytes. Writes are not framed; the device sees a continuous byte stream.
read(n, timeout)Return up to n bytes; return fewer (possibly 0) when timeout expires.
sleep(ms)Delays are part of several protocols (wake-up sequences, inter-command gaps).

1.1 Timeouts

A family states a read timeout in milliseconds. Its meaning is: the total time a single read(n) call may wait for all n bytes. A read that times out MUST report how many bytes did arrive, because several protocols use “fewer bytes than asked” as an end-of-data signal or retry trigger. A timeout of 0 means “return what is buffered now”; an infinite timeout is never needed by any family. Typical values: 1000 ms for interactive command/response protocols, 3000-5000 ms for protocols where the device prepares data before answering.

Confidence: likely.

1.2 DTR and RTS

Many interface cables are powered or switched by the modem-control lines:

  • Some cables take power for the IR or level-shifter circuitry from DTR (and sometimes RTS); the family then asserts DTR at open and keeps it asserted.
  • Some half-duplex single-wire cables use RTS as a transmit-enable or direction line; the family toggles RTS around each write.
  • Some devices use a DTR or RTS edge as a wake-up or reset signal.

Families MUST state the initial level of both lines after configure, and every later change. Implementations MUST NOT rely on the OS default line state (it differs between operating systems and chip drivers).

Note on terminology: some host APIs model these lines with inverted booleans. In this specification “DTR on” always means the line is asserted, whatever the host API calls it.

Confidence: likely.

1.3 Break

A small number of families (ReefNet Sensus Pro, Cochran) signal “wake up” or “start” by holding a break condition for a stated time (for example 16 ms) or for the duration of a handshake read. Implementations without break support cannot talk to these devices.

Confidence: likely.

1.4 Purge

Before a command exchange, families usually purge both directions to drop stale bytes (for example heartbeat bytes or a previous partial answer). When the bridge chip has its own FIFOs (FTDI, CP210x), a purge SHOULD also be sent to the chip (requests below); purging only the host buffer can leave up to one USB packet of stale data.

Confidence: likely.

1.5 Echo on single-wire cables

Several IR and single-wire cables loop the host’s transmitted bytes back into its receiver. Families that use such cables say so; the host then reads and discards exactly as many bytes as it wrote before reading the answer. This is a property of the cable, not of the serial transport, but it is common enough to note here.

Confidence: likely.

1.6 Overview of line settings by family

For orientation only; the family documents are normative.

BaudFormatFamilies (initial DTR / RTS where set)
12008N2Suunto Eon, Suunto Solution (RTS off)
1200 → 48008N1Cressi Edy family (DTR on, RTS off; rate switched during session)
24008O1Suunto Vyper family (DTR on; RTS toggled as direction line)
48008N1Citizen Aqualand (DTR pulsed), Zeagle N2iTiON3
96008N1Suunto Vyper2/D9 (DTR on, RTS toggled), Mares Nemo/Darwin (DTR on, RTS on), Oceanic VT Pro and Veo 250 (DTR on, RTS pulsed), Uwatec Memomouse (DTR toggled), Dive Rite NiTek Q, Liquivision (DTR off, RTS off)
9600 → 1152008N1Suunto D9 family (auto-detected), HW OSTC 2 (19200 or 115200 probed)
9600 then 115200 / 8500008N2Cochran (break used as wake-up)
192008N1Uwatec Aladin (DTR on, RTS off), ReefNet Sensus and Sensus Pro (break)
384008N1Mares Puck (DTR off, RTS off), Oceanic Atom 2 family (DTR on, RTS pulsed)
576008N1Uwatec Smart over serial cradles (Meridian, Chromis, Mantis)
1152008N1Oceanic Atom 2 family fast models (VTX, i750TC, Pro Plus X, i770R), HW OSTC/OSTC 3, Shearwater (over serial), Cressi Leonardo (DTR, RTS set), Cressi Goa (DTR off, RTS off), Ratio/DiveSystem iDive, ReefNet Sensus Ultra, McLean Extreme, Tecdiving, Seac Screen, Deep Six, Divesoft
1152008E1Mares Icon HD family (DTR off, RTS off)
4608008N1Sporasub SP2 (DTR on, RTS off)

One source reports that the Mares Icon HD CDC cradle (FFFF:0005) is opened at 256000 baud with no parity; another configures the same family at 115200 8E1. Both are recorded; see open questions.

Confidence: likely (single reference implementation per row; the Mares 256000/115200 split is uncertain).

2. USB-serial bridges driven directly

When the host has no OS driver (WebUSB, Android), it MUST speak the bridge chip’s own control protocol. All requests below are USB control transfers with the 8-byte setup packet bmRequestType, bRequest, wValue (LE), wIndex (LE), wLength (LE). Data is moved with bulk transfers on the interface’s bulk IN and bulk OUT endpoints (find them from the interface descriptor; do not hard-code endpoint numbers).

2.1 FTDI (FT232R, FT232BM, FT-X; VID 0403)

Interface 0, one bulk IN and one bulk OUT endpoint. All requests are vendor requests to the device: bmRequestType = 0x40 (host to device) or 0xC0 (device to host). wIndex carries the port number: 0 (or 1) on single-port chips; on multi-port chips port A = 1, B = 2, …

PurposebRequestwValuewIndexData
Reset port0x000x0000portnone
Purge RX buffer0x000x0001portnone
Purge TX buffer0x000x0002portnone
Modem control0x01see belowportnone
Flow control0x020x0000 = none (0x0100 RTS/CTS, 0x0200 DTR/DSR, 0x0400 XON/XOFF)portnone
Baud rate0x03divisor low 16 bitsdivisor bit 16 in bit 0 (single-port) / (port) | bit16<<8 (multi-port)none
Line format0x04see belowportnone
Modem status (read)0x050port2 bytes (same layout as the RX status header)
Latency timer0x09milliseconds (1..255)portnone
Read latency timer0x0A (0xC0)0port1 byte

Modem control wValue: high byte is a write-enable mask, low byte the new state; bit 0 = DTR, bit 1 = RTS. DTR on = 0x0101, DTR off = 0x0100, RTS on = 0x0202, RTS off = 0x0200; both at once, e.g. 0x0303.

Line format wValue:

BitsMeaning
0-7data bits (7 or 8)
8-10parity: 0 none, 1 odd, 2 even, 3 mark, 4 space
11-13stop bits: 0 = 1, 1 = 1.5, 2 = 2
141 = transmit break

So 8N1 = 0x0008, 8O1 = 0x0108, 8E1 = 0x0208, 8N2 = 0x1008. Break on = the current format value with bit 14 set; break off = without it.

Baud-rate divisor. The FT232B/R baud generator divides 3 MHz by n + f, where n is a 14-bit integer and f one of 0, 1/8, 2/8, …, 7/8. The three fraction bits are not in numeric order:

f00.1250.250.3750.50.6250.750.875
code (3 bits)03241567

Encoded divisor = n | (code << 14) (17 bits). Bits 0-15 go into wValue, bit 16 into wIndex as stated above. Special cases: encoded divisor 0 selects 3 Mbaud and 1 selects 2 Mbaud. Algorithm: d8 = round(24 000 000 / baud) (the divisor in eighths), n = d8 >> 3, code = table[d8 & 7].

BaudwValuewIndex bitActual rate
12000x09C401200
24000x04E202400
48000x027104800
96000x413809600
192000x809C019200
384000xC04E038400
576000xC034057554
1152000x001A0115385
2304000x000D0230769
4608000x40060461538

The older FT8U232AM uses only two fraction bits; dive computer cables are not known to use it.

Receive status header. Every bulk IN packet starts with two status bytes, then up to wMaxPacketSize − 2 data bytes. Packets are 64 bytes on full-speed chips. The host MUST remove the two status bytes from each USB packet (a single bulk transfer of, say, 512 bytes contains several 64-byte packets, each with its own header). A transfer of exactly 2 bytes carries no data; the chip sends these periodically (every latency-timer period) when idle.

ByteBits
0 (modem status)bits 0-3 reserved (bits 0-3 are 0001 on some chips), 4 CTS, 5 DSR, 6 RI, 7 DCD
1 (line status)0 data ready, 1 overrun, 2 parity error, 3 framing error, 4 break received, 5 TX holding empty, 6 TX empty, 7 RX FIFO error

Latency timer. The chip forwards received data when 62 bytes are buffered or when the latency timer (default 16 ms) expires. Protocols with many small round-trips SHOULD set it to 1-2 ms.

Minimal open sequence: reset (00/0000), set baud (03), set line format (04), set flow control none (02/0000), set DTR/RTS (01) as the family requires, purge RX and TX, optionally set latency timer (09).

Worked example, 9600 8N1, DTR on, RTS off:

H→D control  40 00 0000 0000 0000      reset
H→D control  40 03 4138 0000 0000      9600 baud
H→D control  40 04 0008 0000 0000      8 data bits, no parity, 1 stop bit
H→D control  40 02 0000 0000 0000      no flow control
H→D control  40 01 0101 0000 0000      DTR on
H→D control  40 01 0200 0000 0000      RTS off
H→D control  40 00 0001 0000 0000      purge RX
H→D control  40 00 0002 0000 0000      purge TX

(Setup fields shown as bmRequestType bRequest wValue wIndex wLength, values in hex.)

One reference implementation sends wIndex = 0 for the baud request in all cases and never sets the latency timer or flow control; this works for rates up to 460800 because bit 16 of the divisor is 0 there.

Confidence: verified for the request codes, bit layouts and divisor encoding (FTDI AN232B-05 and the public FTDI register definitions); likely for the open sequence.

2.2 Silicon Labs CP210x (VID 10C4, PID EA60 and others)

Interface 0 (each port of a multi-port CP210x is its own interface), one bulk IN and one bulk OUT endpoint. Requests are vendor requests to the interface: bmRequestType = 0x41 (host to interface) or 0xC1 (interface to host), wIndex = interface number.

PurposebRequestwValueData
Enable / disable UART0x001 = enable, 0 = disablenone
Set baud divisor (legacy)0x013 686 400 / baudnone
Set line control0x03see belownone
Get line control0x04 (0xC1)02 bytes
Set break0x051 = on, 0 = offnone
Set modem handshake (DTR/RTS)0x07see belownone
Get modem status0x08 (0xC1)01 byte
Get comm status0x10 (0xC1)019 bytes (errors, hold reasons, queue lengths)
Purge0x12bit mask, 0x000F = everythingnone
Set flow control0x13016 bytes
Set baud rate0x1E04 bytes, u32le baud

Line control wValue: bits 0-3 stop bits (0 = 1, 1 = 1.5, 2 = 2); bits 4-7 parity (0 none, 1 odd, 2 even, 3 mark, 4 space); bits 8-15 data bits (5..8). So 8N1 = 0x0800, 8O1 = 0x0810, 8E1 = 0x0820, 8N2 = 0x0802.

Modem handshake wValue: bit 0 DTR state, bit 1 RTS state, bit 8 write-enable for DTR, bit 9 write-enable for RTS. DTR on = 0x0101, DTR off = 0x0100, RTS on = 0x0202, RTS off = 0x0200. DTR/RTS can only be driven when flow control does not own them (the power-on default is no flow control).

Purge mask: the four low bits clear the transmit and receive queues (bits 0 and 2 the transmit side, bits 1 and 3 the receive side); 0x000F clears both. On CP2102N a purge also resets the port configuration, so it MUST be followed by re-sending baud and line control.

No status bytes are inserted into the bulk IN stream.

Minimal open sequence: enable UART, set baud rate (0x1E), set line control, set DTR/RTS, purge.

Worked example, 57600 8N1:

H→D control  41 00 0001 0000 0000          enable
H→D control  41 1E 0000 0000 0004  00 E1 00 00   57600 baud (u32le)
H→D control  41 03 0800 0000 0000          8N1
H→D control  41 12 000F 0000 0000          purge all

Variant observed in one reference implementation: the same requests sent with bmRequestType = 0x40 (device recipient) and wIndex = 0. Single-interface CP210x chips accept this; hosts SHOULD use 0x41 with the interface number.

Confidence: verified for request codes 0x03, 0x07, 0x12, the request type 0x41 and the line-control layout (Silicon Labs AN571); likely for the remaining codes and bit masks (taken from a public driver implementation).

2.3 Prolific PL2303 (VID 067B, PID 2303)

Interface 0 has an interrupt IN endpoint (modem status), one bulk IN and one bulk OUT. Line coding and control lines use the CDC-ACM class requests (section 2.4) addressed to the interface (bmRequestType = 0x21, wIndex = 0):

  • SET_LINE_CODING (0x20) with the 7-byte CDC line-coding structure.
  • SET_CONTROL_LINE_STATE (0x22): bit 0 DTR, bit 1 RTS.
  • SEND_BREAK (0x23): wValue = 0xFFFF break on, 0x0000 break off.

Before the first line coding, PL2303 (pre-HXN types) are conventionally initialised with a vendor sequence (bmRequestType 0x40/0xC0, bRequest 0x01): reads of registers 0x8484, 0x8383, writes 0x0404 = 0, 0x0404 = 1, 0 = 1, 1 = 0, 2 = 0x44 (0x24 for the older type). One reference implementation that worked with dive computer cables sent no vendor initialisation and no line coding at all, relying on the chip’s power-on default; that only works for 9600 8N1 devices.

Confidence: likely for the class requests; uncertain for the necessity of the vendor initialisation sequence.

2.4 USB CDC-ACM (class 0x02 communications + class 0x0A data)

The communications interface (class 2, subclass 2) carries class requests and an optional interrupt notification endpoint; the data interface (class 10) carries one bulk IN and one bulk OUT endpoint. Class requests use bmRequestType = 0x21 (host to interface) or 0xA1, wIndex = communications interface number.

PurposebRequestwValueData
SET_LINE_CODING0x2007 bytes
GET_LINE_CODING0x21 (0xA1)07 bytes
SET_CONTROL_LINE_STATE0x22bit 0 DTR, bit 1 RTSnone
SEND_BREAK0x23duration ms; 0xFFFF = until cleared; 0 = clearnone

Line coding: u32le dwDTERate, u8 bCharFormat (0 = 1 stop bit, 1 = 1.5, 2 = 2), u8 bParityType (0 none, 1 odd, 2 even, 3 mark, 4 space), u8 bDataBits.

115200 8N1:  00 C2 01 00  00  00  08
115200 8E1:  00 C2 01 00  00  02  08

CDC-ACM has no purge request; the host purges its own buffers and drains the bulk IN endpoint. Many embedded CDC implementations ignore the baud rate entirely; others (dive computer cradles with a real UART behind them) need it.

Observed device specifics (one source, not confirmed elsewhere):

  • FFFF:0005 (Mares cradle): the host reads the device and configuration descriptors, selects configuration 2, sets line state RTS-only (0x0002), waits 20 ms, clears it (0x0000), then sets line coding 256000 8N1. The data interface is found as the first class-10 interface.
  • 2047:082B: line coding 115200 8N1, no other set-up.

Confidence: verified for the class request definitions (USB CDC 1.2 / PSTN 1.2); uncertain for the device-specific sequences.

2.5 Third-party multi-mode adapters

Some aftermarket USB-to-IR adapters enumerate with the VID:PID of a common bridge chip (10C4:EA60, 066F:4210, 0403:87D0, 0403:6001) but answer FTDI vendor requests and carry a vendor-specific product string. They are not part of any dive computer’s protocol and are out of scope; hosts that want to support them need the adapter vendor’s documentation. When a 10C4:EA60 device does not answer CP210x requests, trying FTDI requests is a reasonable fallback.

Confidence: uncertain.

3. Driver selection

Where a family is reachable through several cable generations, hosts SHOULD try the bridge types in a fixed order and keep the first that opens and accepts line configuration. One reference implementation tries CP210x, then FTDI, then PL2303.

Open questions

  • Mares Icon HD family over the FFFF:0005 CDC cradle: 256000 8N1 or 115200 8E1? Possibly different cradle generations; needs a traffic capture.
  • Whether PL2303-based cables work without the vendor initialisation sequence on all chip revisions.
  • Exact purge-mask semantics on single-port CP210x parts (AN571 wording is ambiguous; the all-bits value is safe).

References

  • libdivecomputer (LGPL-2.1), used as a factual reference; no code copied. https://www.libdivecomputer.org/
  • FTDI, AN232B-05 “Configuring FT232R, FT2232 and FT232B Baud Rates”, https://ftdichip.com/Documents/AppNotes/AN232B-05_BaudRates.pdf
  • FTDI FT232R datasheet, https://ftdichip.com/products/ft232rl/
  • Silicon Labs, AN571 “CP210x Virtual COM Port Interface”, https://www.silabs.com/documents/public/application-notes/AN571.pdf
  • Linux kernel USB-serial drivers (public register definitions for FTDI, CP210x, PL2303), https://github.com/torvalds/linux/tree/master/drivers/usb/serial
  • USB Class Definitions for Communications Devices 1.2 and PSTN subclass 1.2, https://www.usb.org/document-library/class-definitions-communication-devices-12