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.
Files changed (449) hide show
  1. package/API.cmd +5 -0
  2. package/CAPTURE.cmd +8 -0
  3. package/CHECK.cmd +7 -0
  4. package/FIRMWARE-RECOVER.cmd +6 -0
  5. package/FIRMWARE-STATUS.cmd +8 -0
  6. package/INSTALL-DRIVER.cmd +6 -0
  7. package/INSTALL-MCP.cmd +16 -0
  8. package/LICENSE +31 -0
  9. package/MCP.cmd +5 -0
  10. package/README.md +127 -2
  11. package/SELF-TEST.cmd +6 -0
  12. package/THIRD-PARTY-NOTICES.md +32 -0
  13. package/VERIFY-FILES.cmd +6 -0
  14. package/VERSION.txt +17 -0
  15. package/VIEW.cmd +16 -0
  16. package/checksums.sha256 +449 -0
  17. package/docs/DRIVER.md +54 -0
  18. package/docs/DSLOGIC-PLUS.md +180 -0
  19. package/docs/FIRMWARE.md +53 -0
  20. package/docs/INSTALL.md +74 -0
  21. package/docs/MCP-CLIENTS.md +200 -0
  22. package/docs/PROTOCOLS.md +200 -0
  23. package/docs/TROUBLESHOOTING.md +41 -0
  24. package/docs/UPSTREAM-SYNC.md +141 -0
  25. package/docs/WAVEFORM-VIEWER.md +48 -0
  26. package/firmware/DSLogicPlus.fw +0 -0
  27. package/firmware/LICENSE-DreamSourceLab.txt +20 -0
  28. package/launcher/logic-agent-mcp.mjs +106 -0
  29. package/package.json +56 -6
  30. package/runtime/app/logic_agent/__init__.py +4 -0
  31. package/runtime/app/logic_agent/analysis.py +84 -0
  32. package/runtime/app/logic_agent/backends/__init__.py +7 -0
  33. package/runtime/app/logic_agent/backends/base.py +37 -0
  34. package/runtime/app/logic_agent/backends/dslab.py +278 -0
  35. package/runtime/app/logic_agent/backends/mock.py +101 -0
  36. package/runtime/app/logic_agent/backends/sigrok.py +252 -0
  37. package/runtime/app/logic_agent/cli.py +387 -0
  38. package/runtime/app/logic_agent/decoders.py +868 -0
  39. package/runtime/app/logic_agent/errors.py +50 -0
  40. package/runtime/app/logic_agent/importer.py +129 -0
  41. package/runtime/app/logic_agent/mcp_clients.py +956 -0
  42. package/runtime/app/logic_agent/mcp_server.py +345 -0
  43. package/runtime/app/logic_agent/models.py +150 -0
  44. package/runtime/app/logic_agent/protocols.py +233 -0
  45. package/runtime/app/logic_agent/service.py +378 -0
  46. package/runtime/app/logic_agent/signal.py +206 -0
  47. package/runtime/app/logic_agent/store.py +197 -0
  48. package/runtime/bin/_bz2.pyd +0 -0
  49. package/runtime/bin/_ctypes.pyd +0 -0
  50. package/runtime/bin/_decimal.pyd +0 -0
  51. package/runtime/bin/_elementtree.pyd +0 -0
  52. package/runtime/bin/_hashlib.pyd +0 -0
  53. package/runtime/bin/_lzma.pyd +0 -0
  54. package/runtime/bin/_multiprocessing.pyd +0 -0
  55. package/runtime/bin/_socket.pyd +0 -0
  56. package/runtime/bin/_sqlite3.pyd +0 -0
  57. package/runtime/bin/_ssl.pyd +0 -0
  58. package/runtime/bin/dslab.exe +0 -0
  59. package/runtime/bin/libglib-2.0-0.dll +0 -0
  60. package/runtime/bin/libiconv-2.dll +0 -0
  61. package/runtime/bin/libintl-8.dll +0 -0
  62. package/runtime/bin/libpcre2-8-0.dll +0 -0
  63. package/runtime/bin/libusb-1.0.dll +0 -0
  64. package/runtime/bin/libwinpthread-1.dll +0 -0
  65. package/runtime/bin/msvcp100.dll +0 -0
  66. package/runtime/bin/msvcr100.dll +0 -0
  67. package/runtime/bin/pyexpat.pyd +0 -0
  68. package/runtime/bin/python34.dll +0 -0
  69. package/runtime/bin/python34.zip +0 -0
  70. package/runtime/bin/res/DSCope.bin +0 -0
  71. package/runtime/bin/res/DSCope.fw +0 -0
  72. package/runtime/bin/res/DSCope1.def.dsc +88 -0
  73. package/runtime/bin/res/DSCope2.def.dsc +54 -0
  74. package/runtime/bin/res/DSCope20.bin +0 -0
  75. package/runtime/bin/res/DSCope20.fw +0 -0
  76. package/runtime/bin/res/DSCopeC20B.bin +0 -0
  77. package/runtime/bin/res/DSCopeC20P.bin +0 -0
  78. package/runtime/bin/res/DSCopeU2B100.bin +0 -0
  79. package/runtime/bin/res/DSCopeU2B20.bin +0 -0
  80. package/runtime/bin/res/DSCopeU2P20.bin +0 -0
  81. package/runtime/bin/res/DSCopeU3P100.bin +0 -0
  82. package/runtime/bin/res/DSLogic.fw +0 -0
  83. package/runtime/bin/res/DSLogic0.def.dsc +297 -0
  84. package/runtime/bin/res/DSLogic1.def.dsc +82 -0
  85. package/runtime/bin/res/DSLogic2.def.dsc +52 -0
  86. package/runtime/bin/res/DSLogic33.bin +0 -0
  87. package/runtime/bin/res/DSLogic50.bin +0 -0
  88. package/runtime/bin/res/DSLogicBasic.bin +0 -0
  89. package/runtime/bin/res/DSLogicPlus-pgl12-2.bin +0 -0
  90. package/runtime/bin/res/DSLogicPlus-pgl12.bin +0 -0
  91. package/runtime/bin/res/DSLogicPlus.bin +0 -0
  92. package/runtime/bin/res/DSLogicPlus.fw +0 -0
  93. package/runtime/bin/res/DSLogicPro.bin +0 -0
  94. package/runtime/bin/res/DSLogicPro.fw +0 -0
  95. package/runtime/bin/res/DSLogicU2Basic-pgl12-2.bin +0 -0
  96. package/runtime/bin/res/DSLogicU2Basic-pgl12.bin +0 -0
  97. package/runtime/bin/res/DSLogicU2Basic.bin +0 -0
  98. package/runtime/bin/res/DSLogicU2Pro16.bin +0 -0
  99. package/runtime/bin/res/DSLogicU3Pro16.bin +0 -0
  100. package/runtime/bin/res/DSLogicU3Pro32.bin +0 -0
  101. package/runtime/bin/res/license.txt +20 -0
  102. package/runtime/bin/res/virtual-demo1.dsc +68 -0
  103. package/runtime/bin/select.pyd +0 -0
  104. package/runtime/bin/sigrok-cli.exe +0 -0
  105. package/runtime/bin/unicodedata.pyd +0 -0
  106. package/runtime/bin/winsound.pyd +0 -0
  107. package/runtime/bin/zlib1.dll +0 -0
  108. package/runtime/decoders/ac97/__init__.py +38 -0
  109. package/runtime/decoders/ac97/pd.py +477 -0
  110. package/runtime/decoders/ad5626/__init__.py +25 -0
  111. package/runtime/decoders/ad5626/pd.py +62 -0
  112. package/runtime/decoders/ad79x0/__init__.py +25 -0
  113. package/runtime/decoders/ad79x0/pd.py +137 -0
  114. package/runtime/decoders/ade77xx/__init__.py +31 -0
  115. package/runtime/decoders/ade77xx/lists.py +102 -0
  116. package/runtime/decoders/ade77xx/pd.py +131 -0
  117. package/runtime/decoders/adf435x/__init__.py +29 -0
  118. package/runtime/decoders/adf435x/pd.py +230 -0
  119. package/runtime/decoders/adns5020/__init__.py +27 -0
  120. package/runtime/decoders/adns5020/pd.py +116 -0
  121. package/runtime/decoders/adxl345/__init__.py +26 -0
  122. package/runtime/decoders/adxl345/lists.py +96 -0
  123. package/runtime/decoders/adxl345/pd.py +453 -0
  124. package/runtime/decoders/am230x/__init__.py +36 -0
  125. package/runtime/decoders/am230x/pd.py +229 -0
  126. package/runtime/decoders/amulet_ascii/__init__.py +28 -0
  127. package/runtime/decoders/amulet_ascii/lists.py +73 -0
  128. package/runtime/decoders/amulet_ascii/pd.py +699 -0
  129. package/runtime/decoders/arm_etmv3/__init__.py +25 -0
  130. package/runtime/decoders/arm_etmv3/pd.py +567 -0
  131. package/runtime/decoders/arm_itm/__init__.py +25 -0
  132. package/runtime/decoders/arm_itm/pd.py +373 -0
  133. package/runtime/decoders/arm_tpiu/__init__.py +28 -0
  134. package/runtime/decoders/arm_tpiu/pd.py +131 -0
  135. package/runtime/decoders/atsha204a/__init__.py +30 -0
  136. package/runtime/decoders/atsha204a/pd.py +323 -0
  137. package/runtime/decoders/aud/__init__.py +31 -0
  138. package/runtime/decoders/aud/pd.py +108 -0
  139. package/runtime/decoders/avr_isp/__init__.py +25 -0
  140. package/runtime/decoders/avr_isp/parts.py +163 -0
  141. package/runtime/decoders/avr_isp/pd.py +278 -0
  142. package/runtime/decoders/avr_pdi/__init__.py +42 -0
  143. package/runtime/decoders/avr_pdi/pd.py +574 -0
  144. package/runtime/decoders/caliper/__init__.py +36 -0
  145. package/runtime/decoders/caliper/pd.py +146 -0
  146. package/runtime/decoders/can/__init__.py +31 -0
  147. package/runtime/decoders/can/pd.py +519 -0
  148. package/runtime/decoders/cc1101/__init__.py +28 -0
  149. package/runtime/decoders/cc1101/lists.py +115 -0
  150. package/runtime/decoders/cc1101/pd.py +294 -0
  151. package/runtime/decoders/cec/__init__.py +25 -0
  152. package/runtime/decoders/cec/pd.py +311 -0
  153. package/runtime/decoders/cec/protocoldata.py +117 -0
  154. package/runtime/decoders/cfp/__init__.py +34 -0
  155. package/runtime/decoders/cfp/pd.py +110 -0
  156. package/runtime/decoders/cjtag/__init__.py +36 -0
  157. package/runtime/decoders/cjtag/pd.py +323 -0
  158. package/runtime/decoders/common/__init__.py +19 -0
  159. package/runtime/decoders/common/plugtrx/__init__.py +20 -0
  160. package/runtime/decoders/common/plugtrx/mod.py +192 -0
  161. package/runtime/decoders/common/sdcard/__init__.py +20 -0
  162. package/runtime/decoders/common/sdcard/mod.py +150 -0
  163. package/runtime/decoders/common/srdhelper/__init__.py +20 -0
  164. package/runtime/decoders/common/srdhelper/mod.py +98 -0
  165. package/runtime/decoders/counter/__init__.py +28 -0
  166. package/runtime/decoders/counter/pd.py +145 -0
  167. package/runtime/decoders/dali/__init__.py +24 -0
  168. package/runtime/decoders/dali/lists.py +98 -0
  169. package/runtime/decoders/dali/pd.py +244 -0
  170. package/runtime/decoders/dcf77/__init__.py +28 -0
  171. package/runtime/decoders/dcf77/pd.py +311 -0
  172. package/runtime/decoders/dmx512/__init__.py +25 -0
  173. package/runtime/decoders/dmx512/pd.py +361 -0
  174. package/runtime/decoders/ds1307/__init__.py +25 -0
  175. package/runtime/decoders/ds1307/pd.py +270 -0
  176. package/runtime/decoders/ds2408/__init__.py +25 -0
  177. package/runtime/decoders/ds2408/pd.py +129 -0
  178. package/runtime/decoders/ds243x/__init__.py +25 -0
  179. package/runtime/decoders/ds243x/pd.py +270 -0
  180. package/runtime/decoders/ds28ea00/__init__.py +25 -0
  181. package/runtime/decoders/ds28ea00/pd.py +93 -0
  182. package/runtime/decoders/dsi/__init__.py +24 -0
  183. package/runtime/decoders/dsi/pd.py +157 -0
  184. package/runtime/decoders/edid/__init__.py +35 -0
  185. package/runtime/decoders/edid/pd.py +671 -0
  186. package/runtime/decoders/edid/pnpids.txt +2135 -0
  187. package/runtime/decoders/eeprom24xx/__init__.py +25 -0
  188. package/runtime/decoders/eeprom24xx/lists.py +214 -0
  189. package/runtime/decoders/eeprom24xx/pd.py +443 -0
  190. package/runtime/decoders/eeprom93xx/__init__.py +32 -0
  191. package/runtime/decoders/eeprom93xx/pd.py +163 -0
  192. package/runtime/decoders/em4100/__init__.py +24 -0
  193. package/runtime/decoders/em4100/pd.py +238 -0
  194. package/runtime/decoders/em4305/__init__.py +24 -0
  195. package/runtime/decoders/em4305/pd.py +394 -0
  196. package/runtime/decoders/enc28j60/__init__.py +32 -0
  197. package/runtime/decoders/enc28j60/lists.py +161 -0
  198. package/runtime/decoders/enc28j60/pd.py +294 -0
  199. package/runtime/decoders/flexray/__init__.py +32 -0
  200. package/runtime/decoders/flexray/pd.py +413 -0
  201. package/runtime/decoders/graycode/__init__.py +24 -0
  202. package/runtime/decoders/graycode/pd.py +197 -0
  203. package/runtime/decoders/guess_bitrate/__init__.py +40 -0
  204. package/runtime/decoders/guess_bitrate/pd.py +79 -0
  205. package/runtime/decoders/hdcp/__init__.py +27 -0
  206. package/runtime/decoders/hdcp/pd.py +191 -0
  207. package/runtime/decoders/i2c/__init__.py +25 -0
  208. package/runtime/decoders/i2c/pd.py +364 -0
  209. package/runtime/decoders/i2cdemux/__init__.py +27 -0
  210. package/runtime/decoders/i2cdemux/pd.py +80 -0
  211. package/runtime/decoders/i2cfilter/__init__.py +37 -0
  212. package/runtime/decoders/i2cfilter/pd.py +106 -0
  213. package/runtime/decoders/i2s/__init__.py +29 -0
  214. package/runtime/decoders/i2s/pd.py +179 -0
  215. package/runtime/decoders/ieee488/__init__.py +26 -0
  216. package/runtime/decoders/ieee488/pd.py +849 -0
  217. package/runtime/decoders/ir_irmp/__init__.py +25 -0
  218. package/runtime/decoders/ir_irmp/irmp_library.py +168 -0
  219. package/runtime/decoders/ir_irmp/pd.py +139 -0
  220. package/runtime/decoders/ir_nec/__init__.py +25 -0
  221. package/runtime/decoders/ir_nec/lists.py +93 -0
  222. package/runtime/decoders/ir_nec/pd.py +300 -0
  223. package/runtime/decoders/ir_rc5/__init__.py +24 -0
  224. package/runtime/decoders/ir_rc5/lists.py +93 -0
  225. package/runtime/decoders/ir_rc5/pd.py +182 -0
  226. package/runtime/decoders/ir_rc6/__init__.py +24 -0
  227. package/runtime/decoders/ir_rc6/pd.py +205 -0
  228. package/runtime/decoders/ir_sirc/__init__.py +26 -0
  229. package/runtime/decoders/ir_sirc/lists.py +201 -0
  230. package/runtime/decoders/ir_sirc/pd.py +215 -0
  231. package/runtime/decoders/jitter/__init__.py +29 -0
  232. package/runtime/decoders/jitter/pd.py +198 -0
  233. package/runtime/decoders/jtag/__init__.py +30 -0
  234. package/runtime/decoders/jtag/pd.py +235 -0
  235. package/runtime/decoders/jtag_ejtag/__init__.py +25 -0
  236. package/runtime/decoders/jtag_ejtag/pd.py +408 -0
  237. package/runtime/decoders/jtag_stm32/__init__.py +29 -0
  238. package/runtime/decoders/jtag_stm32/pd.py +269 -0
  239. package/runtime/decoders/lfast/__init__.py +35 -0
  240. package/runtime/decoders/lfast/pd.py +335 -0
  241. package/runtime/decoders/lin/__init__.py +28 -0
  242. package/runtime/decoders/lin/pd.py +247 -0
  243. package/runtime/decoders/lm75/__init__.py +25 -0
  244. package/runtime/decoders/lm75/pd.py +186 -0
  245. package/runtime/decoders/lpc/__init__.py +25 -0
  246. package/runtime/decoders/lpc/pd.py +365 -0
  247. package/runtime/decoders/ltc242x/__init__.py +25 -0
  248. package/runtime/decoders/ltc242x/pd.py +86 -0
  249. package/runtime/decoders/ltc26x7/__init__.py +25 -0
  250. package/runtime/decoders/ltc26x7/pd.py +187 -0
  251. package/runtime/decoders/maple_bus/__init__.py +25 -0
  252. package/runtime/decoders/maple_bus/pd.py +222 -0
  253. package/runtime/decoders/max72xx/__init__.py +25 -0
  254. package/runtime/decoders/max72xx/pd.py +130 -0
  255. package/runtime/decoders/mcp230xx/__init__.py +25 -0
  256. package/runtime/decoders/mcp230xx/pd.py +143 -0
  257. package/runtime/decoders/mcs48/__init__.py +31 -0
  258. package/runtime/decoders/mcs48/pd.py +126 -0
  259. package/runtime/decoders/mdio/__init__.py +39 -0
  260. package/runtime/decoders/mdio/pd.py +325 -0
  261. package/runtime/decoders/microwire/__init__.py +40 -0
  262. package/runtime/decoders/microwire/pd.py +194 -0
  263. package/runtime/decoders/midi/__init__.py +28 -0
  264. package/runtime/decoders/midi/lists.py +840 -0
  265. package/runtime/decoders/midi/pd.py +627 -0
  266. package/runtime/decoders/miller/__init__.py +26 -0
  267. package/runtime/decoders/miller/pd.py +190 -0
  268. package/runtime/decoders/mlx90614/__init__.py +25 -0
  269. package/runtime/decoders/mlx90614/pd.py +82 -0
  270. package/runtime/decoders/modbus/__init__.py +28 -0
  271. package/runtime/decoders/modbus/pd.py +941 -0
  272. package/runtime/decoders/morse/__init__.py +28 -0
  273. package/runtime/decoders/morse/pd.py +250 -0
  274. package/runtime/decoders/mrf24j40/__init__.py +25 -0
  275. package/runtime/decoders/mrf24j40/lists.py +165 -0
  276. package/runtime/decoders/mrf24j40/pd.py +188 -0
  277. package/runtime/decoders/mxc6225xu/__init__.py +28 -0
  278. package/runtime/decoders/mxc6225xu/pd.py +217 -0
  279. package/runtime/decoders/nes_gamepad/__init__.py +54 -0
  280. package/runtime/decoders/nes_gamepad/pd.py +92 -0
  281. package/runtime/decoders/nrf24l01/__init__.py +29 -0
  282. package/runtime/decoders/nrf24l01/pd.py +332 -0
  283. package/runtime/decoders/nrf905/__init__.py +26 -0
  284. package/runtime/decoders/nrf905/pd.py +301 -0
  285. package/runtime/decoders/numbers_and_state/__init__.py +41 -0
  286. package/runtime/decoders/numbers_and_state/pd.py +377 -0
  287. package/runtime/decoders/nunchuk/__init__.py +30 -0
  288. package/runtime/decoders/nunchuk/pd.py +207 -0
  289. package/runtime/decoders/onewire_link/__init__.py +56 -0
  290. package/runtime/decoders/onewire_link/pd.py +347 -0
  291. package/runtime/decoders/onewire_network/__init__.py +56 -0
  292. package/runtime/decoders/onewire_network/pd.py +185 -0
  293. package/runtime/decoders/ook/__init__.py +36 -0
  294. package/runtime/decoders/ook/pd.py +484 -0
  295. package/runtime/decoders/ook_oregon/__init__.py +25 -0
  296. package/runtime/decoders/ook_oregon/lists.py +75 -0
  297. package/runtime/decoders/ook_oregon/pd.py +389 -0
  298. package/runtime/decoders/ook_vis/__init__.py +25 -0
  299. package/runtime/decoders/ook_vis/pd.py +194 -0
  300. package/runtime/decoders/pan1321/__init__.py +25 -0
  301. package/runtime/decoders/pan1321/pd.py +164 -0
  302. package/runtime/decoders/parallel/__init__.py +45 -0
  303. package/runtime/decoders/parallel/pd.py +285 -0
  304. package/runtime/decoders/pca9571/__init__.py +25 -0
  305. package/runtime/decoders/pca9571/pd.py +122 -0
  306. package/runtime/decoders/pjdl/__init__.py +27 -0
  307. package/runtime/decoders/pjdl/pd.py +723 -0
  308. package/runtime/decoders/pjon/__init__.py +25 -0
  309. package/runtime/decoders/pjon/pd.py +603 -0
  310. package/runtime/decoders/ps2/__init__.py +26 -0
  311. package/runtime/decoders/ps2/pd.py +126 -0
  312. package/runtime/decoders/pwm/__init__.py +24 -0
  313. package/runtime/decoders/pwm/pd.py +167 -0
  314. package/runtime/decoders/qi/__init__.py +25 -0
  315. package/runtime/decoders/qi/pd.py +244 -0
  316. package/runtime/decoders/rc_encode/__init__.py +40 -0
  317. package/runtime/decoders/rc_encode/pd.py +215 -0
  318. package/runtime/decoders/rfm12/__init__.py +25 -0
  319. package/runtime/decoders/rfm12/pd.py +497 -0
  320. package/runtime/decoders/rgb_led_spi/__init__.py +25 -0
  321. package/runtime/decoders/rgb_led_spi/pd.py +72 -0
  322. package/runtime/decoders/rgb_led_ws281x/__init__.py +27 -0
  323. package/runtime/decoders/rgb_led_ws281x/pd.py +267 -0
  324. package/runtime/decoders/rtc8564/__init__.py +25 -0
  325. package/runtime/decoders/rtc8564/pd.py +254 -0
  326. package/runtime/decoders/sae_j1850_vpw/__init__.py +24 -0
  327. package/runtime/decoders/sae_j1850_vpw/pd.py +296 -0
  328. package/runtime/decoders/sbus_futaba/__init__.py +35 -0
  329. package/runtime/decoders/sbus_futaba/pd.py +273 -0
  330. package/runtime/decoders/sda2506/__init__.py +24 -0
  331. package/runtime/decoders/sda2506/pd.py +146 -0
  332. package/runtime/decoders/sdcard_sd/__init__.py +24 -0
  333. package/runtime/decoders/sdcard_sd/pd.py +554 -0
  334. package/runtime/decoders/sdcard_spi/__init__.py +68 -0
  335. package/runtime/decoders/sdcard_spi/pd.py +518 -0
  336. package/runtime/decoders/sdq/__init__.py +28 -0
  337. package/runtime/decoders/sdq/pd.py +131 -0
  338. package/runtime/decoders/seven_segment/__init__.py +24 -0
  339. package/runtime/decoders/seven_segment/pd.py +186 -0
  340. package/runtime/decoders/signature/__init__.py +25 -0
  341. package/runtime/decoders/signature/pd.py +142 -0
  342. package/runtime/decoders/sipi/__init__.py +30 -0
  343. package/runtime/decoders/sipi/pd.py +181 -0
  344. package/runtime/decoders/sle44xx/__init__.py +26 -0
  345. package/runtime/decoders/sle44xx/pd.py +541 -0
  346. package/runtime/decoders/smart_qspi/PORTING.md +22 -0
  347. package/runtime/decoders/smart_qspi/__init__.py +1 -0
  348. package/runtime/decoders/smart_qspi/pd.py +826 -0
  349. package/runtime/decoders/spdif/__init__.py +25 -0
  350. package/runtime/decoders/spdif/pd.py +295 -0
  351. package/runtime/decoders/spi/__init__.py +32 -0
  352. package/runtime/decoders/spi/pd.py +347 -0
  353. package/runtime/decoders/spiflash/__init__.py +30 -0
  354. package/runtime/decoders/spiflash/lists.py +178 -0
  355. package/runtime/decoders/spiflash/pd.py +537 -0
  356. package/runtime/decoders/ssi32/__init__.py +28 -0
  357. package/runtime/decoders/ssi32/pd.py +127 -0
  358. package/runtime/decoders/st25r39xx_spi/__init__.py +31 -0
  359. package/runtime/decoders/st25r39xx_spi/lists.py +231 -0
  360. package/runtime/decoders/st25r39xx_spi/pd.py +360 -0
  361. package/runtime/decoders/st7735/__init__.py +27 -0
  362. package/runtime/decoders/st7735/pd.py +173 -0
  363. package/runtime/decoders/stepper_motor/__init__.py +25 -0
  364. package/runtime/decoders/stepper_motor/pd.py +95 -0
  365. package/runtime/decoders/swd/__init__.py +34 -0
  366. package/runtime/decoders/swd/pd.py +350 -0
  367. package/runtime/decoders/swim/__init__.py +28 -0
  368. package/runtime/decoders/swim/pd.py +303 -0
  369. package/runtime/decoders/t55xx/__init__.py +25 -0
  370. package/runtime/decoders/t55xx/pd.py +326 -0
  371. package/runtime/decoders/tca6408a/__init__.py +25 -0
  372. package/runtime/decoders/tca6408a/pd.py +157 -0
  373. package/runtime/decoders/tdm_audio/__init__.py +25 -0
  374. package/runtime/decoders/tdm_audio/pd.py +116 -0
  375. package/runtime/decoders/timing/__init__.py +24 -0
  376. package/runtime/decoders/timing/pd.py +194 -0
  377. package/runtime/decoders/tlc5620/__init__.py +24 -0
  378. package/runtime/decoders/tlc5620/pd.py +212 -0
  379. package/runtime/decoders/uart/__init__.py +40 -0
  380. package/runtime/decoders/uart/pd.py +635 -0
  381. package/runtime/decoders/usb_packet/__init__.py +43 -0
  382. package/runtime/decoders/usb_packet/pd.py +401 -0
  383. package/runtime/decoders/usb_power_delivery/__init__.py +24 -0
  384. package/runtime/decoders/usb_power_delivery/pd.py +642 -0
  385. package/runtime/decoders/usb_request/__init__.py +49 -0
  386. package/runtime/decoders/usb_request/pd.py +386 -0
  387. package/runtime/decoders/usb_signalling/__init__.py +50 -0
  388. package/runtime/decoders/usb_signalling/pd.py +348 -0
  389. package/runtime/decoders/wiegand/__init__.py +28 -0
  390. package/runtime/decoders/wiegand/pd.py +148 -0
  391. package/runtime/decoders/x2444m/__init__.py +25 -0
  392. package/runtime/decoders/x2444m/pd.py +111 -0
  393. package/runtime/decoders/xfp/__init__.py +38 -0
  394. package/runtime/decoders/xfp/pd.py +486 -0
  395. package/runtime/decoders/xy2-100/__init__.py +28 -0
  396. package/runtime/decoders/xy2-100/pd.py +242 -0
  397. package/runtime/decoders/z80/__init__.py +36 -0
  398. package/runtime/decoders/z80/pd.py +358 -0
  399. package/runtime/decoders/z80/tables.py +1083 -0
  400. package/runtime/dslab.cmd +5 -0
  401. package/runtime/licenses/DreamSourceLab-res-MIT.txt +20 -0
  402. package/runtime/licenses/dslab-GPL-3.0.txt +674 -0
  403. package/runtime/licenses/logic-agent-MIT.txt +31 -0
  404. package/runtime/licenses/python-PSF.txt +645 -0
  405. package/runtime/licenses/sigrok-cli-GPL-3.0.txt +674 -0
  406. package/runtime/licenses/smart_qspi-PORTING.md +22 -0
  407. package/runtime/licenses/source/patches/dsview-v1.3.2-dslab.patch +124 -0
  408. package/runtime/logic-agent-mcp.cmd +9 -0
  409. package/runtime/logic-agent.cmd +9 -0
  410. package/runtime/python/LICENSE.txt +645 -0
  411. package/runtime/python/_asyncio.pyd +0 -0
  412. package/runtime/python/_bz2.pyd +0 -0
  413. package/runtime/python/_ctypes.pyd +0 -0
  414. package/runtime/python/_decimal.pyd +0 -0
  415. package/runtime/python/_elementtree.pyd +0 -0
  416. package/runtime/python/_hashlib.pyd +0 -0
  417. package/runtime/python/_lzma.pyd +0 -0
  418. package/runtime/python/_multiprocessing.pyd +0 -0
  419. package/runtime/python/_overlapped.pyd +0 -0
  420. package/runtime/python/_queue.pyd +0 -0
  421. package/runtime/python/_socket.pyd +0 -0
  422. package/runtime/python/_sqlite3.pyd +0 -0
  423. package/runtime/python/_ssl.pyd +0 -0
  424. package/runtime/python/_uuid.pyd +0 -0
  425. package/runtime/python/_wmi.pyd +0 -0
  426. package/runtime/python/_zoneinfo.pyd +0 -0
  427. package/runtime/python/libcrypto-3.dll +0 -0
  428. package/runtime/python/libffi-8.dll +0 -0
  429. package/runtime/python/libssl-3.dll +0 -0
  430. package/runtime/python/pyexpat.pyd +0 -0
  431. package/runtime/python/python.cat +0 -0
  432. package/runtime/python/python.exe +0 -0
  433. package/runtime/python/python3.dll +0 -0
  434. package/runtime/python/python313._pth +3 -0
  435. package/runtime/python/python313.dll +0 -0
  436. package/runtime/python/python313.zip +0 -0
  437. package/runtime/python/pythonw.exe +0 -0
  438. package/runtime/python/select.pyd +0 -0
  439. package/runtime/python/sqlite3.dll +0 -0
  440. package/runtime/python/unicodedata.pyd +0 -0
  441. package/runtime/python/vcruntime140.dll +0 -0
  442. package/runtime/python/vcruntime140_1.dll +0 -0
  443. package/runtime/python/winsound.pyd +0 -0
  444. package/runtime/scripts/deploy-check.ps1 +171 -0
  445. package/scripts/check.ps1 +14 -0
  446. package/scripts/firmware-recover.ps1 +27 -0
  447. package/scripts/install-driver.ps1 +30 -0
  448. package/scripts/self-test.ps1 +14 -0
  449. package/scripts/verify-files.py +39 -0
@@ -0,0 +1,849 @@
1
+ ##
2
+ ## This file is part of the libsigrokdecode project.
3
+ ##
4
+ ## Copyright (C) 2016 Rudolf Reuter <reuterru@arcor.de>
5
+ ## Copyright (C) 2017 Marcus Comstedt <marcus@mc.pp.se>
6
+ ## Copyright (C) 2019 Gerhard Sittig <gerhard.sittig@gmx.net>
7
+ ##
8
+ ## This program is free software; you can redistribute it and/or modify
9
+ ## it under the terms of the GNU General Public License as published by
10
+ ## the Free Software Foundation; either version 2 of the License, or
11
+ ## (at your option) any later version.
12
+ ##
13
+ ## This program is distributed in the hope that it will be useful,
14
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ ## GNU General Public License for more details.
17
+ ##
18
+ ## You should have received a copy of the GNU General Public License
19
+ ## along with this program; if not, see <http://www.gnu.org/licenses/>.
20
+ ##
21
+
22
+ # This file was created from earlier implementations of the 'gpib' and
23
+ # the 'iec' protocol decoders. It combines the parallel and the serial
24
+ # transmission variants in a single instance with optional inputs for
25
+ # maximum code re-use.
26
+
27
+ # TODO
28
+ # - Extend annotations for improved usability.
29
+ # - Keep talkers' data streams on separate annotation rows? Is this useful
30
+ # here at the GPIB level, or shall stacked decoders dispatch these? May
31
+ # depend on how often captures get inspected which involve multiple peers.
32
+ # - Make serial bit annotations optional? Could slow down interactive
33
+ # exploration for long captures (see USB).
34
+ # - Move the inlined Commodore IEC peripherals support to a stacked decoder
35
+ # when more peripherals get added.
36
+ # - SCPI over GPIB may "represent somewhat naturally" here already when
37
+ # text lines are a single run of data at the GPIB layer (each line between
38
+ # the address spec and either EOI or ATN). So a stacked SCPI decoder may
39
+ # only become necessary when the text lines' content shall get inspected.
40
+
41
+ import sigrokdecode as srd
42
+ from common.srdhelper import bitpack
43
+
44
+ '''
45
+ OUTPUT_PYTHON format for stacked decoders:
46
+
47
+ General packet format:
48
+ [<ptype>, <addr>, <pdata>]
49
+
50
+ This is the list of <ptype>s and their respective <pdata> values:
51
+
52
+ Raw bits and bytes at the physical transport level:
53
+ - 'IEC_BIT': <addr> is not applicable, <pdata> is the transport's bit value.
54
+ - 'GPIB_RAW': <addr> is not applicable, <pdata> is the transport's
55
+ byte value. Data bytes are in the 0x00-0xff range, command/address
56
+ bytes are in the 0x100-0x1ff range.
57
+
58
+ GPIB level byte fields (commands, addresses, pieces of data):
59
+ - 'COMMAND': <addr> is not applicable, <pdata> is the command's byte value.
60
+ - 'LISTEN': <addr> is the listener address (0-30), <pdata> is the raw
61
+ byte value (including the 0x20 offset).
62
+ - 'TALK': <addr> is the talker address (0-30), <pdata> is the raw byte
63
+ value (including the 0x40 offset).
64
+ - 'SECONDARY': <addr> is the secondary address (0-31), <pdata> is the
65
+ raw byte value (including the 0x60 offset).
66
+ - 'MSB_SET': <addr> as well as <pdata> are the raw byte value (including
67
+ the 0x80 offset). This usually does not happen for GPIB bytes with ATN
68
+ active, but was observed with the IEC bus and Commodore floppy drives,
69
+ when addressing channels within the device.
70
+ - 'DATA_BYTE': <addr> is the talker address (when available), <pdata>
71
+ is the raw data byte (transport layer, ATN inactive).
72
+ - 'PPOLL': <addr> is not applicable, <pdata> is a list of bit indices
73
+ (DIO1 to DIO8 order) which responded to the PP request.
74
+
75
+ Extracted payload information (peers and their communicated data):
76
+ - 'TALK_LISTEN': <addr> is the current talker, <pdata> is the list of
77
+ current listeners. These updates for the current "connected peers"
78
+ are sent when the set of peers changes, i.e. after talkers/listeners
79
+ got selected or deselected. Of course the data only covers what could
80
+ be gathered from the input data. Some controllers may not explicitly
81
+ address themselves, or captures may not include an early setup phase.
82
+ - 'TALKER_BYTES': <addr> is the talker address (when available), <pdata>
83
+ is the accumulated byte sequence between addressing a talker and EOI,
84
+ or the next command/address.
85
+ - 'TALKER_TEXT': <addr> is the talker address (when available), <pdata>
86
+ is the accumulated text sequence between addressing a talker and EOI,
87
+ or the next command/address.
88
+ '''
89
+
90
+ class ChannelError(Exception):
91
+ pass
92
+
93
+ def _format_ann_texts(fmts, **args):
94
+ if not fmts:
95
+ return None
96
+ return [fmt.format(**args) for fmt in fmts]
97
+
98
+ _cmd_table = {
99
+ # Command codes in the 0x00-0x1f range.
100
+ 0x01: ['Go To Local', 'GTL'],
101
+ 0x04: ['Selected Device Clear', 'SDC'],
102
+ 0x05: ['Parallel Poll Configure', 'PPC'],
103
+ 0x08: ['Global Execute Trigger', 'GET'],
104
+ 0x09: ['Take Control', 'TCT'],
105
+ 0x11: ['Local Lock Out', 'LLO'],
106
+ 0x14: ['Device Clear', 'DCL'],
107
+ 0x15: ['Parallel Poll Unconfigure', 'PPU'],
108
+ 0x18: ['Serial Poll Enable', 'SPE'],
109
+ 0x19: ['Serial Poll Disable', 'SPD'],
110
+ # Unknown type of command.
111
+ None: ['Unknown command 0x{cmd:02x}', 'command 0x{cmd:02x}', 'cmd {cmd:02x}', 'C{cmd_ord:c}'],
112
+ # Special listener/talker "addresses" (deselecting previous peers).
113
+ 0x3f: ['Unlisten', 'UNL'],
114
+ 0x5f: ['Untalk', 'UNT'],
115
+ }
116
+
117
+ def _is_command(b):
118
+ # Returns a tuple of booleans (or None when not applicable) whether
119
+ # the raw GPIB byte is: a command, an un-listen, an un-talk command.
120
+ if b in range(0x00, 0x20):
121
+ return True, None, None
122
+ if b in range(0x20, 0x40) and (b & 0x1f) == 31:
123
+ return True, True, False
124
+ if b in range(0x40, 0x60) and (b & 0x1f) == 31:
125
+ return True, False, True
126
+ return False, None, None
127
+
128
+ def _is_listen_addr(b):
129
+ if b in range(0x20, 0x40):
130
+ return b & 0x1f
131
+ return None
132
+
133
+ def _is_talk_addr(b):
134
+ if b in range(0x40, 0x60):
135
+ return b & 0x1f
136
+ return None
137
+
138
+ def _is_secondary_addr(b):
139
+ if b in range(0x60, 0x80):
140
+ return b & 0x1f
141
+ return None
142
+
143
+ def _is_msb_set(b):
144
+ if b & 0x80:
145
+ return b
146
+ return None
147
+
148
+ def _get_raw_byte(b, atn):
149
+ # "Decorate" raw byte values for stacked decoders.
150
+ return b | 0x100 if atn else b
151
+
152
+ def _get_raw_text(b, atn):
153
+ return ['{leader}{data:02x}'.format(leader = '/' if atn else '', data = b)]
154
+
155
+ def _get_command_texts(b):
156
+ fmts = _cmd_table.get(b, None)
157
+ known = fmts is not None
158
+ if not fmts:
159
+ fmts = _cmd_table.get(None, None)
160
+ if not fmts:
161
+ return known, None
162
+ return known, _format_ann_texts(fmts, cmd = b, cmd_ord = ord('0') + b)
163
+
164
+ def _get_address_texts(b):
165
+ laddr = _is_listen_addr(b)
166
+ taddr = _is_talk_addr(b)
167
+ saddr = _is_secondary_addr(b)
168
+ msb = _is_msb_set(b)
169
+ fmts = None
170
+ if laddr is not None:
171
+ fmts = ['Listen {addr:d}', 'L {addr:d}', 'L{addr_ord:c}']
172
+ addr = laddr
173
+ elif taddr is not None:
174
+ fmts = ['Talk {addr:d}', 'T {addr:d}', 'T{addr_ord:c}']
175
+ addr = taddr
176
+ elif saddr is not None:
177
+ fmts = ['Secondary {addr:d}', 'S {addr:d}', 'S{addr_ord:c}']
178
+ addr = saddr
179
+ elif msb is not None: # For IEC bus compat.
180
+ fmts = ['Secondary {addr:d}', 'S {addr:d}', 'S{addr_ord:c}']
181
+ addr = msb
182
+ return _format_ann_texts(fmts, addr = addr, addr_ord = ord('0') + addr)
183
+
184
+ def _get_data_text(b):
185
+ # TODO Move the table of ASCII control characters to a common location?
186
+ # TODO Move the "printable with escapes" logic to a common helper?
187
+ _control_codes = {
188
+ 0x00: 'NUL',
189
+ 0x01: 'SOH',
190
+ 0x02: 'STX',
191
+ 0x03: 'ETX',
192
+ 0x04: 'EOT',
193
+ 0x05: 'ENQ',
194
+ 0x06: 'ACK',
195
+ 0x07: 'BEL',
196
+ 0x08: 'BS',
197
+ 0x09: 'TAB',
198
+ 0x0a: 'LF',
199
+ 0x0b: 'VT',
200
+ 0x0c: 'FF',
201
+ 0x0d: 'CR',
202
+ 0x0e: 'SO',
203
+ 0x0f: 'SI',
204
+ 0x10: 'DLE',
205
+ 0x11: 'DC1',
206
+ 0x12: 'DC2',
207
+ 0x13: 'DC3',
208
+ 0x14: 'DC4',
209
+ 0x15: 'NAK',
210
+ 0x16: 'SYN',
211
+ 0x17: 'ETB',
212
+ 0x18: 'CAN',
213
+ 0x19: 'EM',
214
+ 0x1a: 'SUB',
215
+ 0x1b: 'ESC',
216
+ 0x1c: 'FS',
217
+ 0x1d: 'GS',
218
+ 0x1e: 'RS',
219
+ 0x1f: 'US',
220
+ }
221
+ # Yes, exclude 0x7f (DEL) here. It's considered non-printable.
222
+ if b in range(0x20, 0x7f) and b not in ('[', ']'):
223
+ return '{:s}'.format(chr(b))
224
+ elif b in _control_codes:
225
+ return '[{:s}]'.format(_control_codes[b])
226
+ # Use a compact yet readable and unambigous presentation for bytes
227
+ # which contain non-printables. The format that is used here is
228
+ # compatible with 93xx EEPROM and UART decoders.
229
+ return '[{:02x}]'.format(b)
230
+
231
+ (
232
+ PIN_DIO1, PIN_DIO2, PIN_DIO3, PIN_DIO4,
233
+ PIN_DIO5, PIN_DIO6, PIN_DIO7, PIN_DIO8,
234
+ PIN_EOI, PIN_DAV, PIN_NRFD, PIN_NDAC,
235
+ PIN_IFC, PIN_SRQ, PIN_ATN, PIN_REN,
236
+ PIN_CLK,
237
+ ) = range(17)
238
+ PIN_DATA = PIN_DIO1
239
+
240
+ (
241
+ ANN_RAW_BIT, ANN_RAW_BYTE,
242
+ ANN_CMD, ANN_LADDR, ANN_TADDR, ANN_SADDR, ANN_DATA,
243
+ ANN_EOI,
244
+ ANN_PP,
245
+ ANN_TEXT,
246
+ # TODO Want to provide one annotation class per talker address (0-30)?
247
+ ANN_IEC_PERIPH,
248
+ ANN_WARN,
249
+ ) = range(12)
250
+
251
+ (
252
+ BIN_RAW,
253
+ BIN_DATA,
254
+ # TODO Want to provide one binary annotation class per talker address (0-30)?
255
+ ) = range(2)
256
+
257
+ class Decoder(srd.Decoder):
258
+ api_version = 3
259
+ id = 'ieee488'
260
+ name = 'IEEE-488'
261
+ longname = 'IEEE-488 GPIB/HPIB/IEC'
262
+ desc = 'IEEE-488 General Purpose Interface Bus (GPIB/HPIB or IEC).'
263
+ license = 'gplv2+'
264
+ inputs = ['logic']
265
+ outputs = ['ieee488']
266
+ tags = ['PC', 'Retro computing']
267
+ channels = (
268
+ {'id': 'dio1' , 'name': 'DIO1/DATA',
269
+ 'desc': 'Data I/O bit 1, or serial data'},
270
+ )
271
+ optional_channels = (
272
+ {'id': 'dio2' , 'name': 'DIO2', 'desc': 'Data I/O bit 2'},
273
+ {'id': 'dio3' , 'name': 'DIO3', 'desc': 'Data I/O bit 3'},
274
+ {'id': 'dio4' , 'name': 'DIO4', 'desc': 'Data I/O bit 4'},
275
+ {'id': 'dio5' , 'name': 'DIO5', 'desc': 'Data I/O bit 5'},
276
+ {'id': 'dio6' , 'name': 'DIO6', 'desc': 'Data I/O bit 6'},
277
+ {'id': 'dio7' , 'name': 'DIO7', 'desc': 'Data I/O bit 7'},
278
+ {'id': 'dio8' , 'name': 'DIO8', 'desc': 'Data I/O bit 8'},
279
+ {'id': 'eoi', 'name': 'EOI', 'desc': 'End or identify'},
280
+ {'id': 'dav', 'name': 'DAV', 'desc': 'Data valid'},
281
+ {'id': 'nrfd', 'name': 'NRFD', 'desc': 'Not ready for data'},
282
+ {'id': 'ndac', 'name': 'NDAC', 'desc': 'Not data accepted'},
283
+ {'id': 'ifc', 'name': 'IFC', 'desc': 'Interface clear'},
284
+ {'id': 'srq', 'name': 'SRQ', 'desc': 'Service request'},
285
+ {'id': 'atn', 'name': 'ATN', 'desc': 'Attention'},
286
+ {'id': 'ren', 'name': 'REN', 'desc': 'Remote enable'},
287
+ {'id': 'clk', 'name': 'CLK', 'desc': 'Serial clock'},
288
+ )
289
+ options = (
290
+ {'id': 'iec_periph', 'desc': 'Decode Commodore IEC peripherals',
291
+ 'default': 'no', 'values': ('no', 'yes')},
292
+ {'id': 'delim', 'desc': 'Payload data delimiter',
293
+ 'default': 'eol', 'values': ('none', 'eol')},
294
+ {'id': 'atn_parity', 'desc': 'ATN commands use parity',
295
+ 'default': 'no', 'values': ('no', 'yes')},
296
+ )
297
+ annotations = (
298
+ ('bit', 'IEC bit'),
299
+ ('raw', 'Raw byte'),
300
+ ('cmd', 'Command'),
301
+ ('laddr', 'Listener address'),
302
+ ('taddr', 'Talker address'),
303
+ ('saddr', 'Secondary address'),
304
+ ('data', 'Data byte'),
305
+ ('eoi', 'EOI'),
306
+ ('pp', 'Parallel poll'),
307
+ ('text', 'Talker text'),
308
+ ('periph', 'IEC bus peripherals'),
309
+ ('warning', 'Warning'),
310
+ )
311
+ annotation_rows = (
312
+ ('bits', 'IEC bits', (ANN_RAW_BIT,)),
313
+ ('raws', 'Raw bytes', (ANN_RAW_BYTE,)),
314
+ ('gpib', 'Commands/data', (ANN_CMD, ANN_LADDR, ANN_TADDR, ANN_SADDR, ANN_DATA,)),
315
+ ('eois', 'EOI', (ANN_EOI,)),
316
+ ('polls', 'Polls', (ANN_PP,)),
317
+ ('texts', 'Talker texts', (ANN_TEXT,)),
318
+ ('periphs', 'IEC peripherals', (ANN_IEC_PERIPH,)),
319
+ ('warnings', 'Warnings', (ANN_WARN,)),
320
+ )
321
+ binary = (
322
+ ('raw', 'Raw bytes'),
323
+ ('data', 'Talker bytes'),
324
+ )
325
+
326
+ def __init__(self):
327
+ self.reset()
328
+
329
+ def reset(self):
330
+ self.curr_raw = None
331
+ self.curr_atn = None
332
+ self.curr_eoi = None
333
+ self.latch_atn = None
334
+ self.latch_eoi = None
335
+ self.accu_bytes = []
336
+ self.accu_text = []
337
+ self.ss_raw = None
338
+ self.es_raw = None
339
+ self.ss_eoi = None
340
+ self.es_eoi = None
341
+ self.ss_text = None
342
+ self.es_text = None
343
+ self.ss_pp = None
344
+ self.last_talker = None
345
+ self.last_listener = []
346
+ self.last_iec_addr = None
347
+ self.last_iec_sec = None
348
+
349
+ def start(self):
350
+ self.out_ann = self.register(srd.OUTPUT_ANN)
351
+ self.out_bin = self.register(srd.OUTPUT_BINARY)
352
+ self.out_python = self.register(srd.OUTPUT_PYTHON)
353
+
354
+ def putg(self, ss, es, data):
355
+ self.put(ss, es, self.out_ann, data)
356
+
357
+ def putbin(self, ss, es, data):
358
+ self.put(ss, es, self.out_bin, data)
359
+
360
+ def putpy(self, ss, es, ptype, addr, pdata):
361
+ self.put(ss, es, self.out_python, [ptype, addr, pdata])
362
+
363
+ def emit_eoi_ann(self, ss, es):
364
+ self.putg(ss, es, [ANN_EOI, ['EOI']])
365
+
366
+ def emit_bin_ann(self, ss, es, ann_cls, data):
367
+ self.putbin(ss, es, [ann_cls, bytes(data)])
368
+
369
+ def emit_data_ann(self, ss, es, ann_cls, data):
370
+ self.putg(ss, es, [ann_cls, data])
371
+
372
+ def emit_warn_ann(self, ss, es, data):
373
+ self.putg(ss, es, [ANN_WARN, data])
374
+
375
+ def flush_bytes_text_accu(self):
376
+ if self.accu_bytes and self.ss_text is not None and self.es_text is not None:
377
+ self.emit_bin_ann(self.ss_text, self.es_text, BIN_DATA, bytearray(self.accu_bytes))
378
+ self.putpy(self.ss_text, self.es_text, 'TALKER_BYTES', self.last_talker, bytearray(self.accu_bytes))
379
+ self.accu_bytes = []
380
+ if self.accu_text and self.ss_text is not None and self.es_text is not None:
381
+ text = ''.join(self.accu_text)
382
+ self.emit_data_ann(self.ss_text, self.es_text, ANN_TEXT, [text])
383
+ self.putpy(self.ss_text, self.es_text, 'TALKER_TEXT', self.last_talker, text)
384
+ self.accu_text = []
385
+ self.ss_text = self.es_text = None
386
+
387
+ def check_extra_flush(self, b):
388
+ # Optionally flush previously accumulated runs of payload data
389
+ # according to user specified conditions.
390
+ if self.options['delim'] == 'none':
391
+ return
392
+ if not self.accu_bytes:
393
+ return
394
+
395
+ # This implementation exlusively handles "text lines", but adding
396
+ # support for more variants here is straight forward.
397
+ #
398
+ # Search for the first data byte _after_ a user specified text
399
+ # line termination sequence was seen. The termination sequence's
400
+ # alphabet may be variable, and the sequence may span multiple
401
+ # data bytes. We accept either CR or LF, and combine the CR+LF
402
+ # sequence to strive for maximum length annotations for improved
403
+ # readability at different zoom levels. It's acceptable that this
404
+ # implementation would also combine multiple line terminations
405
+ # like LF+LF.
406
+ term_chars = (10, 13)
407
+ is_eol = b in term_chars
408
+ had_eol = self.accu_bytes[-1] in term_chars
409
+ if had_eol and not is_eol:
410
+ self.flush_bytes_text_accu()
411
+
412
+ def check_pp(self, dio = None):
413
+ # The combination of ATN and EOI means PP (parallel poll). Track
414
+ # this condition's start and end, and keep grabing the DIO lines'
415
+ # state as long as the condition is seen, since DAV is not used
416
+ # in the PP communication.
417
+ capture_in_pp = self.curr_atn and self.curr_eoi
418
+ decoder_in_pp = self.ss_pp is not None
419
+ if capture_in_pp and not decoder_in_pp:
420
+ # Phase starts. Track its ss. Start collecting DIO state.
421
+ self.ss_pp = self.samplenum
422
+ self.dio_pp = []
423
+ return 'enter'
424
+ if not capture_in_pp and decoder_in_pp:
425
+ # Phase ends. Void its ss. Process collected DIO state.
426
+ ss, es = self.ss_pp, self.samplenum
427
+ dio = self.dio_pp or []
428
+ self.ss_pp, self.dio_pp = None, None
429
+ if ss == es:
430
+ # False positive, caused by low oversampling.
431
+ return 'leave'
432
+ # Emit its annotation. Translate bit indices 0..7 for the
433
+ # DIO1..DIO8 signals to display text. Pass bit indices in
434
+ # the Python output for upper layers.
435
+ #
436
+ # TODO The presentation of this information may need more
437
+ # adjustment. The bit positions need not translate to known
438
+ # device addresses. Bits need not even belong to a single
439
+ # device. Participants and their location in the DIO pattern
440
+ # is configurable. Leave the interpretation to upper layers.
441
+ bits = [i for i, b in enumerate(dio) if b]
442
+ bits_text = ' '.join(['{}'.format(i + 1) for i in bits])
443
+ dios = ['DIO{}'.format(i + 1) for i in bits]
444
+ dios_text = ' '.join(dios or ['-'])
445
+ text = [
446
+ 'PPOLL {}'.format(dios_text),
447
+ 'PP {}'.format(bits_text),
448
+ 'PP',
449
+ ]
450
+ self.emit_data_ann(ss, es, ANN_PP, text)
451
+ self.putpy(ss, es, 'PPOLL', None, bits)
452
+ # Cease collecting DIO state.
453
+ return 'leave'
454
+ if decoder_in_pp:
455
+ # Keep collecting DIO state for each individual sample in
456
+ # the PP phase. Logically OR all DIO values that were seen.
457
+ # This increases robustness for low oversampling captures,
458
+ # where DIO may no longer be asserted when ATN/EOI deassert,
459
+ # and DIO was not asserted yet when ATN/EOI start asserting.
460
+ if dio is None:
461
+ dio = []
462
+ if len(dio) > len(self.dio_pp):
463
+ self.dio_pp.extend([ 0, ] * (len(dio) - len(self.dio_pp)))
464
+ for i, b in enumerate(dio):
465
+ self.dio_pp[i] |= b
466
+ return 'keep'
467
+ return 'idle'
468
+
469
+ def handle_ifc_change(self, ifc):
470
+ # Track IFC line for parallel input.
471
+ # Assertion of IFC de-selects all talkers and listeners.
472
+ if ifc:
473
+ self.last_talker = None
474
+ self.last_listener = []
475
+ self.flush_bytes_text_accu()
476
+
477
+ def handle_eoi_change(self, eoi):
478
+ # Track EOI line for parallel and serial input.
479
+ if eoi:
480
+ self.ss_eoi = self.samplenum
481
+ self.curr_eoi = eoi
482
+ else:
483
+ self.es_eoi = self.samplenum
484
+ if self.ss_eoi and self.latch_eoi:
485
+ self.emit_eoi_ann(self.ss_eoi, self.es_eoi)
486
+ self.es_text = self.es_eoi
487
+ self.flush_bytes_text_accu()
488
+ self.ss_eoi = self.es_eoi = None
489
+ self.curr_eoi = None
490
+
491
+ def handle_atn_change(self, atn):
492
+ # Track ATN line for parallel and serial input.
493
+ self.curr_atn = atn
494
+ if atn:
495
+ self.flush_bytes_text_accu()
496
+
497
+ def handle_iec_periph(self, ss, es, addr, sec, data):
498
+ # The annotation is optional.
499
+ if self.options['iec_periph'] != 'yes':
500
+ return
501
+ # Void internal state.
502
+ if addr is None and sec is None and data is None:
503
+ self.last_iec_addr = None
504
+ self.last_iec_sec = None
505
+ return
506
+ # Grab and evaluate new input.
507
+ _iec_addr_names = {
508
+ # TODO Add more items here. See the "Device numbering" section
509
+ # of the https://en.wikipedia.org/wiki/Commodore_bus page.
510
+ 8: 'Disk 0',
511
+ 9: 'Disk 1',
512
+ }
513
+ _iec_disk_range = range(8, 16)
514
+ if addr is not None:
515
+ self.last_iec_addr = addr
516
+ name = _iec_addr_names.get(addr, None)
517
+ if name:
518
+ self.emit_data_ann(ss, es, ANN_IEC_PERIPH, [name])
519
+ addr = self.last_iec_addr # Simplify subsequent logic.
520
+ if sec is not None:
521
+ # BEWARE! The secondary address is a full byte and includes
522
+ # the 0x60 offset, to also work when the MSB was set.
523
+ self.last_iec_sec = sec
524
+ subcmd, channel = sec & 0xf0, sec & 0x0f
525
+ channel_ord = ord('0') + channel
526
+ if addr is not None and addr in _iec_disk_range:
527
+ subcmd_fmts = {
528
+ 0x60: ['Reopen {ch:d}', 'Re {ch:d}', 'R{ch_ord:c}'],
529
+ 0xe0: ['Close {ch:d}', 'Cl {ch:d}', 'C{ch_ord:c}'],
530
+ 0xf0: ['Open {ch:d}', 'Op {ch:d}', 'O{ch_ord:c}'],
531
+ }.get(subcmd, None)
532
+ if subcmd_fmts:
533
+ texts = _format_ann_texts(subcmd_fmts, ch = channel, ch_ord = channel_ord)
534
+ self.emit_data_ann(ss, es, ANN_IEC_PERIPH, texts)
535
+ sec = self.last_iec_sec # Simplify subsequent logic.
536
+ if data is not None:
537
+ if addr is None or sec is None:
538
+ return
539
+ # TODO Process data depending on peripheral type and channel?
540
+
541
+ def handle_data_byte(self):
542
+ if not self.curr_atn:
543
+ self.check_extra_flush(self.curr_raw)
544
+ b = self.curr_raw
545
+ texts = _get_raw_text(b, self.curr_atn)
546
+ self.emit_data_ann(self.ss_raw, self.es_raw, ANN_RAW_BYTE, texts)
547
+ self.emit_bin_ann(self.ss_raw, self.es_raw, BIN_RAW, b.to_bytes(1, byteorder='big'))
548
+ self.putpy(self.ss_raw, self.es_raw, 'GPIB_RAW', None, _get_raw_byte(b, self.curr_atn))
549
+ if self.curr_atn:
550
+ ann_cls = None
551
+ upd_iec = False,
552
+ py_type = None
553
+ py_peers = False
554
+ if self.options['atn_parity'] == 'yes':
555
+ par = 1 if b & 0x80 else 0
556
+ b &= ~0x80
557
+ ones = bin(b).count('1') + par
558
+ if ones % 2:
559
+ warn_texts = ['Command parity error', 'parity', 'PAR']
560
+ self.emit_warn_ann(self.ss_raw, self.es_raw, warn_texts)
561
+ is_cmd, is_unl, is_unt = _is_command(b)
562
+ laddr = _is_listen_addr(b)
563
+ taddr = _is_talk_addr(b)
564
+ saddr = _is_secondary_addr(b)
565
+ msb = _is_msb_set(b)
566
+ if is_cmd:
567
+ known, texts = _get_command_texts(b)
568
+ if not known:
569
+ warn_texts = ['Unknown GPIB command', 'unknown', 'UNK']
570
+ self.emit_warn_ann(self.ss_raw, self.es_raw, warn_texts)
571
+ ann_cls = ANN_CMD
572
+ py_type, py_addr = 'COMMAND', None
573
+ if is_unl:
574
+ self.last_listener = []
575
+ py_peers = True
576
+ if is_unt:
577
+ self.last_talker = None
578
+ py_peers = True
579
+ if is_unl or is_unt:
580
+ upd_iec = True, None, None, None
581
+ elif laddr is not None:
582
+ addr = laddr
583
+ texts = _get_address_texts(b)
584
+ ann_cls = ANN_LADDR
585
+ py_type, py_addr = 'LISTEN', addr
586
+ if addr == self.last_talker:
587
+ self.last_talker = None
588
+ self.last_listener.append(addr)
589
+ upd_iec = True, addr, None, None
590
+ py_peers = True
591
+ elif taddr is not None:
592
+ addr = taddr
593
+ texts = _get_address_texts(b)
594
+ ann_cls = ANN_TADDR
595
+ py_type, py_addr = 'TALK', addr
596
+ if addr in self.last_listener:
597
+ self.last_listener.remove(addr)
598
+ self.last_talker = addr
599
+ upd_iec = True, addr, None, None
600
+ py_peers = True
601
+ elif saddr is not None:
602
+ addr = saddr
603
+ texts = _get_address_texts(b)
604
+ ann_cls = ANN_SADDR
605
+ upd_iec = True, None, b, None
606
+ py_type, py_addr = 'SECONDARY', addr
607
+ elif msb is not None:
608
+ # These are not really "secondary addresses", but they
609
+ # are used by the Commodore IEC bus (floppy channels).
610
+ texts = _get_address_texts(b)
611
+ ann_cls = ANN_SADDR
612
+ upd_iec = True, None, b, None
613
+ py_type, py_addr = 'MSB_SET', b
614
+ if ann_cls is not None and texts is not None:
615
+ self.emit_data_ann(self.ss_raw, self.es_raw, ann_cls, texts)
616
+ if upd_iec[0]:
617
+ self.handle_iec_periph(self.ss_raw, self.es_raw, upd_iec[1], upd_iec[2], upd_iec[3])
618
+ if py_type:
619
+ self.putpy(self.ss_raw, self.es_raw, py_type, py_addr, b)
620
+ if py_peers:
621
+ self.last_listener.sort()
622
+ self.putpy(self.ss_raw, self.es_raw, 'TALK_LISTEN', self.last_talker, self.last_listener)
623
+ else:
624
+ self.accu_bytes.append(b)
625
+ text = _get_data_text(b)
626
+ if not self.accu_text:
627
+ self.ss_text = self.ss_raw
628
+ self.accu_text.append(text)
629
+ self.es_text = self.es_raw
630
+ self.emit_data_ann(self.ss_raw, self.es_raw, ANN_DATA, [text])
631
+ self.handle_iec_periph(self.ss_raw, self.es_raw, None, None, b)
632
+ self.putpy(self.ss_raw, self.es_raw, 'DATA_BYTE', self.last_talker, b)
633
+
634
+ def handle_dav_change(self, dav, data):
635
+ if dav:
636
+ # Data availability starts when the flag goes active.
637
+ self.ss_raw = self.samplenum
638
+ self.curr_raw = bitpack(data)
639
+ self.latch_atn = self.curr_atn
640
+ self.latch_eoi = self.curr_eoi
641
+ return
642
+ # Data availability ends when the flag goes inactive. Handle the
643
+ # previously captured data byte according to associated flags.
644
+ self.es_raw = self.samplenum
645
+ self.handle_data_byte()
646
+ self.ss_raw = self.es_raw = None
647
+ self.curr_raw = None
648
+
649
+ def inject_dav_phase(self, ss, es, data):
650
+ # Inspection of serial input has resulted in one raw byte which
651
+ # spans a given period of time. Pretend we had seen a DAV active
652
+ # phase, to re-use code for the parallel transmission.
653
+ self.ss_raw = ss
654
+ self.curr_raw = bitpack(data)
655
+ self.latch_atn = self.curr_atn
656
+ self.latch_eoi = self.curr_eoi
657
+ self.es_raw = es
658
+ self.handle_data_byte()
659
+ self.ss_raw = self.es_raw = None
660
+ self.curr_raw = None
661
+
662
+ def invert_pins(self, pins):
663
+ # All lines (including data bits!) are low active and thus need
664
+ # to get inverted to receive their logical state (high active,
665
+ # regular data bit values). Cope with inputs being optional.
666
+ return [1 - p if p in (0, 1) else p for p in pins]
667
+
668
+ def decode_serial(self, has_clk, has_data_1, has_atn, has_srq):
669
+ if not has_clk or not has_data_1 or not has_atn:
670
+ raise ChannelError('IEC bus needs at least ATN and serial CLK and DATA.')
671
+
672
+ # This is a rephrased version of decoders/iec/pd.py:decode().
673
+ # SRQ was not used there either. Magic numbers were eliminated.
674
+ (
675
+ STEP_WAIT_READY_TO_SEND,
676
+ STEP_WAIT_READY_FOR_DATA,
677
+ STEP_PREP_DATA_TEST_EOI,
678
+ STEP_CLOCK_DATA_BITS,
679
+ ) = range(4)
680
+ step_wait_conds = (
681
+ [{PIN_ATN: 'f'}, {PIN_DATA: 'l', PIN_CLK: 'h'}],
682
+ [{PIN_ATN: 'f'}, {PIN_DATA: 'h', PIN_CLK: 'h'}, {PIN_CLK: 'l'}],
683
+ [{PIN_ATN: 'f'}, {PIN_DATA: 'f'}, {PIN_CLK: 'l'}],
684
+ [{PIN_ATN: 'f'}, {PIN_CLK: 'e'}],
685
+ )
686
+ step = STEP_WAIT_READY_TO_SEND
687
+ bits = []
688
+
689
+ while True:
690
+
691
+ # Sample input pin values. Keep DATA/CLK in verbatim form to
692
+ # re-use 'iec' decoder logic. Turn ATN to positive logic for
693
+ # easier processing. The data bits get handled during byte
694
+ # accumulation.
695
+ pins = self.wait(step_wait_conds[step])
696
+ data, clk = pins[PIN_DATA], pins[PIN_CLK]
697
+ atn, = self.invert_pins([pins[PIN_ATN]])
698
+
699
+ if self.matched[0]:
700
+ # Falling edge on ATN, reset step.
701
+ step = STEP_WAIT_READY_TO_SEND
702
+
703
+ if step == STEP_WAIT_READY_TO_SEND:
704
+ # Don't use self.matched[1] here since we might come from
705
+ # a step with different conds due to the code above.
706
+ if data == 0 and clk == 1:
707
+ # Rising edge on CLK while DATA is low: Ready to send.
708
+ step = STEP_WAIT_READY_FOR_DATA
709
+ elif step == STEP_WAIT_READY_FOR_DATA:
710
+ if data == 1 and clk == 1:
711
+ # Rising edge on DATA while CLK is high: Ready for data.
712
+ ss_byte = self.samplenum
713
+ self.handle_atn_change(atn)
714
+ if self.curr_eoi:
715
+ self.handle_eoi_change(False)
716
+ bits = []
717
+ step = STEP_PREP_DATA_TEST_EOI
718
+ elif clk == 0:
719
+ # CLK low again, transfer aborted.
720
+ step = STEP_WAIT_READY_TO_SEND
721
+ elif step == STEP_PREP_DATA_TEST_EOI:
722
+ if data == 0 and clk == 1:
723
+ # DATA goes low while CLK is still high, EOI confirmed.
724
+ self.handle_eoi_change(True)
725
+ elif clk == 0:
726
+ step = STEP_CLOCK_DATA_BITS
727
+ ss_bit = self.samplenum
728
+ elif step == STEP_CLOCK_DATA_BITS:
729
+ if self.matched[1]:
730
+ if clk == 1:
731
+ # Rising edge on CLK; latch DATA.
732
+ bits.append(data)
733
+ elif clk == 0:
734
+ # Falling edge on CLK; end of bit.
735
+ es_bit = self.samplenum
736
+ self.emit_data_ann(ss_bit, es_bit, ANN_RAW_BIT, ['{:d}'.format(bits[-1])])
737
+ self.putpy(ss_bit, es_bit, 'IEC_BIT', None, bits[-1])
738
+ ss_bit = self.samplenum
739
+ if len(bits) == 8:
740
+ es_byte = self.samplenum
741
+ self.inject_dav_phase(ss_byte, es_byte, bits)
742
+ if self.curr_eoi:
743
+ self.handle_eoi_change(False)
744
+ step = STEP_WAIT_READY_TO_SEND
745
+
746
+ def decode_parallel(self, has_data_n, has_dav, has_atn, has_eoi, has_srq):
747
+
748
+ if False in has_data_n or not has_dav or not has_atn:
749
+ raise ChannelError('IEEE-488 needs at least ATN and DAV and eight DIO lines.')
750
+ has_ifc = self.has_channel(PIN_IFC)
751
+
752
+ # Capture data lines at the falling edge of DAV, process their
753
+ # values at rising DAV edge (when data validity ends). Also make
754
+ # sure to start inspection when the capture happens to start with
755
+ # low signal levels, i.e. won't include the initial falling edge.
756
+ # Scan for ATN/EOI edges as well (including the trick which works
757
+ # around initial pin state).
758
+ #
759
+ # Use efficient edge based wait conditions for most activities,
760
+ # though some phases may require individual inspection of each
761
+ # sample (think parallel poll in combination with slow sampling).
762
+ #
763
+ # Map low-active physical transport lines to positive logic here,
764
+ # to simplify logical inspection/decoding of communicated data,
765
+ # and to avoid redundancy and inconsistency in later code paths.
766
+ waitcond = []
767
+ idx_dav = len(waitcond)
768
+ waitcond.append({PIN_DAV: 'l'})
769
+ idx_atn = len(waitcond)
770
+ waitcond.append({PIN_ATN: 'l'})
771
+ idx_eoi = None
772
+ if has_eoi:
773
+ idx_eoi = len(waitcond)
774
+ waitcond.append({PIN_EOI: 'l'})
775
+ idx_ifc = None
776
+ if has_ifc:
777
+ idx_ifc = len(waitcond)
778
+ waitcond.append({PIN_IFC: 'l'})
779
+ idx_pp_check = None
780
+ def add_data_cond(conds):
781
+ idx = len(conds)
782
+ conds.append({'skip': 1})
783
+ return idx
784
+ def del_data_cond(conds, idx):
785
+ conds.pop(idx)
786
+ return None
787
+ while True:
788
+ pins = self.wait(waitcond)
789
+ pins = self.invert_pins(pins)
790
+
791
+ # BEWARE! Order of evaluation does matter. For low samplerate
792
+ # captures, many edges fall onto the same sample number. So
793
+ # we process active edges of flags early (before processing
794
+ # data bits), and inactive edges late (after data got processed).
795
+ want_pp_check = False
796
+ if idx_ifc is not None and self.matched[idx_ifc] and pins[PIN_IFC] == 1:
797
+ self.handle_ifc_change(pins[PIN_IFC])
798
+ if idx_eoi is not None and self.matched[idx_eoi] and pins[PIN_EOI] == 1:
799
+ self.handle_eoi_change(pins[PIN_EOI])
800
+ want_pp_check = True
801
+ if self.matched[idx_atn] and pins[PIN_ATN] == 1:
802
+ self.handle_atn_change(pins[PIN_ATN])
803
+ want_pp_check = True
804
+ if want_pp_check and not idx_pp_check:
805
+ pp = self.check_pp()
806
+ if pp in ('enter',):
807
+ idx_pp_check = add_data_cond(waitcond)
808
+ if self.matched[idx_dav]:
809
+ self.handle_dav_change(pins[PIN_DAV], pins[PIN_DIO1:PIN_DIO8 + 1])
810
+ if idx_pp_check:
811
+ pp = self.check_pp(pins[PIN_DIO1:PIN_DIO8 + 1])
812
+ want_pp_check = False
813
+ if self.matched[idx_atn] and pins[PIN_ATN] == 0:
814
+ self.handle_atn_change(pins[PIN_ATN])
815
+ want_pp_check = True
816
+ if idx_eoi is not None and self.matched[idx_eoi] and pins[PIN_EOI] == 0:
817
+ self.handle_eoi_change(pins[PIN_EOI])
818
+ want_pp_check = True
819
+ if idx_pp_check is not None and want_pp_check:
820
+ pp = self.check_pp(pins[PIN_DIO1:PIN_DIO8 + 1])
821
+ if pp in ('leave',) and idx_pp_check is not None:
822
+ idx_pp_check = del_data_cond(waitcond, idx_pp_check)
823
+ if idx_ifc is not None and self.matched[idx_ifc] and pins[PIN_IFC] == 0:
824
+ self.handle_ifc_change(pins[PIN_IFC])
825
+
826
+ waitcond[idx_dav][PIN_DAV] = 'e'
827
+ waitcond[idx_atn][PIN_ATN] = 'e'
828
+ if has_eoi:
829
+ waitcond[idx_eoi][PIN_EOI] = 'e'
830
+ if has_ifc:
831
+ waitcond[idx_ifc][PIN_IFC] = 'e'
832
+
833
+ def decode(self):
834
+ # The decoder's boilerplate declares some of the input signals as
835
+ # optional, but only to support both serial and parallel variants.
836
+ # The CLK signal discriminates the two. For either variant some
837
+ # of the "optional" signals are not really optional for proper
838
+ # operation of the decoder. Check these conditions here.
839
+ has_clk = self.has_channel(PIN_CLK)
840
+ has_data_1 = self.has_channel(PIN_DIO1)
841
+ has_data_n = [bool(self.has_channel(pin) for pin in range(PIN_DIO1, PIN_DIO8 + 1))]
842
+ has_dav = self.has_channel(PIN_DAV)
843
+ has_atn = self.has_channel(PIN_ATN)
844
+ has_eoi = self.has_channel(PIN_EOI)
845
+ has_srq = self.has_channel(PIN_SRQ)
846
+ if has_clk:
847
+ self.decode_serial(has_clk, has_data_1, has_atn, has_srq)
848
+ else:
849
+ self.decode_parallel(has_data_n, has_dav, has_atn, has_eoi, has_srq)