TestBench.tools
GitHub

AI 助手里的 TestBench.tools

本站的每个计算器同时也是 MCP 服务器:Claude Code 或任何 MCP 客户端都能直接调用同一套经过测试的函数,而不是靠心算。

100% 无状态:每次调用计算完即丢弃。输入不保存、不记录,也不用于任何其他用途 — 服务器根本没有存储空间。

一行安装

远程(无需安装)
claude mcp add --transport http testbench https://mcp.testbench.tools/mcp
本地(在你的电脑上运行,可离线)
claude mcp add testbench -- npx -y @testbench-tools/mcp

本地服务器需要 Node.js 18 或更高版本。使用时没有任何数据离开你的电脑。

或加入项目的 .mcp.json

{
  "mcpServers": {
    "testbench": {
      "type": "http",
      "url": "https://mcp.testbench.tools/mcp"
    }
  }
}

提交此文件后,任何用 Claude Code 打开该项目的人都能使用这些工具。

可以这样问

以下每个结果都是构建本页时由工具本身计算得出的,而不是手写的。

提问

“检查这个 Modbus 帧的 CRC:01 03 00 00 00 0A C5 CD”

调用的工具
crc.modbus16 {"data":"01 03 00 00 00 0A"}
返回
{
  "crc": "0xCDC5",
  "bytesLittleEndian": "C5 CD"
}
提问

“解码 MIL-STD-1553 命令字 0x0C22”

调用的工具
mil1553.decode_command {"word":"0x0C22"}
返回
{
  "rtAddress": 1,
  "direction": "Transmit (RT → BC)",
  "subaddress": 1,
  "wordCount": 2
}
提问

“LS XGT 地址 P00105 是第几个字的第几位?”

调用的工具
plc.xgt_address {"address":"P00105"}
返回
{
  "deviceName": "I/O relay",
  "word": 10,
  "bit": 5,
  "bitFromStartOfArea": 165
}

全部工具 (58)

名称前缀表示领域。每个工具与本站同名页面的计算相同。

协议解码

  • modbus.decode_frame/tools/modbus-frame-decoder/

    Decode a Modbus RTU or Modbus TCP frame field by field, checking the RTU CRC-16 or the TCP MBAP header, with RTU/TCP auto-detection. Example: data "11 03 00 6B 00 03 76 87" → RTU, slave 17, Read Holding Registers from 0x006B, 3 registers, CRC valid.

  • Split an NMEA 0183 sentence into talker, type and labelled fields and verify its XOR checksum. Example: "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47" → talker GP, type GGA, 14 fields, checksum 0x47 valid.

  • Build a valid NMEA 0183 GGA or RMC sentence from decimal-degree coordinates (or wrap a custom body), with the checksum computed. Example: GGA, talker GP, latitude 37.5665, longitude 126.978, time 02:30:00, fix 1, 8 satellites, HDOP 0.9, altitude 38 → "$GPGGA,023000.00,3733.9900,N,12658.6800,E,1,08,0.9,38,M,,M,,*55".

  • Check a CAN 2.0 frame's identifier range (11-bit standard or 29-bit extended), DLC and data, and show the identifier in hex, binary and decimal. Example: id "123", data "DE AD BE EF" → 0x123, binary 00100100011, decimal 291, DLC 4.

  • Decode a Mitsubishi MELSEC MC protocol 3E frame (request or response, ASCII or binary code): access route, command, device, points, end code and data length. Example: ASCII "500000FF03FF000018000A04010000D*0000000005" → batch read (0x0401) of D0, 5 word points, monitoring timer 2.5 s.

  • Decode binary frames against a layout of one checksum placement plus typed fields at fixed offsets (FrameTerm's .ftproj model), reporting checksum OK/FAIL and every field value per frame. Example: checksum CRC16_MODBUS at the last 2 bytes (LE), field temp s16 BE at offset 3, frame "A5 06 07 00 E1 01 18 0A" → checksum ok (0x0A18), temp 225.

航空电子 & 数据总线

  • Build a 32-bit ARINC 429 word from an octal label, SDI, SSM and either a 19-bit data field (BNR/discrete) or BCD digits, with odd parity set on bit 32. Example: labelOctal "205", sdi 2, ssm 3, format bnr, data 400 → word 0x600642A1 (parity bit 0).

  • Decode a 32-bit ARINC 429 word into label (octal, under both bit-order conventions), SDI, SSM, the data field read as BNR and BCD, and the odd-parity check. Example: word "0xE00640A1" → label 205 (241 read the other way round), SDI 0, SSM 3, BNR value 400, parity valid.

  • mil1553.decode_command/tools/mil-1553-command-word/

    Decode a MIL-STD-1553B command word into RT address, T/R, subaddress and word count or mode code, or build one from those fields with mode "encode". Example: word "183E" → RT 3, receive (BC → RT), subaddress 1, 30 data words.

  • mil1553.decode_message/tools/mil-1553-message-decoder/

    Lay out a MIL-STD-1553B transfer from its 16-bit words (word 1 is the command), labelling each word as command, data or status and checking the word count against the transfer format. Example: words "2822 1234 5678 2800" → BC → RT (receive): command, 2 data words and the RT 5 status word, layout matches.

  • mil1553.mode_codes/tools/mil-1553-mode-codes/

    List the MIL-STD-1553B mode codes (used with subaddress 0 or 31) with their required T/R bit and whether a data word follows, optionally filtered by code or name. Example: query "reset" → code 8, Reset Remote Terminal, T/R 1, no data word.

  • mil1553.decode_status/tools/mil-1553-status-word/

    Decode a MIL-STD-1553B status word into the RT address, each status flag bit and the odd-parity bit. Example: word "1800" → RT address 3, no status flags set, parity bit 1.

数据转换

  • convert.float32/tools/ieee-754-float/

    Convert a float32 to two 16-bit registers in all four word orders (ABCD, CDAB, BADC, DCBA), or two registers back to a float. Example: value 3.1415927 → ABCD 0x4049 0x0FDB, CDAB 0x0FDB 0x4049.

  • convert.hex_to_ascii/tools/hex-to-ascii/

    Convert hex bytes to ASCII text, showing non-printable bytes (outside 0x20–0x7E) as ".". Example: "48 69 0D 0A" → "Hi.." (4 bytes).

  • convert.ascii_to_hex/tools/ascii-to-hex/

    Convert ASCII text to space-separated uppercase hex bytes (one byte per character, low 8 bits of each code). Example: "Hi" → "48 69" (2 bytes).

  • Convert an integer of any size between binary, octal, decimal and hexadecimal (prefixes 0b/0o/0x, a sign and _ digit grouping accepted). Example: value "255" in base 10 → binary 11111111, octal 377, hex FF.

  • convert.twos_complement/tools/twos-complement/

    Convert between a signed decimal integer and its 8-, 16- or 32-bit two's-complement hex form, with the unsigned and binary views. Example: decimal "-10" at 16 bits → 0xFFF6 (unsigned 65526, binary 1111111111110110).

  • Show hex bytes fully byte-reversed, byte-swapped within 16-bit words, and 16-bit-word-swapped within 32-bit groups. Example: "12 34 56 78" → reversed 78 56 34 12, byte swap 34 12 78 56, word swap 56 78 12 34.

  • convert.q_format/tools/q-format/

    Encode a real value as signed Qm.n fixed point (round to nearest, clamp at the range ends) or decode a raw hex word back to its value. Example: 0.5 in Q0.15 → raw 0x4000 (16384 steps), stored 0.5.

校验和 & CRC

  • Compute the CRC-16/MODBUS of hex or ASCII bytes, with the two CRC bytes in Modbus RTU transmit order (low byte first). Example: data "01 03 00 00 00 0A" → 0xCDC5, sent as C5 CD.

  • Compute a CRC-16 from the CCITT family (polynomial 0x1021): CCITT-FALSE, XMODEM, KERMIT or IBM-SDLC. Example: data "123456789" as ASCII with variant CRC-16/CCITT-FALSE → 0x29B1.

  • Compute the standard CRC-32 (ISO-HDLC, as used by zip, Ethernet and PNG) of hex or ASCII bytes. Example: data "123456789" as ASCII → 0xCBF43926.

  • Compute a CRC-8 (CRC-8 with polynomial 0x07, or CRC-8/MAXIM for 1-Wire). Example: data "123456789" as ASCII → 0xF4 (CRC-8) or 0xA1 (CRC-8/MAXIM).

  • Compute a fully parameterised CRC (Rocksoft/RevEng model: width, poly, init, refin, refout, xorout). Example: width 16, poly 0x1021, init 0xFFFF, refin false, refout false, xorout 0 over ASCII "123456789" → 0x29B1.

  • Find which catalogue CRC algorithm produced a checksum, from one or more (data, checksum) samples; only algorithms that match every sample are returned. Example: samples [{data: "123456789", checksum: "0x29B1"}] with encoding ascii → CRC-16/CCITT-FALSE.

  • Verify or compute the NMEA 0183 checksum (XOR of every character between $ and *). Example: sentence "$GPGGA,023000.00,3733.9900,N,12658.6800,E,1,08,0.9,38.0,M,,M,,*4B" → checksum OK, 0x4B.

PLC & 工业

  • plc.scale_4_20ma/tools/4-20ma-scaling/

    Convert a 4-20 mA loop current to a process value on a linear range (with open-loop / under-range / over-range judgement), or a process value back to mA. Example: value 12 mA with range 0…200 → 100, 50 % of span, status ok.

  • Parse an Allen-Bradley SLC 500 / MicroLogix data-table address (N7:2/8, B3/16) or I/O address (I:2.1/3) into file, element, bit and flat bit index. Example: N7:2/8 → integer file 7, element 2, bit 8, bit 40 from file start.

  • Convert a packed BCD word (hex, up to 8 nibbles) to decimal, or a decimal integer (0–99999999) to packed BCD, rejecting nibbles A–F. Example: BCD 0x1234 → 1234; decimal 5678 → 0x5678.

  • plc.loop_burden/tools/loop-burden/

    Check a 4-20 mA loop voltage budget at 20 mA full scale: supply minus the drop across sense resistor, wiring and other series burden must cover the transmitter's minimum voltage. Example: 24 V supply, 12 V transmitter minimum, 250 Ω + 50 Ω → 18 V at the transmitter, 6 V margin, max 600 Ω.

  • Parse an LS ELECTRIC XGK/XGB device address (bit devices P/M/K/F/L/S with a trailing hex bit, word devices D/R/Z with a dotted hex bit) into word, bit and flat bit index, plus the next consecutive bits. Example: P00105 → I/O relay word 10, bit 5, bit 165 from the start of the area.

  • Decode a Mitsubishi MELSEC device address for iQ-F (FX5) or iQ-R, where X/Y are octal on FX5 but hexadecimal on iQ-R, and give the same point on the other series. Example: X20 on fx5 → point 16 (octal), written X10 on iQ-R.

  • Convert between Modbus data-model notation (0xxxx/1xxxx/3xxxx/4xxxx, 5 or 6 digits) and the 0-based protocol address sent on the wire. Example: 40011 → holding register, protocol address 10, 6-digit 400011.

  • plc.analog_scaling/tools/plc-analog-scaling/

    Scale a PLC analog-module raw count to engineering units or back, using a vendor module preset (Siemens, Mitsubishi, Allen-Bradley raw ranges) or a custom raw range. Example: preset s7 (0…27648), engineering 0…100, raw 13824 → 50.

  • Parse a Siemens S7 address (%MW100, %M10.3, DB1.DBW20, German E/A accepted) into area, width and covered bytes, check overlap with a second address, and lay out non-overlapping successors. Example: %MW100 → bytes 100–101, overlaps %MW101, next words %MW100 %MW102 %MW104 %MW106.

  • plc.signal_convert/tools/signal-converter/

    Convert a value between standard instrumentation signal spans (4–20 mA, 0–20 mA, 1–5 V, 0–5 V, 0–10 V, 3–15 psi) by linear mapping. Example: 12 mA from 4-20ma to 1-5v → 3 V, 50 % of span.

  • Derive the slope (gain) and offset of a linear calibration from two reference points, optionally applying it to a value in both directions. Example: (4, 0) and (20, 200) → slope 12.5, offset −50, so x = 12 gives y = 100.

  • plc.xgt_cnet_build/tools/xgt-cnet-builder/

    Build an LS ELECTRIC XGT Cnet dedicated-protocol request (RSS, RSB, WSS, WSB) with the BCC appended when the lowercase command calls for one. Example: RSS, station 20, device %MW100 → <ENQ>20rSS0106%MW100<EOT>A4.

  • plc.xgt_cnet_decode/tools/xgt-cnet-decoder/

    Decode an LS ELECTRIC XGT Cnet dedicated-protocol frame (ENQ request, ACK/NAK response) given as hex bytes or text with <ENQ> markers, checking the BCC against the letter-case rule and naming NAK error codes. Example: "05 32 30 72 53 53 30 31 30 36 25 4D 57 31 30 30 04 41 34" → ENQ request, station 0x20, rSS read of %MW100, BCC A4 valid.

传感器 & 信号

  • Convert an N-bit ADC count to volts or a voltage to the nearest code, using ratio = count / (2^N − 1). Example: 12-bit, Vref 3.3 V, count 2048 → 1.650403 V with an LSB of 0.805861 mV.

  • sensor.db_dbm/tools/db-dbm/

    Convert dBm to milliwatts, watts and Vrms into 50/75/600 Ω, or a power or voltage ratio to and from dB. Example: 0 dBm into 50 Ω → 1 mW and 0.223607 Vrms; voltage ratio 2 → 6.0206 dB.

  • sensor.measurement_accuracy/tools/measurement-accuracy/

    Turn an instrument accuracy spec ±(% of reading + % of range + counts + offset) into an absolute ± uncertainty with a per-term breakdown, manually or from a sourced DMM preset. Example: reading 4.7 V on the 10 V range at ±(0.0035 % of reading + 0.0005 % of range) → ±0.0002145 V, 45.6 ppm of reading.

  • Convert NTC thermistor resistance to temperature (or back) with both the Beta equation and a Steinhart-Hart curve fitted to three points, plus the gap between them, a model-deviation sweep and an optional divider/ADC reading. Example: 32554 Ω with R0 10 kΩ at 25 °C and B25/85 3977 K, fitted to the Vishay NTCLE100E3103 points → 0.021 °C (Steinhart-Hart) and 0.762 °C (Beta).

  • sensor.rtd_pt100/tools/pt100-calculator/

    Convert temperature to resistance or resistance to temperature for a PT100 or PT1000 RTD using the IEC 60751 Callendar-Van Dusen equation (0…850 °C branch). Example: PT100 at 100 °C → 138.5055 Ω.

  • sensor.rms_peak/tools/rms-peak/

    Convert between RMS, peak, peak-to-peak and rectified average for a pure sine wave with no DC offset. Example: 230 V RMS → 325.269 V peak, 650.538 V peak-to-peak, 207.073 V rectified average.

  • Convert thermocouple °C to mV, mV to °C, or measured mV plus cold-junction temperature to hot-junction °C with the NIST Monograph 175 polynomials, including the inverse error band and sub-range used. Example: type K, 4.096 mV measured with the cold junction at 25 °C → 124.31 °C.

  • sensor.voltage_divider/tools/voltage-divider/

    Find E24/E96 resistor pairs for a target divider output, or compute the unloaded Vout = Vin·R2/(R1+R2) for given resistors. Example: compute with Vin 5 V, R1 10 kΩ, R2 10 kΩ → 2.5 V.

嵌入式 & MCU

  • Extract named bit fields (LSB position + width) from a hex register value of up to 64 bits, giving each field in decimal, hex and binary. Example: 0xCAFE1234 with fields lsb 0 width 8, lsb 8 width 12, lsb 20 width 12 → 0x34, 0xE12, 0xCAF.

  • mcu.can_bit_timing/tools/can-bit-timing/

    Find CAN 2.0 prescaler, SEG1 and SEG2 settings (8–25 tq per bit, SYNC + SEG1 + SEG2) for a clock, bitrate and target sample point, best first. Example: 8 MHz clock, 500 kbit/s, 87.5 % → prescaler 1, 16 tq, SEG1 13, SEG2 2, 0 % error.

  • mcu.i2c_pullup/tools/i2c-pullup/

    Compute the valid I2C pull-up range from VDD, bus capacitance and speed mode (UM10204: R_min = (VDD − 0.4 V)/I_OL, R_max = t_r/(0.8473·C_b)) with a suggested E24 value. Example: fast mode (400 kHz), 3.3 V, 150 pF → 967 Ω … 2.36 kΩ, suggested 1.5 kΩ.

  • mcu.timer_prescaler/tools/stm32-timer/

    Find 16-bit timer prescaler (PSC) and auto-reload (ARR) register values for a target frequency, f = f_clk / ((PSC+1)·(ARR+1)), best matches first. Example: 72 MHz clock, 1000 Hz target → PSC 1, ARR 35999 with 0 % error.

  • mcu.struct_padding/tools/struct-padding/

    Lay out C struct members with natural (System V-style) alignment on a 32- or 64-bit target, giving each member's offset, size and padding plus sizeof and total padding. Example: "uint8_t flags; uint32_t count; uint16_t id; char name[8];" on 32-bit → sizeof 20 with 5 bytes padding.

  • mcu.uart_baud_error/tools/uart-baud-error/

    Compute the UART baud divisor round(f_clk/(oversampling·baud)), the actual baud and its error against the ~±2 % rule of thumb, plus a table of common baud rates. Example: 16 MHz clock, 115200 baud, ×16 oversampling → divisor 9, 111111.1 baud, −3.549 % error.

文件工具

  • Parse numeric CSV text the way the waveform plotter does (auto delimiter, optional header row, non-numeric rows skipped) and return per-column min/max/mean, the plot axis ranges and the first rows instead of the plot. Example: text "t,v\n0,1\n1,3\n2,2" → 3 rows, column v min 1, max 3, mean 2, plotted against t from 0 to 2.

  • Hex dump of a binary file (offset, 16 hex bytes, ASCII column), returned in windows of up to 64 KB with the next offset to continue from. Example: contentBase64 "SGVsbG8sIFdvcmxkIQ==" ("Hello, World!") → 13 bytes, one line starting "00000000 48 65 6C 6C 6F" and ending "|Hello, World!|".

  • file.hex_srec_convert/tools/hex-srec-bin/

    Convert Intel HEX or Motorola S-Record text to a flat binary (gaps filled with 0xFF, returned as base64 with its segment map), or a binary to Intel HEX or S-Record at a base address. Example: direction toBin, text ":10010000214601360121470136007EFE09D2190140\n:00000001FF" → one 16-byte segment 0x00000100-0x0000010F, binBase64 "IUYBNgEhRwE2AH7+CdIZAQ==".

  • file.tdms_to_csv/tools/tdms-to-csv/

    Convert an NI TDMS file's channels to CSV, one column per channel headed "group/channel", with rows padded where channel lengths differ and capped at maxRows. Example: a TDMS with channel DAQ/ch1 = [1, 2, 3] and DAQ/ch2 = [-1, -2, -3] → "DAQ/ch1,DAQ/ch2\n1,-1\n2,-2\n3,-3\n".

  • file.tdms_inspect/tools/tdms-viewer/

    List an NI TDMS file's properties, groups and channels with each channel's data type, sample count, properties and first 10 samples. Example: a TDMS with group DAQ, channels ch1 (unit V) and ch2 of 3 f64 samples each → 1 group, 2 channels, ch1 properties {unit: "V"} and firstSamples [1, 2, 3].