# USB Relay Kernel Driver

> A Linux kernel driver and CLI for USB relay boards.

- Period: Oct 2025 – Dec 2025
- Status: shipped
- Stack: C, Linux Kernel, USB, FTDI, Make
- Repository: https://github.com/ethandom/SainSmart5VUSBRelayDriver

## Highlights

- Kernel module that binds to the board's FTDI FT232R chip and exposes each board as /dev/usbrelayN, with a one-byte mask ABI that drives all 8 channels.
- Enables FTDI bit-bang mode with vendor USB control requests, so all 256 output states fit in a single byte write.
- Handles hot-plug through probe/disconnect, endpoint discovery, and bulk transfers with 1 s timeouts.
- Supports up to 4 boards at once, with IDA minor allocation, a mutex per device, and leak-free cleanup on every error path.
- Includes relayctl, a user-space CLI that turns commands like "set 1 on" into bit masks, with a functional test script.

## Metrics

| Metric | Value | Note |
| --- | --- | --- |
| Channels | 8 | per board |
| Boards | 4 | max concurrent |
| States / byte | 256 |  |
| Transfer timeout | 1 s |  |
