56 lines
2.4 KiB
Markdown
56 lines
2.4 KiB
Markdown
# MAG160C C SDK (csdk/)
|
|
|
|
Pure C reimplementation of the MAG160C thermal camera SDK, written from the
|
|
recovered protocol (see `analysis/protocol_spec.md` for the full reverse
|
|
engineering report). The previous C++ implementation was archived to
|
|
`analysis/legacy-cpp/`; this tree replaces it.
|
|
|
|
## Layout
|
|
|
|
```
|
|
csdk/
|
|
include/mag160c/mag160c.h public C ABI (error domain, magic codes, frame
|
|
format, temperature API, TCM framing)
|
|
src/
|
|
mag160c_internal.h shared helpers (last-error)
|
|
mag160c_error.c TLS last-error + error names
|
|
mag160c_frame.c 0x1bb1b11b frame parse + streaming assembler
|
|
mag160c_temp.c Calibration / ConvertResponse2Temperature / T2E
|
|
mag160c_tcm.c FTDICommand 0x7e framing + rotate/light builders
|
|
mag160c_ir.c libusb session (link/start/stop/ffc/info)
|
|
mag160c_tables.h T2E + E2TAccQ10 tables (generated from binary)
|
|
tools/mag160c_cli.c CLI: ir-info, ffc, start, stop, tcm-rotate,
|
|
tcm-light, frame-test, temp-test
|
|
tests/ test_frame, test_temp, test_tcm, test_api
|
|
```
|
|
|
|
## Build
|
|
|
|
```
|
|
cmake -B build -S csdk # auto-detects libusb-1.0 via pkg-config
|
|
cmake --build build
|
|
ctest --test-dir build
|
|
```
|
|
|
|
Without libusb-1.0 the IR session APIs return MAG160C_ERR_NOT_SUPPORTED;
|
|
the pure helpers (frame parse, temperature math, TCM framing) and their tests
|
|
work with no dependencies. Threads (pthread) are used when available.
|
|
|
|
## Recovered protocol summary
|
|
|
|
- VID 0x833C, config value 2, interface 0.
|
|
- Commands: EP OUT 0x03, 8-byte packets `{u32 magic, u32 param}` (0x3c-byte
|
|
with 0x38-byte payload for DDT). Response: EP IN 0x82 (0x1000 max, 2000 ms).
|
|
- Magic commands: 0x6bb6b66b/66c prepare, 66d/66e DDT, 66f info, 670 version,
|
|
672 FFC, 673 start, 674 stop, 676/677 set params.
|
|
- Magic responses: 0x5bb5b55b..55f (0x38-byte info blocks / 0x10 pair),
|
|
0x5bb5b57b file header.
|
|
- Frame stream: EP IN 0x81, marker 0x1bb1b11b @0, counter @4, data length @8,
|
|
type @0xc (0 response / 1 raw), shutter @0x10, pixels @0x1c (uint16 LE),
|
|
trailing 0x1bb1b11c @0x1c+len, frame size 0x38+len.
|
|
- Temperature: per-pixel piecewise-linear Calibration with baseline,
|
|
ConvertResponse2Temperature auto-gain, T2E curve (0x112 entries) with Q13
|
|
band interpolation.
|
|
- TCM: FTDICommand 0x7e framing with additive (mod-256) checksums; command
|
|
table main 0x02 (rotate 0x77, light 0x31/32/33, ...).
|