logic-agent-mcp 0.0.0-stage → 1.2.1
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 +200 -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/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/bin/zlib1.dll +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,84 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from .errors import ValidationError
|
|
6
|
+
from .signal import edge_indices, summarize_channel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class Window:
|
|
11
|
+
offset_samples: int
|
|
12
|
+
samples: bytes
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def select_window(samples: bytes, sample_rate_hz: int, start_s: float, duration_s: float | None) -> Window:
|
|
16
|
+
if start_s < 0:
|
|
17
|
+
raise ValidationError("start_s must be non-negative")
|
|
18
|
+
offset = int(round(start_s * sample_rate_hz))
|
|
19
|
+
if offset >= len(samples):
|
|
20
|
+
raise ValidationError("start_s is outside the capture", details={"capture_duration_s": len(samples) / sample_rate_hz})
|
|
21
|
+
if duration_s is None:
|
|
22
|
+
stop = len(samples)
|
|
23
|
+
else:
|
|
24
|
+
if duration_s <= 0:
|
|
25
|
+
raise ValidationError("duration_s must be positive")
|
|
26
|
+
stop = min(len(samples), offset + max(1, int(round(duration_s * sample_rate_hz))))
|
|
27
|
+
return Window(offset_samples=offset, samples=samples[offset:stop])
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def window_report(
|
|
31
|
+
window: Window,
|
|
32
|
+
channel: str,
|
|
33
|
+
sample_rate_hz: int,
|
|
34
|
+
*,
|
|
35
|
+
max_edges: int = 80,
|
|
36
|
+
) -> dict:
|
|
37
|
+
if max_edges <= 0:
|
|
38
|
+
raise ValidationError("max_edges must be positive")
|
|
39
|
+
summary = summarize_channel(channel, window.samples, sample_rate_hz).to_dict()
|
|
40
|
+
rising, falling = edge_indices(window.samples)
|
|
41
|
+
edges = sorted([(index, "rising") for index in rising] + [(index, "falling") for index in falling])
|
|
42
|
+
returned = edges[:max_edges]
|
|
43
|
+
return {
|
|
44
|
+
"offset_s": round(window.offset_samples / sample_rate_hz, 9),
|
|
45
|
+
"duration_s": round(len(window.samples) / sample_rate_hz, 9),
|
|
46
|
+
"sample_count": len(window.samples),
|
|
47
|
+
"summary": summary,
|
|
48
|
+
"edges": [
|
|
49
|
+
{
|
|
50
|
+
"index": window.offset_samples + index,
|
|
51
|
+
"time_s": round((window.offset_samples + index) / sample_rate_hz, 9),
|
|
52
|
+
"type": kind,
|
|
53
|
+
}
|
|
54
|
+
for index, kind in returned
|
|
55
|
+
],
|
|
56
|
+
"edges_truncated": len(edges) > len(returned),
|
|
57
|
+
"total_edges": len(edges),
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def protocol_hints(summary: dict) -> list[str]:
|
|
62
|
+
"""Cheap, deterministic hints that steer the agent toward a decoder."""
|
|
63
|
+
hints: list[str] = []
|
|
64
|
+
frequency = summary.get("estimated_frequency_hz")
|
|
65
|
+
transitions = summary.get("transitions", 0)
|
|
66
|
+
high_ratio = summary.get("high_ratio", 0)
|
|
67
|
+
if transitions == 0:
|
|
68
|
+
hints.append("No edges in this window: line is idle, mis-probed, or the window is too narrow.")
|
|
69
|
+
return hints
|
|
70
|
+
if 0.2 < high_ratio < 0.8 and frequency:
|
|
71
|
+
hints.append(
|
|
72
|
+
f"Periodic square-ish activity near {frequency:g} Hz; check it as a clock/PWM before decoding serial data."
|
|
73
|
+
)
|
|
74
|
+
if 0.02 < high_ratio < 0.98 and transitions >= 8:
|
|
75
|
+
hints.append("Irregular edges may be asynchronous serial (UART) or a framed bus (I2C/SPI).")
|
|
76
|
+
min_high = summary.get("min_high_s")
|
|
77
|
+
min_low = summary.get("min_low_s")
|
|
78
|
+
if min_high and min_low:
|
|
79
|
+
shortest = min(min_high, min_low)
|
|
80
|
+
if shortest > 0:
|
|
81
|
+
estimated_baud = round(1 / shortest)
|
|
82
|
+
hints.append(f"Shortest pulse is {shortest:g} s; if this is UART, try baud near {estimated_baud}.")
|
|
83
|
+
return hints
|
|
84
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Protocol
|
|
5
|
+
|
|
6
|
+
from ..models import CaptureRequest, CapturedSignal
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class Device:
|
|
11
|
+
id: str
|
|
12
|
+
name: str
|
|
13
|
+
driver: str
|
|
14
|
+
channels: tuple[str, ...]
|
|
15
|
+
serial: str | None = None
|
|
16
|
+
connected: bool = True
|
|
17
|
+
|
|
18
|
+
def to_dict(self) -> dict:
|
|
19
|
+
return {
|
|
20
|
+
"id": self.id,
|
|
21
|
+
"name": self.name,
|
|
22
|
+
"driver": self.driver,
|
|
23
|
+
"channels": list(self.channels),
|
|
24
|
+
"serial": self.serial,
|
|
25
|
+
"connected": self.connected,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Backend(Protocol):
|
|
30
|
+
name: str
|
|
31
|
+
|
|
32
|
+
def list_devices(self) -> list[Device]:
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
def capture(self, request: CaptureRequest) -> CapturedSignal:
|
|
36
|
+
...
|
|
37
|
+
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
import tempfile
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from ..errors import BackendUnavailableError, CaptureError, ValidationError
|
|
12
|
+
from ..models import CaptureRequest, CapturedSignal, Channel
|
|
13
|
+
from .base import Device
|
|
14
|
+
|
|
15
|
+
_EDGE = {"rising": "R", "falling": "F", "either": "C"}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True)
|
|
19
|
+
class _DslabDevice(Device):
|
|
20
|
+
handle: int = 0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DslabBackend:
|
|
24
|
+
"""DSLogic Plus capture through the local dslab CLI.
|
|
25
|
+
|
|
26
|
+
dslab links DreamSourceLab's libsigrok4DSL. Raw samples use DSLogic's
|
|
27
|
+
cross-block layout: 64 samples x enabled channels, one bit per sample.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
name = "dslab"
|
|
31
|
+
|
|
32
|
+
def __init__(self, executable: str | None = None, timeout_s: float = 120.0) -> None:
|
|
33
|
+
self.executable = executable or os.environ.get("DSLAB_EXE") or self._discover()
|
|
34
|
+
self.timeout_s = timeout_s
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def _discover() -> str | None:
|
|
38
|
+
app = Path(__file__).resolve().parents[2] # <root>/runtime/app in the portable bundle
|
|
39
|
+
candidates = [
|
|
40
|
+
# Portable bundle: runtime/app/logic_agent/backends -> runtime/bin/dslab.exe.
|
|
41
|
+
app / "bin" / "dslab.exe",
|
|
42
|
+
app.parent / "bin" / "dslab.exe",
|
|
43
|
+
# Source checkout: dslab/build/dslab.exe.
|
|
44
|
+
app / "dslab" / "build" / "dslab.exe",
|
|
45
|
+
Path.cwd() / "dslab" / "build" / "dslab.exe",
|
|
46
|
+
]
|
|
47
|
+
for item in candidates:
|
|
48
|
+
if item.is_file():
|
|
49
|
+
return str(item)
|
|
50
|
+
return shutil.which("dslab")
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def available(self) -> bool:
|
|
54
|
+
return bool(self.executable) and Path(self.executable).is_file()
|
|
55
|
+
|
|
56
|
+
def _require_executable(self) -> str:
|
|
57
|
+
if not self.available:
|
|
58
|
+
raise BackendUnavailableError(
|
|
59
|
+
"dslab.exe was not found. Build dslab and set DSLAB_EXE to its full path."
|
|
60
|
+
)
|
|
61
|
+
return str(self.executable)
|
|
62
|
+
|
|
63
|
+
def list_devices(self) -> list[Device]:
|
|
64
|
+
payload = self._run(["devices", "--json"])
|
|
65
|
+
raw_devices = payload.get("devices")
|
|
66
|
+
if not isinstance(raw_devices, list):
|
|
67
|
+
raise CaptureError("dslab devices returned no device array")
|
|
68
|
+
devices = []
|
|
69
|
+
for item in raw_devices:
|
|
70
|
+
name = str(item.get("name") or "DSLogic")
|
|
71
|
+
handle = int(item.get("handle") or 0)
|
|
72
|
+
devices.append(
|
|
73
|
+
_DslabDevice(
|
|
74
|
+
id=f"handle-{handle}" if handle else "dslogic",
|
|
75
|
+
name=name,
|
|
76
|
+
driver="dslab",
|
|
77
|
+
channels=tuple(f"D{i}" for i in range(16)),
|
|
78
|
+
serial=str(handle) if handle else None,
|
|
79
|
+
handle=handle,
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
return devices
|
|
83
|
+
|
|
84
|
+
def capture(self, request: CaptureRequest) -> CapturedSignal:
|
|
85
|
+
executable = self._require_executable()
|
|
86
|
+
devices = self.list_devices()
|
|
87
|
+
if not devices:
|
|
88
|
+
raise BackendUnavailableError(
|
|
89
|
+
"dslab found no DSLogic device. Check USB power/data cable and run 'dslab firmware status --json'."
|
|
90
|
+
)
|
|
91
|
+
device = _select_device(devices, request.device)
|
|
92
|
+
|
|
93
|
+
# dslab emits raw data blocks in probe order (ascending channel
|
|
94
|
+
# index), regardless of the order in --channels. Sort both the
|
|
95
|
+
# command and the mapping so D3,D0 cannot silently swap waveforms.
|
|
96
|
+
requested_channels = tuple(
|
|
97
|
+
sorted(request.channels, key=lambda item: int(item[1:]))
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
command = [
|
|
101
|
+
"capture", "once",
|
|
102
|
+
"--channels", ",".join(requested_channels),
|
|
103
|
+
"--rate", str(request.sample_rate_hz),
|
|
104
|
+
"--samples", str(request.sample_count),
|
|
105
|
+
"--json",
|
|
106
|
+
]
|
|
107
|
+
if request.trigger is not None:
|
|
108
|
+
command += [
|
|
109
|
+
"--trigger",
|
|
110
|
+
f"{request.trigger.channel}={_EDGE[request.trigger.edge]}",
|
|
111
|
+
]
|
|
112
|
+
payload, stderr = self._run_with_stderr(command)
|
|
113
|
+
if not payload.get("ok"):
|
|
114
|
+
raise CaptureError(
|
|
115
|
+
"dslab capture failed",
|
|
116
|
+
details={"message": payload.get("message"), "stderr": stderr[-4000:]},
|
|
117
|
+
)
|
|
118
|
+
raw_path = Path(str(payload.get("raw_path") or ""))
|
|
119
|
+
if not raw_path.is_file():
|
|
120
|
+
raise CaptureError("dslab reported success but the raw file is missing")
|
|
121
|
+
raw = raw_path.read_bytes()
|
|
122
|
+
|
|
123
|
+
enabled = int(payload.get("enabled_channels") or len(requested_channels))
|
|
124
|
+
raw_bytes = int(payload.get("raw_bytes") or len(raw))
|
|
125
|
+
sample_count = int(payload.get("sample_count") or 0)
|
|
126
|
+
if enabled <= 0:
|
|
127
|
+
raise CaptureError("dslab returned no enabled channel count")
|
|
128
|
+
expected = (sample_count * enabled + 7) // 8
|
|
129
|
+
if raw_bytes < expected:
|
|
130
|
+
raise CaptureError(
|
|
131
|
+
"dslab returned fewer raw bytes than metadata claims",
|
|
132
|
+
details={"expected": expected, "raw_bytes": raw_bytes, "sample_count": sample_count},
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
samples = _unpack_cross(raw[:expected], sample_count, enabled)
|
|
136
|
+
channels = tuple(
|
|
137
|
+
Channel(id=channel, name=channel, index=int(channel[1:]))
|
|
138
|
+
for channel in requested_channels
|
|
139
|
+
)
|
|
140
|
+
samples = {channel.id: samples[index] for index, channel in enumerate(channels)}
|
|
141
|
+
|
|
142
|
+
warnings: list[str] = []
|
|
143
|
+
if payload.get("overflow"):
|
|
144
|
+
warnings.append("device reported buffer overflow")
|
|
145
|
+
if payload.get("timed_out"):
|
|
146
|
+
warnings.append("capture timed out")
|
|
147
|
+
if request.trigger is not None and not payload.get("triggered"):
|
|
148
|
+
warnings.append("trigger did not report a hit")
|
|
149
|
+
|
|
150
|
+
native = {
|
|
151
|
+
"dslab-raw": raw_path,
|
|
152
|
+
"dslab-meta": raw_path.with_name("meta.json"),
|
|
153
|
+
}
|
|
154
|
+
vcd = payload.get("vcd_path")
|
|
155
|
+
if vcd and Path(str(vcd)).is_file():
|
|
156
|
+
native["dslab-vcd"] = Path(str(vcd))
|
|
157
|
+
|
|
158
|
+
return CapturedSignal(
|
|
159
|
+
backend=self.name,
|
|
160
|
+
device_id=device.id,
|
|
161
|
+
device_label=device.name,
|
|
162
|
+
channels=channels,
|
|
163
|
+
sample_rate_hz=int(payload.get("sample_rate") or request.sample_rate_hz),
|
|
164
|
+
samples=samples,
|
|
165
|
+
native_files=native,
|
|
166
|
+
trigger_applied=request.trigger is not None,
|
|
167
|
+
warnings=warnings,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def self_test(self) -> dict:
|
|
171
|
+
"""Run the DSLogic internal test pattern through the real sample path."""
|
|
172
|
+
payload = self._run(["capture", "once", "--channels", "D0",
|
|
173
|
+
"--operation", "internal", "--samples", "4096",
|
|
174
|
+
"--json"])
|
|
175
|
+
if not payload.get("ok"):
|
|
176
|
+
raise CaptureError(
|
|
177
|
+
"dslab internal self-test failed",
|
|
178
|
+
details={"message": payload.get("message")},
|
|
179
|
+
)
|
|
180
|
+
raw_path = Path(str(payload.get("raw_path") or ""))
|
|
181
|
+
if not raw_path.is_file():
|
|
182
|
+
raise CaptureError("dslab self-test reported success but raw is missing")
|
|
183
|
+
raw = raw_path.read_bytes()
|
|
184
|
+
if not raw:
|
|
185
|
+
raise CaptureError("dslab self-test produced no samples")
|
|
186
|
+
# One enabled channel uses DSLogic's alternating test pattern; every
|
|
187
|
+
# byte is 0xAA or 0x55, and the stream must not be stuck high/low.
|
|
188
|
+
if any(byte not in (0xAA, 0x55) for byte in raw):
|
|
189
|
+
raise CaptureError(
|
|
190
|
+
"internal test pattern is not alternating (stuck or corrupt sample path)",
|
|
191
|
+
details={"raw_bytes": len(raw)},
|
|
192
|
+
)
|
|
193
|
+
ones = sum(byte.bit_count() for byte in raw)
|
|
194
|
+
if ones in (0, len(raw) * 8):
|
|
195
|
+
raise CaptureError("internal test pattern is stuck", details={"raw_bytes": len(raw)})
|
|
196
|
+
return {
|
|
197
|
+
"ok": True,
|
|
198
|
+
"mode": "internal-test-pattern",
|
|
199
|
+
"sample_rate_hz": int(payload.get("sample_rate") or 0),
|
|
200
|
+
"sample_count": int(payload.get("sample_count") or 0),
|
|
201
|
+
"raw_bytes": len(raw),
|
|
202
|
+
"run_dir": payload.get("run_dir"),
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
def _run(self, args: list[str]) -> dict:
|
|
206
|
+
payload, _ = self._run_with_stderr(args)
|
|
207
|
+
return payload
|
|
208
|
+
|
|
209
|
+
def _run_with_stderr(self, args: list[str]) -> tuple[dict, str]:
|
|
210
|
+
command = [self._require_executable(), *args]
|
|
211
|
+
try:
|
|
212
|
+
completed = subprocess.run(
|
|
213
|
+
command,
|
|
214
|
+
check=False,
|
|
215
|
+
capture_output=True,
|
|
216
|
+
text=True,
|
|
217
|
+
timeout=self.timeout_s,
|
|
218
|
+
encoding="utf-8",
|
|
219
|
+
errors="replace",
|
|
220
|
+
)
|
|
221
|
+
except subprocess.TimeoutExpired as exc:
|
|
222
|
+
raise CaptureError(
|
|
223
|
+
"dslab timed out",
|
|
224
|
+
details={"timeout_s": self.timeout_s, "command": command},
|
|
225
|
+
) from exc
|
|
226
|
+
except OSError as exc:
|
|
227
|
+
raise BackendUnavailableError(f"failed to start dslab: {exc}") from exc
|
|
228
|
+
text = (completed.stdout or "").strip()
|
|
229
|
+
try:
|
|
230
|
+
payload = json.loads(text.splitlines()[-1]) if text else {}
|
|
231
|
+
except json.JSONDecodeError as exc:
|
|
232
|
+
raise CaptureError(
|
|
233
|
+
"dslab returned invalid JSON",
|
|
234
|
+
details={"stdout": text[-4000:], "stderr": (completed.stderr or "")[-4000:]},
|
|
235
|
+
) from exc
|
|
236
|
+
if completed.returncode != 0 and payload.get("ok") is not False:
|
|
237
|
+
raise CaptureError(
|
|
238
|
+
"dslab failed",
|
|
239
|
+
details={
|
|
240
|
+
"returncode": completed.returncode,
|
|
241
|
+
"stdout": text[-4000:],
|
|
242
|
+
"stderr": (completed.stderr or "")[-4000:],
|
|
243
|
+
},
|
|
244
|
+
)
|
|
245
|
+
return payload, completed.stderr or ""
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _select_device(devices: list[Device], requested: str | None) -> Device:
|
|
249
|
+
if requested is None:
|
|
250
|
+
return devices[0]
|
|
251
|
+
for device in devices:
|
|
252
|
+
if requested in {device.id, device.name, device.serial}:
|
|
253
|
+
return device
|
|
254
|
+
raise ValidationError(
|
|
255
|
+
f"unknown device: {requested}",
|
|
256
|
+
details={"devices": [device.to_dict() for device in devices]},
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _unpack_cross(raw: bytes, sample_count: int, enabled: int) -> list[bytes]:
|
|
261
|
+
if enabled <= 0:
|
|
262
|
+
raise ValidationError("enabled channel count must be positive")
|
|
263
|
+
samples: list[bytearray] = [bytearray(sample_count) for _ in range(enabled)]
|
|
264
|
+
for sample in range(sample_count):
|
|
265
|
+
frame = sample // 64
|
|
266
|
+
bit = sample % 64
|
|
267
|
+
byte_index = bit // 8
|
|
268
|
+
mask = 1 << (bit % 8)
|
|
269
|
+
for channel in range(enabled):
|
|
270
|
+
offset = (frame * enabled + channel) * 8 + byte_index
|
|
271
|
+
if offset >= len(raw):
|
|
272
|
+
raise CaptureError(
|
|
273
|
+
"raw capture ended before the reported sample count",
|
|
274
|
+
details={"sample": sample, "channel": channel, "offset": offset, "bytes": len(raw)},
|
|
275
|
+
)
|
|
276
|
+
if raw[offset] & mask:
|
|
277
|
+
samples[channel][sample] = 1
|
|
278
|
+
return [bytes(item) for item in samples]
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
from ..errors import ValidationError
|
|
6
|
+
from ..models import CaptureRequest, CapturedSignal, Channel
|
|
7
|
+
from .base import Device
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MockBackend:
|
|
11
|
+
"""Deterministic signals for exercising the agent toolchain without hardware.
|
|
12
|
+
|
|
13
|
+
D0: UART TX, 8N1, carrying "PING 0x2A\\n" at 115200 baud.
|
|
14
|
+
D1: 1 kHz 25% duty-cycle PWM.
|
|
15
|
+
D2: 100 kHz clock burst, useful for testing frequency heuristics.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
name = "mock"
|
|
19
|
+
|
|
20
|
+
def list_devices(self) -> list[Device]:
|
|
21
|
+
return [
|
|
22
|
+
Device(
|
|
23
|
+
id="mock-0",
|
|
24
|
+
name="Mock Logic Analyzer (deterministic)",
|
|
25
|
+
driver="mock",
|
|
26
|
+
channels=("D0", "D1", "D2", "D3"),
|
|
27
|
+
)
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
def capture(self, request: CaptureRequest) -> CapturedSignal:
|
|
31
|
+
if request.device not in {None, "mock-0"}:
|
|
32
|
+
raise ValidationError(f"unknown mock device: {request.device}")
|
|
33
|
+
if request.sample_rate_hz < 1_000_000:
|
|
34
|
+
raise ValidationError("mock backend needs sample_rate_hz >= 1,000,000 for clean UART decoding")
|
|
35
|
+
|
|
36
|
+
sample_count = request.sample_count
|
|
37
|
+
generators = {
|
|
38
|
+
"D0": self._uart,
|
|
39
|
+
"D1": self._pwm,
|
|
40
|
+
"D2": self._clock_burst,
|
|
41
|
+
"D3": lambda count, rate: bytes([0]) * count,
|
|
42
|
+
}
|
|
43
|
+
unknown = [channel for channel in request.channels if channel not in generators]
|
|
44
|
+
if unknown:
|
|
45
|
+
raise ValidationError("mock backend has no signal for these channels", details={"channels": unknown})
|
|
46
|
+
|
|
47
|
+
samples = {
|
|
48
|
+
channel: bytes(generators[channel](sample_count, request.sample_rate_hz))
|
|
49
|
+
for channel in request.channels
|
|
50
|
+
}
|
|
51
|
+
warnings: list[str] = []
|
|
52
|
+
trigger_applied = False
|
|
53
|
+
if request.trigger is not None:
|
|
54
|
+
if request.trigger.channel not in samples:
|
|
55
|
+
raise ValidationError("trigger.channel must be one of the captured channels")
|
|
56
|
+
trigger_applied = True
|
|
57
|
+
if request.trigger.edge == "falling":
|
|
58
|
+
warnings.append("mock backend is free-running; trigger edge is reported but not aligned")
|
|
59
|
+
|
|
60
|
+
return CapturedSignal(
|
|
61
|
+
backend=self.name,
|
|
62
|
+
device_id="mock-0",
|
|
63
|
+
device_label="Mock Logic Analyzer (deterministic)",
|
|
64
|
+
channels=tuple(Channel(id=channel, name=channel, index=index) for index, channel in enumerate(request.channels)),
|
|
65
|
+
sample_rate_hz=request.sample_rate_hz,
|
|
66
|
+
samples=samples,
|
|
67
|
+
trigger_applied=trigger_applied,
|
|
68
|
+
warnings=warnings,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
def _uart(self, count: int, rate: int) -> list[int]:
|
|
72
|
+
bits_per_second = 115_200
|
|
73
|
+
samples_per_bit = rate / bits_per_second
|
|
74
|
+
payload = b"PING 0x2A\n"
|
|
75
|
+
result = [1] * count
|
|
76
|
+
cursor = float(int(rate * 0.002))
|
|
77
|
+
for byte in payload:
|
|
78
|
+
frame = [0] + [(byte >> bit) & 1 for bit in range(8)] + [1]
|
|
79
|
+
for bit in frame:
|
|
80
|
+
start = int(cursor)
|
|
81
|
+
end = min(count, round(cursor + samples_per_bit))
|
|
82
|
+
if start >= count:
|
|
83
|
+
return result
|
|
84
|
+
for index in range(start, end):
|
|
85
|
+
result[index] = bit
|
|
86
|
+
cursor += samples_per_bit
|
|
87
|
+
cursor += samples_per_bit # idle between bytes
|
|
88
|
+
return result
|
|
89
|
+
|
|
90
|
+
def _pwm(self, count: int, rate: int) -> list[int]:
|
|
91
|
+
period = rate / 1_000
|
|
92
|
+
high = period * 0.25
|
|
93
|
+
return [1 if (index % period) < high else 0 for index in range(count)]
|
|
94
|
+
|
|
95
|
+
def _clock_burst(self, count: int, rate: int) -> list[int]:
|
|
96
|
+
period = rate / 100_000
|
|
97
|
+
half = period / 2
|
|
98
|
+
start = int(rate * 0.01)
|
|
99
|
+
stop = int(rate * 0.02)
|
|
100
|
+
return [1 if start <= index < stop and (index % period) < half else 0 for index in range(count)]
|
|
101
|
+
|