logic-agent-mcp 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.cmd +5 -0
- package/CAPTURE.cmd +8 -0
- package/CHECK.cmd +7 -0
- package/FIRMWARE-RECOVER.cmd +6 -0
- package/FIRMWARE-STATUS.cmd +8 -0
- package/INSTALL-DRIVER.cmd +6 -0
- package/INSTALL-MCP.cmd +16 -0
- package/LICENSE +31 -0
- package/MCP.cmd +5 -0
- package/README.md +127 -2
- package/SELF-TEST.cmd +6 -0
- package/THIRD-PARTY-NOTICES.md +32 -0
- package/VERIFY-FILES.cmd +6 -0
- package/VERSION.txt +17 -0
- package/VIEW.cmd +16 -0
- package/checksums.sha256 +449 -0
- package/docs/DRIVER.md +54 -0
- package/docs/DSLOGIC-PLUS.md +180 -0
- package/docs/FIRMWARE.md +53 -0
- package/docs/INSTALL.md +74 -0
- package/docs/MCP-CLIENTS.md +213 -0
- package/docs/PROTOCOLS.md +200 -0
- package/docs/TROUBLESHOOTING.md +41 -0
- package/docs/UPSTREAM-SYNC.md +141 -0
- package/docs/WAVEFORM-VIEWER.md +48 -0
- package/firmware/DSLogicPlus.fw +0 -0
- package/firmware/LICENSE-DreamSourceLab.txt +20 -0
- package/launcher/logic-agent-mcp.mjs +106 -0
- package/package.json +56 -6
- package/runtime/app/logic_agent/__init__.py +4 -0
- package/runtime/app/logic_agent/analysis.py +84 -0
- package/runtime/app/logic_agent/backends/__init__.py +7 -0
- package/runtime/app/logic_agent/backends/base.py +37 -0
- package/runtime/app/logic_agent/backends/dslab.py +278 -0
- package/runtime/app/logic_agent/backends/mock.py +101 -0
- package/runtime/app/logic_agent/backends/sigrok.py +252 -0
- package/runtime/app/logic_agent/cli.py +387 -0
- package/runtime/app/logic_agent/decoders.py +868 -0
- package/runtime/app/logic_agent/errors.py +50 -0
- package/runtime/app/logic_agent/importer.py +129 -0
- package/runtime/app/logic_agent/mcp_clients.py +956 -0
- package/runtime/app/logic_agent/mcp_server.py +345 -0
- package/runtime/app/logic_agent/models.py +150 -0
- package/runtime/app/logic_agent/protocols.py +233 -0
- package/runtime/app/logic_agent/service.py +378 -0
- package/runtime/app/logic_agent/signal.py +206 -0
- package/runtime/app/logic_agent/store.py +197 -0
- package/runtime/bin/_bz2.pyd +0 -0
- package/runtime/bin/_ctypes.pyd +0 -0
- package/runtime/bin/_decimal.pyd +0 -0
- package/runtime/bin/_elementtree.pyd +0 -0
- package/runtime/bin/_hashlib.pyd +0 -0
- package/runtime/bin/_lzma.pyd +0 -0
- package/runtime/bin/_multiprocessing.pyd +0 -0
- package/runtime/bin/_socket.pyd +0 -0
- package/runtime/bin/_sqlite3.pyd +0 -0
- package/runtime/bin/_ssl.pyd +0 -0
- package/runtime/bin/dslab.exe +0 -0
- package/runtime/bin/libglib-2.0-0.dll +0 -0
- package/runtime/bin/libiconv-2.dll +0 -0
- package/runtime/bin/libintl-8.dll +0 -0
- package/runtime/bin/libpcre2-8-0.dll +0 -0
- package/runtime/bin/libusb-1.0.dll +0 -0
- package/runtime/bin/libwinpthread-1.dll +0 -0
- package/runtime/bin/libz-1.dll +0 -0
- package/runtime/bin/msvcp100.dll +0 -0
- package/runtime/bin/msvcr100.dll +0 -0
- package/runtime/bin/pyexpat.pyd +0 -0
- package/runtime/bin/python34.dll +0 -0
- package/runtime/bin/python34.zip +0 -0
- package/runtime/bin/res/DSCope.bin +0 -0
- package/runtime/bin/res/DSCope.fw +0 -0
- package/runtime/bin/res/DSCope1.def.dsc +88 -0
- package/runtime/bin/res/DSCope2.def.dsc +54 -0
- package/runtime/bin/res/DSCope20.bin +0 -0
- package/runtime/bin/res/DSCope20.fw +0 -0
- package/runtime/bin/res/DSCopeC20B.bin +0 -0
- package/runtime/bin/res/DSCopeC20P.bin +0 -0
- package/runtime/bin/res/DSCopeU2B100.bin +0 -0
- package/runtime/bin/res/DSCopeU2B20.bin +0 -0
- package/runtime/bin/res/DSCopeU2P20.bin +0 -0
- package/runtime/bin/res/DSCopeU3P100.bin +0 -0
- package/runtime/bin/res/DSLogic.fw +0 -0
- package/runtime/bin/res/DSLogic0.def.dsc +297 -0
- package/runtime/bin/res/DSLogic1.def.dsc +82 -0
- package/runtime/bin/res/DSLogic2.def.dsc +52 -0
- package/runtime/bin/res/DSLogic33.bin +0 -0
- package/runtime/bin/res/DSLogic50.bin +0 -0
- package/runtime/bin/res/DSLogicBasic.bin +0 -0
- package/runtime/bin/res/DSLogicPlus-pgl12-2.bin +0 -0
- package/runtime/bin/res/DSLogicPlus-pgl12.bin +0 -0
- package/runtime/bin/res/DSLogicPlus.bin +0 -0
- package/runtime/bin/res/DSLogicPlus.fw +0 -0
- package/runtime/bin/res/DSLogicPro.bin +0 -0
- package/runtime/bin/res/DSLogicPro.fw +0 -0
- package/runtime/bin/res/DSLogicU2Basic-pgl12-2.bin +0 -0
- package/runtime/bin/res/DSLogicU2Basic-pgl12.bin +0 -0
- package/runtime/bin/res/DSLogicU2Basic.bin +0 -0
- package/runtime/bin/res/DSLogicU2Pro16.bin +0 -0
- package/runtime/bin/res/DSLogicU3Pro16.bin +0 -0
- package/runtime/bin/res/DSLogicU3Pro32.bin +0 -0
- package/runtime/bin/res/license.txt +20 -0
- package/runtime/bin/res/virtual-demo1.dsc +68 -0
- package/runtime/bin/select.pyd +0 -0
- package/runtime/bin/sigrok-cli.exe +0 -0
- package/runtime/bin/unicodedata.pyd +0 -0
- package/runtime/bin/winsound.pyd +0 -0
- package/runtime/decoders/ac97/__init__.py +38 -0
- package/runtime/decoders/ac97/pd.py +477 -0
- package/runtime/decoders/ad5626/__init__.py +25 -0
- package/runtime/decoders/ad5626/pd.py +62 -0
- package/runtime/decoders/ad79x0/__init__.py +25 -0
- package/runtime/decoders/ad79x0/pd.py +137 -0
- package/runtime/decoders/ade77xx/__init__.py +31 -0
- package/runtime/decoders/ade77xx/lists.py +102 -0
- package/runtime/decoders/ade77xx/pd.py +131 -0
- package/runtime/decoders/adf435x/__init__.py +29 -0
- package/runtime/decoders/adf435x/pd.py +230 -0
- package/runtime/decoders/adns5020/__init__.py +27 -0
- package/runtime/decoders/adns5020/pd.py +116 -0
- package/runtime/decoders/adxl345/__init__.py +26 -0
- package/runtime/decoders/adxl345/lists.py +96 -0
- package/runtime/decoders/adxl345/pd.py +453 -0
- package/runtime/decoders/am230x/__init__.py +36 -0
- package/runtime/decoders/am230x/pd.py +229 -0
- package/runtime/decoders/amulet_ascii/__init__.py +28 -0
- package/runtime/decoders/amulet_ascii/lists.py +73 -0
- package/runtime/decoders/amulet_ascii/pd.py +699 -0
- package/runtime/decoders/arm_etmv3/__init__.py +25 -0
- package/runtime/decoders/arm_etmv3/pd.py +567 -0
- package/runtime/decoders/arm_itm/__init__.py +25 -0
- package/runtime/decoders/arm_itm/pd.py +373 -0
- package/runtime/decoders/arm_tpiu/__init__.py +28 -0
- package/runtime/decoders/arm_tpiu/pd.py +131 -0
- package/runtime/decoders/atsha204a/__init__.py +30 -0
- package/runtime/decoders/atsha204a/pd.py +323 -0
- package/runtime/decoders/aud/__init__.py +31 -0
- package/runtime/decoders/aud/pd.py +108 -0
- package/runtime/decoders/avr_isp/__init__.py +25 -0
- package/runtime/decoders/avr_isp/parts.py +163 -0
- package/runtime/decoders/avr_isp/pd.py +278 -0
- package/runtime/decoders/avr_pdi/__init__.py +42 -0
- package/runtime/decoders/avr_pdi/pd.py +574 -0
- package/runtime/decoders/caliper/__init__.py +36 -0
- package/runtime/decoders/caliper/pd.py +146 -0
- package/runtime/decoders/can/__init__.py +31 -0
- package/runtime/decoders/can/pd.py +519 -0
- package/runtime/decoders/cc1101/__init__.py +28 -0
- package/runtime/decoders/cc1101/lists.py +115 -0
- package/runtime/decoders/cc1101/pd.py +294 -0
- package/runtime/decoders/cec/__init__.py +25 -0
- package/runtime/decoders/cec/pd.py +311 -0
- package/runtime/decoders/cec/protocoldata.py +117 -0
- package/runtime/decoders/cfp/__init__.py +34 -0
- package/runtime/decoders/cfp/pd.py +110 -0
- package/runtime/decoders/cjtag/__init__.py +36 -0
- package/runtime/decoders/cjtag/pd.py +323 -0
- package/runtime/decoders/common/__init__.py +19 -0
- package/runtime/decoders/common/plugtrx/__init__.py +20 -0
- package/runtime/decoders/common/plugtrx/mod.py +192 -0
- package/runtime/decoders/common/sdcard/__init__.py +20 -0
- package/runtime/decoders/common/sdcard/mod.py +150 -0
- package/runtime/decoders/common/srdhelper/__init__.py +20 -0
- package/runtime/decoders/common/srdhelper/mod.py +98 -0
- package/runtime/decoders/counter/__init__.py +28 -0
- package/runtime/decoders/counter/pd.py +145 -0
- package/runtime/decoders/dali/__init__.py +24 -0
- package/runtime/decoders/dali/lists.py +98 -0
- package/runtime/decoders/dali/pd.py +244 -0
- package/runtime/decoders/dcf77/__init__.py +28 -0
- package/runtime/decoders/dcf77/pd.py +311 -0
- package/runtime/decoders/dmx512/__init__.py +25 -0
- package/runtime/decoders/dmx512/pd.py +361 -0
- package/runtime/decoders/ds1307/__init__.py +25 -0
- package/runtime/decoders/ds1307/pd.py +270 -0
- package/runtime/decoders/ds2408/__init__.py +25 -0
- package/runtime/decoders/ds2408/pd.py +129 -0
- package/runtime/decoders/ds243x/__init__.py +25 -0
- package/runtime/decoders/ds243x/pd.py +270 -0
- package/runtime/decoders/ds28ea00/__init__.py +25 -0
- package/runtime/decoders/ds28ea00/pd.py +93 -0
- package/runtime/decoders/dsi/__init__.py +24 -0
- package/runtime/decoders/dsi/pd.py +157 -0
- package/runtime/decoders/edid/__init__.py +35 -0
- package/runtime/decoders/edid/pd.py +671 -0
- package/runtime/decoders/edid/pnpids.txt +2135 -0
- package/runtime/decoders/eeprom24xx/__init__.py +25 -0
- package/runtime/decoders/eeprom24xx/lists.py +214 -0
- package/runtime/decoders/eeprom24xx/pd.py +443 -0
- package/runtime/decoders/eeprom93xx/__init__.py +32 -0
- package/runtime/decoders/eeprom93xx/pd.py +163 -0
- package/runtime/decoders/em4100/__init__.py +24 -0
- package/runtime/decoders/em4100/pd.py +238 -0
- package/runtime/decoders/em4305/__init__.py +24 -0
- package/runtime/decoders/em4305/pd.py +394 -0
- package/runtime/decoders/enc28j60/__init__.py +32 -0
- package/runtime/decoders/enc28j60/lists.py +161 -0
- package/runtime/decoders/enc28j60/pd.py +294 -0
- package/runtime/decoders/flexray/__init__.py +32 -0
- package/runtime/decoders/flexray/pd.py +413 -0
- package/runtime/decoders/graycode/__init__.py +24 -0
- package/runtime/decoders/graycode/pd.py +197 -0
- package/runtime/decoders/guess_bitrate/__init__.py +40 -0
- package/runtime/decoders/guess_bitrate/pd.py +79 -0
- package/runtime/decoders/hdcp/__init__.py +27 -0
- package/runtime/decoders/hdcp/pd.py +191 -0
- package/runtime/decoders/i2c/__init__.py +25 -0
- package/runtime/decoders/i2c/pd.py +364 -0
- package/runtime/decoders/i2cdemux/__init__.py +27 -0
- package/runtime/decoders/i2cdemux/pd.py +80 -0
- package/runtime/decoders/i2cfilter/__init__.py +37 -0
- package/runtime/decoders/i2cfilter/pd.py +106 -0
- package/runtime/decoders/i2s/__init__.py +29 -0
- package/runtime/decoders/i2s/pd.py +179 -0
- package/runtime/decoders/ieee488/__init__.py +26 -0
- package/runtime/decoders/ieee488/pd.py +849 -0
- package/runtime/decoders/ir_irmp/__init__.py +25 -0
- package/runtime/decoders/ir_irmp/irmp_library.py +168 -0
- package/runtime/decoders/ir_irmp/pd.py +139 -0
- package/runtime/decoders/ir_nec/__init__.py +25 -0
- package/runtime/decoders/ir_nec/lists.py +93 -0
- package/runtime/decoders/ir_nec/pd.py +300 -0
- package/runtime/decoders/ir_rc5/__init__.py +24 -0
- package/runtime/decoders/ir_rc5/lists.py +93 -0
- package/runtime/decoders/ir_rc5/pd.py +182 -0
- package/runtime/decoders/ir_rc6/__init__.py +24 -0
- package/runtime/decoders/ir_rc6/pd.py +205 -0
- package/runtime/decoders/ir_sirc/__init__.py +26 -0
- package/runtime/decoders/ir_sirc/lists.py +201 -0
- package/runtime/decoders/ir_sirc/pd.py +215 -0
- package/runtime/decoders/jitter/__init__.py +29 -0
- package/runtime/decoders/jitter/pd.py +198 -0
- package/runtime/decoders/jtag/__init__.py +30 -0
- package/runtime/decoders/jtag/pd.py +235 -0
- package/runtime/decoders/jtag_ejtag/__init__.py +25 -0
- package/runtime/decoders/jtag_ejtag/pd.py +408 -0
- package/runtime/decoders/jtag_stm32/__init__.py +29 -0
- package/runtime/decoders/jtag_stm32/pd.py +269 -0
- package/runtime/decoders/lfast/__init__.py +35 -0
- package/runtime/decoders/lfast/pd.py +335 -0
- package/runtime/decoders/lin/__init__.py +28 -0
- package/runtime/decoders/lin/pd.py +247 -0
- package/runtime/decoders/lm75/__init__.py +25 -0
- package/runtime/decoders/lm75/pd.py +186 -0
- package/runtime/decoders/lpc/__init__.py +25 -0
- package/runtime/decoders/lpc/pd.py +365 -0
- package/runtime/decoders/ltc242x/__init__.py +25 -0
- package/runtime/decoders/ltc242x/pd.py +86 -0
- package/runtime/decoders/ltc26x7/__init__.py +25 -0
- package/runtime/decoders/ltc26x7/pd.py +187 -0
- package/runtime/decoders/maple_bus/__init__.py +25 -0
- package/runtime/decoders/maple_bus/pd.py +222 -0
- package/runtime/decoders/max72xx/__init__.py +25 -0
- package/runtime/decoders/max72xx/pd.py +130 -0
- package/runtime/decoders/mcp230xx/__init__.py +25 -0
- package/runtime/decoders/mcp230xx/pd.py +143 -0
- package/runtime/decoders/mcs48/__init__.py +31 -0
- package/runtime/decoders/mcs48/pd.py +126 -0
- package/runtime/decoders/mdio/__init__.py +39 -0
- package/runtime/decoders/mdio/pd.py +325 -0
- package/runtime/decoders/microwire/__init__.py +40 -0
- package/runtime/decoders/microwire/pd.py +194 -0
- package/runtime/decoders/midi/__init__.py +28 -0
- package/runtime/decoders/midi/lists.py +840 -0
- package/runtime/decoders/midi/pd.py +627 -0
- package/runtime/decoders/miller/__init__.py +26 -0
- package/runtime/decoders/miller/pd.py +190 -0
- package/runtime/decoders/mlx90614/__init__.py +25 -0
- package/runtime/decoders/mlx90614/pd.py +82 -0
- package/runtime/decoders/modbus/__init__.py +28 -0
- package/runtime/decoders/modbus/pd.py +941 -0
- package/runtime/decoders/morse/__init__.py +28 -0
- package/runtime/decoders/morse/pd.py +250 -0
- package/runtime/decoders/mrf24j40/__init__.py +25 -0
- package/runtime/decoders/mrf24j40/lists.py +165 -0
- package/runtime/decoders/mrf24j40/pd.py +188 -0
- package/runtime/decoders/mxc6225xu/__init__.py +28 -0
- package/runtime/decoders/mxc6225xu/pd.py +217 -0
- package/runtime/decoders/nes_gamepad/__init__.py +54 -0
- package/runtime/decoders/nes_gamepad/pd.py +92 -0
- package/runtime/decoders/nrf24l01/__init__.py +29 -0
- package/runtime/decoders/nrf24l01/pd.py +332 -0
- package/runtime/decoders/nrf905/__init__.py +26 -0
- package/runtime/decoders/nrf905/pd.py +301 -0
- package/runtime/decoders/numbers_and_state/__init__.py +41 -0
- package/runtime/decoders/numbers_and_state/pd.py +377 -0
- package/runtime/decoders/nunchuk/__init__.py +30 -0
- package/runtime/decoders/nunchuk/pd.py +207 -0
- package/runtime/decoders/onewire_link/__init__.py +56 -0
- package/runtime/decoders/onewire_link/pd.py +347 -0
- package/runtime/decoders/onewire_network/__init__.py +56 -0
- package/runtime/decoders/onewire_network/pd.py +185 -0
- package/runtime/decoders/ook/__init__.py +36 -0
- package/runtime/decoders/ook/pd.py +484 -0
- package/runtime/decoders/ook_oregon/__init__.py +25 -0
- package/runtime/decoders/ook_oregon/lists.py +75 -0
- package/runtime/decoders/ook_oregon/pd.py +389 -0
- package/runtime/decoders/ook_vis/__init__.py +25 -0
- package/runtime/decoders/ook_vis/pd.py +194 -0
- package/runtime/decoders/pan1321/__init__.py +25 -0
- package/runtime/decoders/pan1321/pd.py +164 -0
- package/runtime/decoders/parallel/__init__.py +45 -0
- package/runtime/decoders/parallel/pd.py +285 -0
- package/runtime/decoders/pca9571/__init__.py +25 -0
- package/runtime/decoders/pca9571/pd.py +122 -0
- package/runtime/decoders/pjdl/__init__.py +27 -0
- package/runtime/decoders/pjdl/pd.py +723 -0
- package/runtime/decoders/pjon/__init__.py +25 -0
- package/runtime/decoders/pjon/pd.py +603 -0
- package/runtime/decoders/ps2/__init__.py +26 -0
- package/runtime/decoders/ps2/pd.py +126 -0
- package/runtime/decoders/pwm/__init__.py +24 -0
- package/runtime/decoders/pwm/pd.py +167 -0
- package/runtime/decoders/qi/__init__.py +25 -0
- package/runtime/decoders/qi/pd.py +244 -0
- package/runtime/decoders/rc_encode/__init__.py +40 -0
- package/runtime/decoders/rc_encode/pd.py +215 -0
- package/runtime/decoders/rfm12/__init__.py +25 -0
- package/runtime/decoders/rfm12/pd.py +497 -0
- package/runtime/decoders/rgb_led_spi/__init__.py +25 -0
- package/runtime/decoders/rgb_led_spi/pd.py +72 -0
- package/runtime/decoders/rgb_led_ws281x/__init__.py +27 -0
- package/runtime/decoders/rgb_led_ws281x/pd.py +267 -0
- package/runtime/decoders/rtc8564/__init__.py +25 -0
- package/runtime/decoders/rtc8564/pd.py +254 -0
- package/runtime/decoders/sae_j1850_vpw/__init__.py +24 -0
- package/runtime/decoders/sae_j1850_vpw/pd.py +296 -0
- package/runtime/decoders/sbus_futaba/__init__.py +35 -0
- package/runtime/decoders/sbus_futaba/pd.py +273 -0
- package/runtime/decoders/sda2506/__init__.py +24 -0
- package/runtime/decoders/sda2506/pd.py +146 -0
- package/runtime/decoders/sdcard_sd/__init__.py +24 -0
- package/runtime/decoders/sdcard_sd/pd.py +554 -0
- package/runtime/decoders/sdcard_spi/__init__.py +68 -0
- package/runtime/decoders/sdcard_spi/pd.py +518 -0
- package/runtime/decoders/sdq/__init__.py +28 -0
- package/runtime/decoders/sdq/pd.py +131 -0
- package/runtime/decoders/seven_segment/__init__.py +24 -0
- package/runtime/decoders/seven_segment/pd.py +186 -0
- package/runtime/decoders/signature/__init__.py +25 -0
- package/runtime/decoders/signature/pd.py +142 -0
- package/runtime/decoders/sipi/__init__.py +30 -0
- package/runtime/decoders/sipi/pd.py +181 -0
- package/runtime/decoders/sle44xx/__init__.py +26 -0
- package/runtime/decoders/sle44xx/pd.py +541 -0
- package/runtime/decoders/smart_qspi/PORTING.md +22 -0
- package/runtime/decoders/smart_qspi/__init__.py +1 -0
- package/runtime/decoders/smart_qspi/pd.py +826 -0
- package/runtime/decoders/spdif/__init__.py +25 -0
- package/runtime/decoders/spdif/pd.py +295 -0
- package/runtime/decoders/spi/__init__.py +32 -0
- package/runtime/decoders/spi/pd.py +347 -0
- package/runtime/decoders/spiflash/__init__.py +30 -0
- package/runtime/decoders/spiflash/lists.py +178 -0
- package/runtime/decoders/spiflash/pd.py +537 -0
- package/runtime/decoders/ssi32/__init__.py +28 -0
- package/runtime/decoders/ssi32/pd.py +127 -0
- package/runtime/decoders/st25r39xx_spi/__init__.py +31 -0
- package/runtime/decoders/st25r39xx_spi/lists.py +231 -0
- package/runtime/decoders/st25r39xx_spi/pd.py +360 -0
- package/runtime/decoders/st7735/__init__.py +27 -0
- package/runtime/decoders/st7735/pd.py +173 -0
- package/runtime/decoders/stepper_motor/__init__.py +25 -0
- package/runtime/decoders/stepper_motor/pd.py +95 -0
- package/runtime/decoders/swd/__init__.py +34 -0
- package/runtime/decoders/swd/pd.py +350 -0
- package/runtime/decoders/swim/__init__.py +28 -0
- package/runtime/decoders/swim/pd.py +303 -0
- package/runtime/decoders/t55xx/__init__.py +25 -0
- package/runtime/decoders/t55xx/pd.py +326 -0
- package/runtime/decoders/tca6408a/__init__.py +25 -0
- package/runtime/decoders/tca6408a/pd.py +157 -0
- package/runtime/decoders/tdm_audio/__init__.py +25 -0
- package/runtime/decoders/tdm_audio/pd.py +116 -0
- package/runtime/decoders/timing/__init__.py +24 -0
- package/runtime/decoders/timing/pd.py +194 -0
- package/runtime/decoders/tlc5620/__init__.py +24 -0
- package/runtime/decoders/tlc5620/pd.py +212 -0
- package/runtime/decoders/uart/__init__.py +40 -0
- package/runtime/decoders/uart/pd.py +635 -0
- package/runtime/decoders/usb_packet/__init__.py +43 -0
- package/runtime/decoders/usb_packet/pd.py +401 -0
- package/runtime/decoders/usb_power_delivery/__init__.py +24 -0
- package/runtime/decoders/usb_power_delivery/pd.py +642 -0
- package/runtime/decoders/usb_request/__init__.py +49 -0
- package/runtime/decoders/usb_request/pd.py +386 -0
- package/runtime/decoders/usb_signalling/__init__.py +50 -0
- package/runtime/decoders/usb_signalling/pd.py +348 -0
- package/runtime/decoders/wiegand/__init__.py +28 -0
- package/runtime/decoders/wiegand/pd.py +148 -0
- package/runtime/decoders/x2444m/__init__.py +25 -0
- package/runtime/decoders/x2444m/pd.py +111 -0
- package/runtime/decoders/xfp/__init__.py +38 -0
- package/runtime/decoders/xfp/pd.py +486 -0
- package/runtime/decoders/xy2-100/__init__.py +28 -0
- package/runtime/decoders/xy2-100/pd.py +242 -0
- package/runtime/decoders/z80/__init__.py +36 -0
- package/runtime/decoders/z80/pd.py +358 -0
- package/runtime/decoders/z80/tables.py +1083 -0
- package/runtime/dslab.cmd +5 -0
- package/runtime/licenses/DreamSourceLab-res-MIT.txt +20 -0
- package/runtime/licenses/dslab-GPL-3.0.txt +674 -0
- package/runtime/licenses/logic-agent-MIT.txt +31 -0
- package/runtime/licenses/python-PSF.txt +645 -0
- package/runtime/licenses/sigrok-cli-GPL-3.0.txt +674 -0
- package/runtime/licenses/smart_qspi-PORTING.md +22 -0
- package/runtime/licenses/source/patches/dsview-v1.3.2-dslab.patch +124 -0
- package/runtime/logic-agent-mcp.cmd +9 -0
- package/runtime/logic-agent.cmd +9 -0
- package/runtime/python/LICENSE.txt +645 -0
- package/runtime/python/_asyncio.pyd +0 -0
- package/runtime/python/_bz2.pyd +0 -0
- package/runtime/python/_ctypes.pyd +0 -0
- package/runtime/python/_decimal.pyd +0 -0
- package/runtime/python/_elementtree.pyd +0 -0
- package/runtime/python/_hashlib.pyd +0 -0
- package/runtime/python/_lzma.pyd +0 -0
- package/runtime/python/_multiprocessing.pyd +0 -0
- package/runtime/python/_overlapped.pyd +0 -0
- package/runtime/python/_queue.pyd +0 -0
- package/runtime/python/_socket.pyd +0 -0
- package/runtime/python/_sqlite3.pyd +0 -0
- package/runtime/python/_ssl.pyd +0 -0
- package/runtime/python/_uuid.pyd +0 -0
- package/runtime/python/_wmi.pyd +0 -0
- package/runtime/python/_zoneinfo.pyd +0 -0
- package/runtime/python/libcrypto-3.dll +0 -0
- package/runtime/python/libffi-8.dll +0 -0
- package/runtime/python/libssl-3.dll +0 -0
- package/runtime/python/pyexpat.pyd +0 -0
- package/runtime/python/python.cat +0 -0
- package/runtime/python/python.exe +0 -0
- package/runtime/python/python3.dll +0 -0
- package/runtime/python/python313._pth +3 -0
- package/runtime/python/python313.dll +0 -0
- package/runtime/python/python313.zip +0 -0
- package/runtime/python/pythonw.exe +0 -0
- package/runtime/python/select.pyd +0 -0
- package/runtime/python/sqlite3.dll +0 -0
- package/runtime/python/unicodedata.pyd +0 -0
- package/runtime/python/vcruntime140.dll +0 -0
- package/runtime/python/vcruntime140_1.dll +0 -0
- package/runtime/python/winsound.pyd +0 -0
- package/runtime/scripts/deploy-check.ps1 +171 -0
- package/scripts/check.ps1 +14 -0
- package/scripts/firmware-recover.ps1 +27 -0
- package/scripts/install-driver.ps1 +30 -0
- package/scripts/self-test.ps1 +14 -0
- package/scripts/verify-files.py +39 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any, BinaryIO
|
|
8
|
+
|
|
9
|
+
from . import __version__
|
|
10
|
+
from .decoders import protocol_specs, supported_protocols
|
|
11
|
+
from .errors import LogicAgentError
|
|
12
|
+
from .service import DEFAULT_RESOURCE_URI_TEMPLATE, LogicAgentService
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
TOOLS = [
|
|
16
|
+
{
|
|
17
|
+
"name": "capabilities",
|
|
18
|
+
"description": "Report available backends, safety limits, and the recommended workflow.",
|
|
19
|
+
"inputSchema": {"type": "object", "properties": {}, "additionalProperties": False},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "list_devices",
|
|
23
|
+
"description": "Discover connected logic analyzers without starting a capture.",
|
|
24
|
+
"inputSchema": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {"backend": {"type": "string", "enum": ["mock", "sigrok", "dslab"]}},
|
|
27
|
+
"additionalProperties": False,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "capture",
|
|
32
|
+
"description": (
|
|
33
|
+
"Capture digital channels and persist them under a capture_id. Returns per-channel statistics "
|
|
34
|
+
"(edges, pulse widths, rough frequency), never the raw sample array. Prefer a short window first."
|
|
35
|
+
),
|
|
36
|
+
"inputSchema": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"channels": {"type": "array", "items": {"type": "string"}, "minItems": 1},
|
|
40
|
+
"sample_rate_hz": {"type": "integer", "minimum": 1},
|
|
41
|
+
"duration_s": {"type": "number", "exclusiveMinimum": 0},
|
|
42
|
+
"backend": {"type": "string", "enum": ["mock", "sigrok", "dslab"]},
|
|
43
|
+
"device": {"type": "string"},
|
|
44
|
+
"label": {"type": "string", "maxLength": 120},
|
|
45
|
+
"trigger": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"properties": {
|
|
48
|
+
"channel": {"type": "string"},
|
|
49
|
+
"edge": {"type": "string", "enum": ["rising", "falling", "either"]},
|
|
50
|
+
},
|
|
51
|
+
"required": ["channel"],
|
|
52
|
+
"additionalProperties": False,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
"required": ["channels", "sample_rate_hz", "duration_s"],
|
|
56
|
+
"additionalProperties": False,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "list_captures",
|
|
61
|
+
"description": "List saved captures, newest first.",
|
|
62
|
+
"inputSchema": {"type": "object", "properties": {}, "additionalProperties": False},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "self_test",
|
|
66
|
+
"description": (
|
|
67
|
+
"Hardware self-test using the DSLogic internal pattern generator. "
|
|
68
|
+
"Run this before protocol work to distinguish a broken capture path from a bad probe signal. "
|
|
69
|
+
"It does not prove that external wiring is correct."
|
|
70
|
+
),
|
|
71
|
+
"inputSchema": {"type": "object", "properties": {}, "additionalProperties": False},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "analyze_window",
|
|
75
|
+
"description": (
|
|
76
|
+
"Analyze a bounded time window of a saved channel. Starts with summaries and at most max_edges "
|
|
77
|
+
"transitions so the agent can drill down incrementally."
|
|
78
|
+
),
|
|
79
|
+
"inputSchema": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"properties": {
|
|
82
|
+
"capture_id": {"type": "string"},
|
|
83
|
+
"channel": {"type": "string"},
|
|
84
|
+
"start_s": {"type": "number", "minimum": 0},
|
|
85
|
+
"duration_s": {"type": "number", "exclusiveMinimum": 0},
|
|
86
|
+
"max_edges": {"type": "integer", "minimum": 1, "maximum": 1000},
|
|
87
|
+
},
|
|
88
|
+
"required": ["capture_id", "channel"],
|
|
89
|
+
"additionalProperties": False,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "decode_uart",
|
|
94
|
+
"description": (
|
|
95
|
+
"Decode UART/RS-232-style asynchronous serial from a saved channel window. "
|
|
96
|
+
"Always report framing/parity warnings rather than silently trusting text."
|
|
97
|
+
),
|
|
98
|
+
"inputSchema": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": {
|
|
101
|
+
"capture_id": {"type": "string"},
|
|
102
|
+
"channel": {"type": "string"},
|
|
103
|
+
"start_s": {"type": "number", "minimum": 0},
|
|
104
|
+
"duration_s": {"type": "number", "exclusiveMinimum": 0},
|
|
105
|
+
"max_bytes": {"type": "integer", "minimum": 1, "maximum": 65536},
|
|
106
|
+
"uart": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"baud": {"type": "integer", "minimum": 50},
|
|
110
|
+
"data_bits": {"type": "integer", "enum": [5, 6, 7, 8]},
|
|
111
|
+
"parity": {"type": "string", "enum": ["none", "even", "odd"]},
|
|
112
|
+
"stop_bits": {"type": "number", "enum": [1, 1.5, 2]},
|
|
113
|
+
"idle_high": {"type": "boolean"},
|
|
114
|
+
"inverted": {"type": "boolean"},
|
|
115
|
+
"msb_first": {"type": "boolean"},
|
|
116
|
+
},
|
|
117
|
+
"additionalProperties": False,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
"required": ["capture_id", "channel"],
|
|
121
|
+
"additionalProperties": False,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "decode_protocol",
|
|
126
|
+
"description": (
|
|
127
|
+
"Decode a saved capture with bundled single-layer or stacked protocol decoders. "
|
|
128
|
+
f"Protocols: {', '.join(supported_protocols())}. "
|
|
129
|
+
"Map protocol roles explicitly, for example channels={scl:D0,sda:D1}. "
|
|
130
|
+
"Inspect capabilities for each protocol's required/optional channels and typed options. "
|
|
131
|
+
"Returns bounded structured events, never raw waveform arrays."
|
|
132
|
+
),
|
|
133
|
+
"inputSchema": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": {
|
|
136
|
+
"capture_id": {"type": "string"},
|
|
137
|
+
"protocol": {"type": "string", "enum": supported_protocols()},
|
|
138
|
+
"channels": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"description": "Protocol role to capture channel, e.g. {\"scl\":\"D0\",\"sda\":\"D1\"}",
|
|
141
|
+
"additionalProperties": {"type": "string"},
|
|
142
|
+
},
|
|
143
|
+
"options": {
|
|
144
|
+
"type": "object",
|
|
145
|
+
"description": (
|
|
146
|
+
"Typed decoder options. Use decoder.option when stacked layers share "
|
|
147
|
+
"a name, for example spi.cpol=0. See capabilities."
|
|
148
|
+
),
|
|
149
|
+
"additionalProperties": True,
|
|
150
|
+
},
|
|
151
|
+
"start_s": {"type": "number", "minimum": 0},
|
|
152
|
+
"duration_s": {"type": "number", "exclusiveMinimum": 0},
|
|
153
|
+
"max_events": {"type": "integer", "minimum": 1, "maximum": 5000},
|
|
154
|
+
"include_bits": {"type": "boolean"},
|
|
155
|
+
"include_lower_layers": {
|
|
156
|
+
"type": "boolean",
|
|
157
|
+
"description": "Include lower-layer annotations for stacked protocols.",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
"required": ["capture_id", "protocol", "channels"],
|
|
161
|
+
"additionalProperties": False,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "import_csv",
|
|
166
|
+
"description": (
|
|
167
|
+
"Import a DSView CSV export (Export Data -> CSV) as a capture. This is the reliable "
|
|
168
|
+
"offline path when DSView was driven manually. Export a narrow time range first."
|
|
169
|
+
),
|
|
170
|
+
"inputSchema": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"properties": {
|
|
173
|
+
"path": {"type": "string"},
|
|
174
|
+
"channels": {"type": "array", "items": {"type": "string"}, "minItems": 1},
|
|
175
|
+
"label": {"type": "string", "maxLength": 120},
|
|
176
|
+
},
|
|
177
|
+
"required": ["path"],
|
|
178
|
+
"additionalProperties": False,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "measure_period",
|
|
183
|
+
"description": (
|
|
184
|
+
"Measure period, frequency, duty cycle and jitter of a clock/PWM channel. "
|
|
185
|
+
"Returns periodic=false when fewer than two rising edges exist in the window."
|
|
186
|
+
),
|
|
187
|
+
"inputSchema": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"properties": {
|
|
190
|
+
"capture_id": {"type": "string"},
|
|
191
|
+
"channel": {"type": "string"},
|
|
192
|
+
"start_s": {"type": "number", "minimum": 0},
|
|
193
|
+
"duration_s": {"type": "number", "exclusiveMinimum": 0},
|
|
194
|
+
},
|
|
195
|
+
"required": ["capture_id", "channel"],
|
|
196
|
+
"additionalProperties": False,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class McpServer:
|
|
203
|
+
def __init__(self, service: LogicAgentService, stdin: BinaryIO | None = None, stdout: BinaryIO | None = None) -> None:
|
|
204
|
+
self.service = service
|
|
205
|
+
self.stdin = stdin or sys.stdin.buffer
|
|
206
|
+
self.stdout = stdout or sys.stdout.buffer
|
|
207
|
+
|
|
208
|
+
def serve(self) -> None:
|
|
209
|
+
for raw in self.stdin:
|
|
210
|
+
if not raw.strip():
|
|
211
|
+
continue
|
|
212
|
+
try:
|
|
213
|
+
message = json.loads(raw)
|
|
214
|
+
except json.JSONDecodeError:
|
|
215
|
+
self._write(None, {"code": -32700, "message": "Parse error"})
|
|
216
|
+
continue
|
|
217
|
+
if not isinstance(message, dict) or "method" not in message:
|
|
218
|
+
self._write(None, {"code": -32600, "message": "Invalid Request"})
|
|
219
|
+
continue
|
|
220
|
+
if "id" not in message:
|
|
221
|
+
continue # notifications do not receive responses
|
|
222
|
+
self._write(message["id"], self._dispatch(message["method"], message.get("params") or {}))
|
|
223
|
+
|
|
224
|
+
def _dispatch(self, method: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
225
|
+
try:
|
|
226
|
+
if method == "initialize":
|
|
227
|
+
return self._result(
|
|
228
|
+
{
|
|
229
|
+
"protocolVersion": str(params.get("protocolVersion") or "2024-11-05"),
|
|
230
|
+
"capabilities": {"tools": {}, "resources": {}},
|
|
231
|
+
"serverInfo": {"name": "logic-agent", "version": __version__},
|
|
232
|
+
"instructions": (
|
|
233
|
+
"Capture a short window first. Inspect channel summaries and hints, then "
|
|
234
|
+
"call analyze_window on a narrower window. Use decode_protocol for "
|
|
235
|
+
"registered single-layer and stacked protocols, and decode_uart for "
|
|
236
|
+
"asynchronous serial. Treat "
|
|
237
|
+
"zero-edge or framing-error results as uncertainty, not proof of "
|
|
238
|
+
"protocol behavior. Never present raw waveforms to the user as analysis."
|
|
239
|
+
),
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
if method == "ping":
|
|
243
|
+
return self._result({})
|
|
244
|
+
if method == "tools/list":
|
|
245
|
+
return self._result({"tools": TOOLS})
|
|
246
|
+
if method == "resources/list":
|
|
247
|
+
return self._result(
|
|
248
|
+
{
|
|
249
|
+
"resources": [
|
|
250
|
+
{
|
|
251
|
+
"uri": DEFAULT_RESOURCE_URI_TEMPLATE.format(capture_id=item["id"]),
|
|
252
|
+
"name": f"capture {item['id']}",
|
|
253
|
+
"mimeType": "application/json",
|
|
254
|
+
}
|
|
255
|
+
for item in self.service.store.list()
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
if method == "resources/read":
|
|
260
|
+
return self._read_resource(params)
|
|
261
|
+
if method == "tools/call":
|
|
262
|
+
return self._call_tool(params)
|
|
263
|
+
return self._error(-32601, f"Method not found: {method}")
|
|
264
|
+
except LogicAgentError as exc:
|
|
265
|
+
return self._error(-32000, exc.message, data=exc.to_dict())
|
|
266
|
+
except Exception as exc: # pragma: no cover - defensive protocol boundary
|
|
267
|
+
return self._error(-32603, f"Internal error: {type(exc).__name__}")
|
|
268
|
+
|
|
269
|
+
def _call_tool(self, params: dict[str, Any]) -> dict[str, Any]:
|
|
270
|
+
name = params.get("name")
|
|
271
|
+
args = params.get("arguments") or {}
|
|
272
|
+
if not isinstance(args, dict):
|
|
273
|
+
return self._error(-32602, "arguments must be an object")
|
|
274
|
+
handlers = {
|
|
275
|
+
"capabilities": lambda: self.service.capabilities(),
|
|
276
|
+
"list_devices": lambda: self.service.list_devices(args.get("backend")),
|
|
277
|
+
"capture": lambda: self.service.capture(args),
|
|
278
|
+
"list_captures": self.service.list_captures,
|
|
279
|
+
"self_test": self.service.self_test,
|
|
280
|
+
"analyze_window": lambda: self.service.analyze_window(args),
|
|
281
|
+
"decode_uart": lambda: self.service.decode_uart(args),
|
|
282
|
+
"decode_protocol": lambda: self.service.decode_protocol(args),
|
|
283
|
+
"import_csv": lambda: self.service.import_csv(args),
|
|
284
|
+
"measure_period": lambda: self.service.measure_period(args),
|
|
285
|
+
}
|
|
286
|
+
try:
|
|
287
|
+
payload = handlers[name]()
|
|
288
|
+
except KeyError:
|
|
289
|
+
return self._error(-32602, f"Unknown tool: {name}")
|
|
290
|
+
except LogicAgentError as exc:
|
|
291
|
+
payload = exc.to_dict()
|
|
292
|
+
text = json.dumps(payload, ensure_ascii=False)
|
|
293
|
+
is_error = payload.get("ok") is False
|
|
294
|
+
if len(text) > self.service.limits.max_tool_chars:
|
|
295
|
+
return self._error(-32001, "Tool result exceeded max_tool_chars; ask for a narrower window")
|
|
296
|
+
return self._result(
|
|
297
|
+
{
|
|
298
|
+
"content": [{"type": "text", "text": text}],
|
|
299
|
+
"structuredContent": payload,
|
|
300
|
+
"isError": is_error,
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
def _read_resource(self, params: dict[str, Any]) -> dict[str, Any]:
|
|
305
|
+
uri = str(params.get("uri", ""))
|
|
306
|
+
prefix = "logic-agent://captures/"
|
|
307
|
+
if not uri.startswith(prefix):
|
|
308
|
+
return self._error(-32002, f"Unsupported resource URI: {uri}")
|
|
309
|
+
capture_id = uri[len(prefix):].strip("/")
|
|
310
|
+
text, mime = self.service.read_resource(capture_id)
|
|
311
|
+
return self._result({"contents": [{"uri": uri, "mimeType": mime, "text": text}]})
|
|
312
|
+
|
|
313
|
+
def _result(self, result: dict[str, Any]) -> dict[str, Any]:
|
|
314
|
+
return {"jsonrpc": "2.0", "result": result}
|
|
315
|
+
|
|
316
|
+
def _error(self, code: int, message: str, *, data: dict | None = None) -> dict[str, Any]:
|
|
317
|
+
error: dict[str, Any] = {"code": code, "message": message}
|
|
318
|
+
if data:
|
|
319
|
+
error["data"] = data
|
|
320
|
+
return {"jsonrpc": "2.0", "error": error}
|
|
321
|
+
|
|
322
|
+
def _write(self, request_id: Any, payload: dict[str, Any]) -> None:
|
|
323
|
+
message = {"jsonrpc": "2.0", **payload}
|
|
324
|
+
if request_id is not None:
|
|
325
|
+
message["id"] = request_id
|
|
326
|
+
self.stdout.write(json.dumps(message, ensure_ascii=False).encode("utf-8") + b"\n")
|
|
327
|
+
self.stdout.flush()
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def main(argv: list[str] | None = None) -> int:
|
|
331
|
+
parser = argparse.ArgumentParser(prog="logic-agent-mcp", description="Logic analyzer MCP server (stdio)")
|
|
332
|
+
parser.add_argument("--data-dir", type=Path, default=None)
|
|
333
|
+
parser.add_argument("--backend", choices=["mock", "sigrok", "dslab"], default=None)
|
|
334
|
+
parser.add_argument("--version", action="version", version=__version__)
|
|
335
|
+
args = parser.parse_args(argv)
|
|
336
|
+
service = LogicAgentService(data_dir=args.data_dir)
|
|
337
|
+
if args.backend:
|
|
338
|
+
service.default_backend = args.backend
|
|
339
|
+
McpServer(service).serve()
|
|
340
|
+
return 0
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
if __name__ == "__main__":
|
|
344
|
+
raise SystemExit(main())
|
|
345
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any, Mapping
|
|
7
|
+
|
|
8
|
+
from .errors import ValidationError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class Channel:
|
|
13
|
+
id: str
|
|
14
|
+
name: str
|
|
15
|
+
index: int
|
|
16
|
+
|
|
17
|
+
def to_dict(self) -> dict[str, Any]:
|
|
18
|
+
return {"id": self.id, "name": self.name, "index": self.index}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True)
|
|
22
|
+
class Trigger:
|
|
23
|
+
channel: str
|
|
24
|
+
edge: str = "rising"
|
|
25
|
+
|
|
26
|
+
def validate(self) -> None:
|
|
27
|
+
if self.edge not in {"rising", "falling", "either"}:
|
|
28
|
+
raise ValidationError("edge must be one of: rising, falling, either")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(frozen=True)
|
|
32
|
+
class CaptureRequest:
|
|
33
|
+
channels: tuple[str, ...]
|
|
34
|
+
sample_rate_hz: int
|
|
35
|
+
duration_s: float
|
|
36
|
+
backend: str | None = None
|
|
37
|
+
device: str | None = None
|
|
38
|
+
trigger: Trigger | None = None
|
|
39
|
+
label: str | None = None
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def from_args(cls, args: Mapping[str, Any]) -> "CaptureRequest":
|
|
43
|
+
raw_channels = args.get("channels")
|
|
44
|
+
if not isinstance(raw_channels, list) or not raw_channels:
|
|
45
|
+
raise ValidationError("channels must be a non-empty array, for example ['D0', 'D1']")
|
|
46
|
+
channels = tuple(str(channel).strip() for channel in raw_channels if str(channel).strip())
|
|
47
|
+
if not channels:
|
|
48
|
+
raise ValidationError("channels must contain at least one channel id")
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
sample_rate_hz = int(args.get("sample_rate_hz"))
|
|
52
|
+
duration_s = float(args.get("duration_s"))
|
|
53
|
+
except (TypeError, ValueError) as exc:
|
|
54
|
+
raise ValidationError("sample_rate_hz and duration_s must be numbers") from exc
|
|
55
|
+
|
|
56
|
+
raw_trigger = args.get("trigger")
|
|
57
|
+
trigger = None
|
|
58
|
+
if raw_trigger is not None:
|
|
59
|
+
if not isinstance(raw_trigger, Mapping):
|
|
60
|
+
raise ValidationError("trigger must be an object")
|
|
61
|
+
trigger = Trigger(
|
|
62
|
+
channel=str(raw_trigger.get("channel", "")),
|
|
63
|
+
edge=str(raw_trigger.get("edge", "rising")),
|
|
64
|
+
)
|
|
65
|
+
if not trigger.channel:
|
|
66
|
+
raise ValidationError("trigger.channel is required")
|
|
67
|
+
trigger.validate()
|
|
68
|
+
|
|
69
|
+
label = args.get("label")
|
|
70
|
+
if label is not None:
|
|
71
|
+
label = str(label).strip()
|
|
72
|
+
if len(label) > 120:
|
|
73
|
+
raise ValidationError("label must be at most 120 characters")
|
|
74
|
+
|
|
75
|
+
request = cls(
|
|
76
|
+
channels=channels,
|
|
77
|
+
sample_rate_hz=sample_rate_hz,
|
|
78
|
+
duration_s=duration_s,
|
|
79
|
+
backend=_optional_str(args.get("backend")),
|
|
80
|
+
device=_optional_str(args.get("device")),
|
|
81
|
+
trigger=trigger,
|
|
82
|
+
label=label or None,
|
|
83
|
+
)
|
|
84
|
+
request.validate()
|
|
85
|
+
return request
|
|
86
|
+
|
|
87
|
+
def validate(self) -> None:
|
|
88
|
+
if self.sample_rate_hz <= 0:
|
|
89
|
+
raise ValidationError("sample_rate_hz must be positive")
|
|
90
|
+
if self.duration_s <= 0:
|
|
91
|
+
raise ValidationError("duration_s must be positive")
|
|
92
|
+
if len(set(self.channels)) != len(self.channels):
|
|
93
|
+
raise ValidationError("channels must not contain duplicates")
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def sample_count(self) -> int:
|
|
97
|
+
return max(1, round(self.sample_rate_hz * self.duration_s))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class CapturedSignal:
|
|
102
|
+
backend: str
|
|
103
|
+
device_id: str
|
|
104
|
+
device_label: str
|
|
105
|
+
channels: tuple[Channel, ...]
|
|
106
|
+
sample_rate_hz: int
|
|
107
|
+
samples: dict[str, bytes]
|
|
108
|
+
native_files: dict[str, Path] = field(default_factory=dict)
|
|
109
|
+
trigger_applied: bool = False
|
|
110
|
+
warnings: list[str] = field(default_factory=list)
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def sample_count(self) -> int:
|
|
114
|
+
if not self.samples:
|
|
115
|
+
return 0
|
|
116
|
+
return len(next(iter(self.samples.values())))
|
|
117
|
+
|
|
118
|
+
def validate(self) -> None:
|
|
119
|
+
if self.sample_rate_hz <= 0:
|
|
120
|
+
raise ValidationError("backend returned a non-positive sample rate")
|
|
121
|
+
if not self.channels:
|
|
122
|
+
raise ValidationError("backend returned no channels")
|
|
123
|
+
lengths = {channel.id: len(self.samples.get(channel.id, b"")) for channel in self.channels}
|
|
124
|
+
if any(length == 0 for length in lengths.values()):
|
|
125
|
+
raise ValidationError("backend returned an empty channel", details={"lengths": lengths})
|
|
126
|
+
if len(set(lengths.values())) != 1:
|
|
127
|
+
raise ValidationError("backend returned channels with different lengths", details={"lengths": lengths})
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@dataclass(frozen=True)
|
|
131
|
+
class Limits:
|
|
132
|
+
max_channels: int = 16
|
|
133
|
+
max_sample_rate_hz: int = 50_000_000
|
|
134
|
+
max_duration_s: float = 60.0
|
|
135
|
+
max_total_samples: int = 5_000_000
|
|
136
|
+
max_capture_bytes: int = 100_000_000
|
|
137
|
+
max_tool_chars: int = 64_000
|
|
138
|
+
max_resource_bytes: int = 2_000_000
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def utc_now_iso() -> str:
|
|
142
|
+
return datetime.now(timezone.utc).isoformat(timespec="seconds")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _optional_str(value: Any) -> str | None:
|
|
146
|
+
if value is None:
|
|
147
|
+
return None
|
|
148
|
+
text = str(value).strip()
|
|
149
|
+
return text or None
|
|
150
|
+
|