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,25 @@
1
+ ##
2
+ ## This file is part of the libsigrokdecode project.
3
+ ##
4
+ ## Copyright (C) 2020 Gerhard Sittig <gerhard.sittig@gmx.net>
5
+ ##
6
+ ## This program is free software; you can redistribute it and/or modify
7
+ ## it under the terms of the GNU General Public License as published by
8
+ ## the Free Software Foundation; either version 2 of the License, or
9
+ ## (at your option) any later version.
10
+ ##
11
+ ## This program is distributed in the hope that it will be useful,
12
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ ## GNU General Public License for more details.
15
+ ##
16
+ ## You should have received a copy of the GNU General Public License
17
+ ## along with this program; if not, see <http://www.gnu.org/licenses/>.
18
+ ##
19
+
20
+ '''
21
+ This protocol decoder interprets the PJON protocol on top of the PJDL
22
+ link layer (and potentially other link layers).
23
+ '''
24
+
25
+ from .pd import Decoder
@@ -0,0 +1,603 @@
1
+ ##
2
+ ## This file is part of the libsigrokdecode project.
3
+ ##
4
+ ## Copyright (C) 2020 Gerhard Sittig <gerhard.sittig@gmx.net>
5
+ ##
6
+ ## This program is free software; you can redistribute it and/or modify
7
+ ## it under the terms of the GNU General Public License as published by
8
+ ## the Free Software Foundation; either version 2 of the License, or
9
+ ## (at your option) any later version.
10
+ ##
11
+ ## This program is distributed in the hope that it will be useful,
12
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ ## GNU General Public License for more details.
15
+ ##
16
+ ## You should have received a copy of the GNU General Public License
17
+ ## along with this program; if not, see <http://www.gnu.org/licenses/>.
18
+ ##
19
+
20
+ # See the https://www.pjon.org/ PJON project page and especially the
21
+ # https://www.pjon.org/PJON-protocol-specification-v3.2.php protocol
22
+ # specification, which can use different link layers.
23
+
24
+ # TODO
25
+ # - Check for the correct order of optional fields (the spec is not as
26
+ # explicit on these details as I'd expect).
27
+ # - Check decoder's robustness, completeness, and correctness when more
28
+ # captures become available. Currently there are only few, which only
29
+ # cover minimal communication, and none of the protocol's flexibility.
30
+ # The decoder was essentially written based on the available docs, and
31
+ # then took some arbitrary choices and liberties to cope with real life
32
+ # data from an example setup. Strictly speaking this decoder violates
33
+ # the spec, and errs towards the usability side.
34
+
35
+ import sigrokdecode as srd
36
+ import struct
37
+
38
+ ANN_RX_INFO, ANN_HDR_CFG, ANN_PKT_LEN, ANN_META_CRC, ANN_TX_INFO, \
39
+ ANN_SVC_ID, ANN_PKT_ID, ANN_ANON_DATA, ANN_PAYLOAD, ANN_END_CRC, \
40
+ ANN_SYN_RSP, \
41
+ ANN_RELATION, \
42
+ ANN_WARN, \
43
+ = range(13)
44
+
45
+ def calc_crc8(data):
46
+ crc = 0
47
+ for b in data:
48
+ crc ^= b
49
+ for i in range(8):
50
+ odd = crc % 2
51
+ crc >>= 1
52
+ if odd:
53
+ crc ^= 0x97
54
+ return crc
55
+
56
+ def calc_crc32(data):
57
+ crc = 0xffffffff
58
+ for b in data:
59
+ crc ^= b
60
+ for i in range(8):
61
+ odd = crc % 2
62
+ crc >>= 1
63
+ if odd:
64
+ crc ^= 0xedb88320
65
+ crc ^= 0xffffffff
66
+ return crc
67
+
68
+ class Decoder(srd.Decoder):
69
+ api_version = 3
70
+ id = 'pjon'
71
+ name = 'PJON'
72
+ longname = 'PJON'
73
+ desc = 'The PJON protocol.'
74
+ license = 'gplv2+'
75
+ inputs = ['pjon_link']
76
+ outputs = []
77
+ tags = ['Embedded/industrial']
78
+ annotations = (
79
+ ('rx_info', 'Receiver ID'),
80
+ ('hdr_cfg', 'Header config'),
81
+ ('pkt_len', 'Packet length'),
82
+ ('meta_crc', 'Meta CRC'),
83
+ ('tx_info', 'Sender ID'),
84
+ ('port', 'Service ID'),
85
+ ('pkt_id', 'Packet ID'),
86
+ ('anon', 'Anonymous data'),
87
+ ('payload', 'Payload'),
88
+ ('end_crc', 'End CRC'),
89
+ ('syn_rsp', 'Sync response'),
90
+ ('relation', 'Relation'),
91
+ ('warning', 'Warning'),
92
+ )
93
+ annotation_rows = (
94
+ ('fields', 'Fields', (
95
+ ANN_RX_INFO, ANN_HDR_CFG, ANN_PKT_LEN, ANN_META_CRC, ANN_TX_INFO,
96
+ ANN_SVC_ID, ANN_ANON_DATA, ANN_PAYLOAD, ANN_END_CRC, ANN_SYN_RSP,
97
+ )),
98
+ ('relations', 'Relations', (ANN_RELATION,)),
99
+ ('warnings', 'Warnings', (ANN_WARN,)),
100
+ )
101
+
102
+ def __init__(self):
103
+ self.reset()
104
+
105
+ def reset(self):
106
+ self.reset_frame()
107
+
108
+ def reset_frame(self):
109
+ self.frame_ss = None
110
+ self.frame_es = None
111
+ self.frame_rx_id = None
112
+ self.frame_tx_id = None
113
+ self.frame_payload_text = None
114
+ self.frame_bytes = None
115
+ self.frame_has_ack = None
116
+ self.ack_bytes = None
117
+ self.ann_ss = None
118
+ self.ann_es = None
119
+
120
+ def start(self):
121
+ self.out_ann = self.register(srd.OUTPUT_ANN)
122
+
123
+ def putg(self, ss, es, ann, data):
124
+ self.put(ss, es, self.out_ann, [ann, data])
125
+
126
+ def frame_flush(self):
127
+ if not self.frame_bytes:
128
+ return
129
+ if not self.frame_ss or not self.frame_es:
130
+ return
131
+
132
+ # Emit "communication relation" details.
133
+ # TODO Include the service ID (port number) as well?
134
+ text = []
135
+ if self.frame_rx_id is not None:
136
+ text.append("RX {}".format(self.frame_rx_id[-1]))
137
+ if self.frame_tx_id is not None:
138
+ text.append("TX {}".format(self.frame_tx_id[-1]))
139
+ if self.frame_payload_text is not None:
140
+ text.append("DATA {}".format(self.frame_payload_text))
141
+ if self.frame_has_ack is not None:
142
+ text.append("ACK {:02x}".format(self.frame_has_ack))
143
+ if text:
144
+ text = " - ".join(text)
145
+ self.putg(self.frame_ss, self.frame_es, ANN_RELATION, [text])
146
+
147
+ def handle_field_get_desc(self, idx = None):
148
+ '''Lookup description of a PJON frame field.'''
149
+ if not self.field_desc:
150
+ return None
151
+ if idx is None:
152
+ idx = self.field_desc_idx
153
+ if idx >= 0 and idx >= len(self.field_desc):
154
+ return None
155
+ if idx < 0 and abs(idx) > len(self.field_desc):
156
+ return None
157
+ desc = self.field_desc[idx]
158
+ return desc
159
+
160
+ def handle_field_add_desc(self, fmt, hdl, cls = None):
161
+ '''Register description for a PJON frame field.'''
162
+ item = {
163
+ 'format': fmt,
164
+ 'width': struct.calcsize(fmt),
165
+ 'handler': hdl,
166
+ 'anncls': cls,
167
+ }
168
+ self.field_desc.append(item)
169
+
170
+ def handle_field_seed_desc(self):
171
+ '''Seed list of PJON frame fields' descriptions.'''
172
+
173
+ # At the start of a PJON frame, the layout of only two fields
174
+ # is known. Subsequent fields (their presence, and width) depend
175
+ # on the content of the header config field.
176
+
177
+ self.field_desc = []
178
+ self.handle_field_add_desc('<B', self.handle_field_rx_id, ANN_RX_INFO)
179
+ self.handle_field_add_desc('<B', self.handle_field_config, ANN_HDR_CFG)
180
+
181
+ self.field_desc_idx = 0
182
+ self.field_desc_got = 0
183
+
184
+ self.frame_ss = None
185
+ self.frame_es = None
186
+ self.frame_rx_id = None
187
+ self.frame_is_broadcast = None
188
+ self.frame_tx_id = None
189
+ self.frame_payload = None
190
+ self.frame_payload_text = None
191
+ self.frame_has_ack = None
192
+
193
+ def handle_field_rx_id(self, b):
194
+ '''Process receiver ID field of a PJON frame.'''
195
+
196
+ b = b[0]
197
+
198
+ # Provide text presentation, caller emits frame field annotation.
199
+ if b == 255: # "not assigned"
200
+ id_txt = 'NA'
201
+ elif b == 0: # "broadcast"
202
+ id_txt = 'BC'
203
+ else: # unicast
204
+ id_txt = '{:d}'.format(b)
205
+ texts = [
206
+ 'RX_ID {}'.format(id_txt),
207
+ '{}'.format(id_txt),
208
+ ]
209
+
210
+ # Track RX info for communication relation emission.
211
+ self.frame_rx_id = (b, id_txt)
212
+ self.frame_is_broadcast = b == 0
213
+
214
+ return texts
215
+
216
+ def handle_field_config(self, b):
217
+ '''Process header config field of a PJON frame.'''
218
+
219
+ # Caller provides a list of values. We want a single scalar.
220
+ b = b[0]
221
+
222
+ # Get the config flags.
223
+ self.cfg_shared = b & (1 << 0)
224
+ self.cfg_tx_info = b & (1 << 1)
225
+ self.cfg_sync_ack = b & (1 << 2)
226
+ self.cfg_async_ack = b & (1 << 3)
227
+ self.cfg_port = b & (1 << 4)
228
+ self.cfg_crc32 = b & (1 << 5)
229
+ self.cfg_len16 = b & (1 << 6)
230
+ self.cfg_pkt_id = b & (1 << 7)
231
+
232
+ # Get a textual presentation of the flags.
233
+ text = []
234
+ text.append('pkt_id' if self.cfg_pkt_id else '-') # packet number
235
+ text.append('len16' if self.cfg_len16 else '-') # 16bit length not 8bit
236
+ text.append('crc32' if self.cfg_crc32 else '-') # 32bit CRC not 8bit
237
+ text.append('svc_id' if self.cfg_port else '-') # port aka service ID
238
+ text.append('ack_mode' if self.cfg_async_ack else '-') # async response
239
+ text.append('ack' if self.cfg_sync_ack else '-') # synchronous response
240
+ text.append('tx_info' if self.cfg_tx_info else '-') # sender address
241
+ text.append('bus_id' if self.cfg_shared else '-') # "shared" vs "local"
242
+ text = ' '.join(text)
243
+ bits = '{:08b}'.format(b)
244
+ texts = [
245
+ 'CFG {:s}'.format(text),
246
+ 'CFG {}'.format(bits),
247
+ bits
248
+ ]
249
+
250
+ # TODO Come up with the most appropriate phrases for this logic.
251
+ # Are separate instruction groups with repeated conditions more
252
+ # readable than one common block which registers fields _and_
253
+ # updates the overhead size? Or is the latter preferrable due to
254
+ # easier maintenance and less potential for inconsistency?
255
+
256
+ # Get the size of variable width fields, to calculate the size
257
+ # of the packet overhead (the part that is not the payload data).
258
+ # This lets us derive the payload length when we later receive
259
+ # the frame's total length.
260
+ u8_fmt = '>B'
261
+ u16_fmt = '>H'
262
+ u32_fmt = '>L'
263
+ len_fmt = u16_fmt if self.cfg_len16 else u8_fmt
264
+ bus_fmt = '>4B'
265
+ crc_fmt = u32_fmt if self.cfg_crc32 else u8_fmt
266
+ self.cfg_overhead = 0
267
+ self.cfg_overhead += struct.calcsize(u8_fmt) # receiver ID
268
+ self.cfg_overhead += struct.calcsize(u8_fmt) # header config
269
+ self.cfg_overhead += struct.calcsize(len_fmt) # packet length
270
+ self.cfg_overhead += struct.calcsize(u8_fmt) # initial CRC, always CRC8
271
+ # TODO Check for completeness and correctness.
272
+ if self.cfg_shared:
273
+ self.cfg_overhead += struct.calcsize(u32_fmt) # receiver bus
274
+ if self.cfg_tx_info:
275
+ if self.cfg_shared:
276
+ self.cfg_overhead += struct.calcsize(u32_fmt) # sender bus
277
+ self.cfg_overhead += struct.calcsize(u8_fmt) # sender ID
278
+ if self.cfg_port:
279
+ self.cfg_overhead += struct.calcsize(u16_fmt) # service ID
280
+ if self.cfg_pkt_id:
281
+ self.cfg_overhead += struct.calcsize(u16_fmt) # packet ID
282
+ self.cfg_overhead += struct.calcsize(crc_fmt) # end CRC
283
+
284
+ # Register more frame fields as we learn about their presence and
285
+ # format. Up to this point only receiver ID and header config were
286
+ # registered since their layout is fixed.
287
+ #
288
+ # Packet length and meta CRC are always present but can be of
289
+ # variable width. Optional fields follow the meta CRC and preceed
290
+ # the payload bytes. Notice that payload length isn't known here
291
+ # either, though its position is known already. The packet length
292
+ # is yet to get received. Subtracting the packet overhead from it
293
+ # (which depends on the header configuration) will provide that
294
+ # information.
295
+ #
296
+ # TODO Check for completeness and correctness.
297
+ # TODO Optionally fold overhead size arith and field registration
298
+ # into one block of instructions, to reduce the redundancy in the
299
+ # condition checks, and raise awareness for incomplete sequences
300
+ # during maintenance.
301
+ self.handle_field_add_desc(len_fmt, self.handle_field_pkt_len, ANN_PKT_LEN)
302
+ self.handle_field_add_desc(u8_fmt, self.handle_field_meta_crc, ANN_META_CRC)
303
+ if self.cfg_shared:
304
+ self.handle_field_add_desc(bus_fmt, self.handle_field_rx_bus, ANN_ANON_DATA)
305
+ if self.cfg_tx_info:
306
+ if self.cfg_shared:
307
+ self.handle_field_add_desc(bus_fmt, self.handle_field_tx_bus, ANN_ANON_DATA)
308
+ self.handle_field_add_desc(u8_fmt, self.handle_field_tx_id, ANN_ANON_DATA)
309
+ if self.cfg_port:
310
+ self.handle_field_add_desc(u16_fmt, ['PORT {:d}', '{:d}'], ANN_ANON_DATA)
311
+ if self.cfg_pkt_id:
312
+ self.handle_field_add_desc(u16_fmt, ['PKT {:04x}', '{:04x}'], ANN_ANON_DATA)
313
+ pl_fmt = '>{:d}B'.format(0)
314
+ self.handle_field_add_desc(pl_fmt, self.handle_field_payload, ANN_PAYLOAD)
315
+ self.handle_field_add_desc(crc_fmt, self.handle_field_end_crc, ANN_END_CRC)
316
+
317
+ # Emit warning annotations for invalid flag combinations.
318
+ warn_texts = []
319
+ wants_ack = self.cfg_sync_ack or self.cfg_async_ack
320
+ if wants_ack and not self.cfg_tx_info:
321
+ warn_texts.append('ACK request without TX info')
322
+ if wants_ack and self.frame_is_broadcast:
323
+ warn_texts.append('ACK request for broadcast')
324
+ if self.cfg_sync_ack and self.cfg_async_ack:
325
+ warn_texts.append('sync and async ACK request')
326
+ if self.cfg_len16 and not self.cfg_crc32:
327
+ warn_texts.append('extended length needs CRC32')
328
+ if warn_texts:
329
+ warn_texts = ', '.join(warn_texts)
330
+ self.putg(self.ann_ss, self.ann_es, ANN_WARN, [warn_texts])
331
+
332
+ # Have the caller emit the annotation for configuration data.
333
+ return texts
334
+
335
+ def handle_field_pkt_len(self, b):
336
+ '''Process packet length field of a PJON frame.'''
337
+
338
+ # Caller provides a list of values. We want a single scalar.
339
+ b = b[0]
340
+
341
+ # The wire communicates the total packet length. Some of it is
342
+ # overhead (non-payload data), while its volume is variable in
343
+ # size (depends on the header configuration).
344
+ #
345
+ # Derive the payload size from previously observed flags. Update
346
+ # the previously registered field description (the second last
347
+ # item in the list, before the end CRC).
348
+
349
+ pkt_len = b
350
+ pl_len = b - self.cfg_overhead
351
+ warn_texts = []
352
+ if pkt_len not in range(self.cfg_overhead, 65536):
353
+ warn_texts.append('suspicious packet length')
354
+ if pkt_len > 15 and not self.cfg_crc32:
355
+ warn_texts.append('length above 15 needs CRC32')
356
+ if pl_len < 1:
357
+ warn_texts.append('suspicious payload length')
358
+ pl_len = 0
359
+ if warn_texts:
360
+ warn_texts = ', '.join(warn_texts)
361
+ self.putg(self.ann_ss, self.ann_es, ANN_WARN, [warn_texts])
362
+ pl_fmt = '>{:d}B'.format(pl_len)
363
+
364
+ desc = self.handle_field_get_desc(-2)
365
+ desc['format'] = pl_fmt
366
+ desc['width'] = struct.calcsize(pl_fmt)
367
+
368
+ # Have the caller emit the annotation for the packet length.
369
+ # Provide information of different detail level for zooming.
370
+ texts = [
371
+ 'LENGTH {:d} (PAYLOAD {:d})'.format(pkt_len, pl_len),
372
+ 'LEN {:d} (PL {:d})'.format(pkt_len, pl_len),
373
+ '{:d} ({:d})'.format(pkt_len, pl_len),
374
+ '{:d}'.format(pkt_len),
375
+ ]
376
+ return texts
377
+
378
+ def handle_field_common_crc(self, have, is_meta):
379
+ '''Process a CRC field of a PJON frame.'''
380
+
381
+ # CRC algorithm and width are configurable, and can differ
382
+ # across meta and end checksums in a frame's fields.
383
+ caption = 'META' if is_meta else 'END'
384
+ crc_len = 8 if is_meta else 32 if self.cfg_crc32 else 8
385
+ crc_bytes = crc_len // 8
386
+ crc_fmt = '{:08x}' if crc_len == 32 else '{:02x}'
387
+ have_text = crc_fmt.format(have)
388
+
389
+ # Check received against expected checksum. Emit warnings.
390
+ warn_texts = []
391
+ data = self.frame_bytes[:-crc_bytes]
392
+ want = calc_crc32(data) if crc_len == 32 else calc_crc8(data)
393
+ if want != have:
394
+ want_text = crc_fmt.format(want)
395
+ warn_texts.append('CRC mismatch - want {} have {}'.format(want_text, have_text))
396
+ if warn_texts:
397
+ warn_texts = ', '.join(warn_texts)
398
+ self.putg(self.ann_ss, self.ann_es, ANN_WARN, [warn_texts])
399
+
400
+ # Provide text representation for frame field, caller emits
401
+ # the annotation.
402
+ texts = [
403
+ '{}_CRC {}'.format(caption, have_text),
404
+ 'CRC {}'.format(have_text),
405
+ have_text,
406
+ ]
407
+ return texts
408
+
409
+ def handle_field_meta_crc(self, b):
410
+ '''Process initial CRC (meta) field of a PJON frame.'''
411
+ # Caller provides a list of values. We want a single scalar.
412
+ b = b[0]
413
+ return self.handle_field_common_crc(b, True)
414
+
415
+ def handle_field_end_crc(self, b):
416
+ '''Process end CRC (total frame) field of a PJON frame.'''
417
+ # Caller provides a list of values. We want a single scalar.
418
+ b = b[0]
419
+ return self.handle_field_common_crc(b, False)
420
+
421
+ def handle_field_common_bus(self, b):
422
+ '''Common handling of bus ID details. Used for RX and TX.'''
423
+ bus_id = b[:4]
424
+ bus_num = struct.unpack('>L', bytearray(bus_id))
425
+ bus_txt = '.'.join(['{:d}'.format(b) for b in bus_id])
426
+ return bus_num, bus_txt
427
+
428
+ def handle_field_rx_bus(self, b):
429
+ '''Process receiver bus ID field of a PJON frame.'''
430
+
431
+ # When we get here, there always should be an RX ID already.
432
+ bus_num, bus_txt = self.handle_field_common_bus(b[:4])
433
+ rx_txt = "{} {}".format(bus_txt, self.frame_rx_id[-1])
434
+ self.frame_rx_id = (bus_num, self.frame_rx_id[0], rx_txt)
435
+
436
+ # Provide text representation for frame field, caller emits
437
+ # the annotation.
438
+ texts = [
439
+ 'RX_BUS {}'.format(bus_txt),
440
+ bus_txt,
441
+ ]
442
+ return texts
443
+
444
+ def handle_field_tx_bus(self, b):
445
+ '''Process transmitter bus ID field of a PJON frame.'''
446
+
447
+ # The TX ID field is optional, as is the use of bus ID fields.
448
+ # In the TX info case the TX bus ID is seen before the TX ID.
449
+ bus_num, bus_txt = self.handle_field_common_bus(b[:4])
450
+ self.frame_tx_id = (bus_num, None, bus_txt)
451
+
452
+ # Provide text representation for frame field, caller emits
453
+ # the annotation.
454
+ texts = [
455
+ 'TX_BUS {}'.format(bus_txt),
456
+ bus_txt,
457
+ ]
458
+ return texts
459
+
460
+ def handle_field_tx_id(self, b):
461
+ '''Process transmitter ID field of a PJON frame.'''
462
+
463
+ b = b[0]
464
+
465
+ id_txt = "{:d}".format(b)
466
+ if self.frame_tx_id is None:
467
+ self.frame_tx_id = (b, id_txt)
468
+ else:
469
+ tx_txt = "{} {}".format(self.frame_tx_id[-1], id_txt)
470
+ self.frame_tx_id = (self.frame_tx_id[0], b, tx_txt)
471
+
472
+ # Provide text representation for frame field, caller emits
473
+ # the annotation.
474
+ texts = [
475
+ 'TX_ID {}'.format(id_txt),
476
+ id_txt,
477
+ ]
478
+ return texts
479
+
480
+ def handle_field_payload(self, b):
481
+ '''Process payload data field of a PJON frame.'''
482
+
483
+ text = ' '.join(['{:02x}'.format(v) for v in b])
484
+ self.frame_payload = b[:]
485
+ self.frame_payload_text = text
486
+
487
+ texts = [
488
+ 'PAYLOAD {}'.format(text),
489
+ text,
490
+ ]
491
+ return texts
492
+
493
+ def handle_field_sync_resp(self, b):
494
+ '''Process synchronous response for a PJON frame.'''
495
+
496
+ self.frame_has_ack = b
497
+
498
+ texts = [
499
+ 'ACK {:02x}'.format(b),
500
+ '{:02x}'.format(b),
501
+ ]
502
+ return texts
503
+
504
+ def decode(self, ss, es, data):
505
+ ptype, pdata = data
506
+
507
+ # Start frame bytes accumulation when FRAME_INIT is seen. Flush
508
+ # previously accumulated frame bytes when a new frame starts.
509
+ if ptype == 'FRAME_INIT':
510
+ self.frame_flush()
511
+ self.reset_frame()
512
+ self.frame_bytes = []
513
+ self.handle_field_seed_desc()
514
+ self.frame_ss = ss
515
+ self.frame_es = es
516
+ return
517
+
518
+ # Use IDLE as another (earlier) trigger to flush frames. Also
519
+ # trigger flushes on FRAME-DATA which mean that the link layer
520
+ # inspection has seen the end of a protocol frame.
521
+ #
522
+ # TODO Improve usability? Emit warnings for PJON frames where
523
+ # FRAME_DATA was seen but FRAME_INIT wasn't? So that users can
524
+ # become aware of broken frames.
525
+ if ptype in ('IDLE', 'FRAME_DATA'):
526
+ self.frame_flush()
527
+ self.reset_frame()
528
+ return
529
+
530
+ # Switch from data bytes to response bytes when WAIT is seen.
531
+ if ptype == 'SYNC_RESP_WAIT':
532
+ self.ack_bytes = []
533
+ self.ann_ss, self.ann_es = None, None
534
+ return
535
+
536
+ # Accumulate data bytes as they arrive. Put them in the bucket
537
+ # which corresponds to its most recently seen leader.
538
+ if ptype == 'DATA_BYTE':
539
+ b = pdata
540
+ self.frame_es = es
541
+
542
+ # Are we collecting response bytes (ACK)?
543
+ if self.ack_bytes is not None:
544
+ if not self.ann_ss:
545
+ self.ann_ss = ss
546
+ self.ack_bytes.append(b)
547
+ self.ann_es = es
548
+ text = self.handle_field_sync_resp(b)
549
+ if text:
550
+ self.putg(self.ann_ss, self.ann_es, ANN_SYN_RSP, text)
551
+ self.ann_ss, self.ann_es = None, None
552
+ return
553
+
554
+ # Are we collecting frame content?
555
+ if self.frame_bytes is not None:
556
+ if not self.ann_ss:
557
+ self.ann_ss = ss
558
+ self.frame_bytes.append(b)
559
+ self.ann_es = es
560
+
561
+ # Has the field value become available yet?
562
+ desc = self.handle_field_get_desc()
563
+ if not desc:
564
+ return
565
+ width = desc.get('width', None)
566
+ if not width:
567
+ return
568
+ self.field_desc_got += 1
569
+ if self.field_desc_got != width:
570
+ return
571
+
572
+ # Grab most recent received field as a byte array. Get
573
+ # the values that it contains.
574
+ fmt = desc.get('format', '>B')
575
+ raw = bytearray(self.frame_bytes[-width:])
576
+ values = struct.unpack(fmt, raw)
577
+
578
+ # Process the value, and get its presentation. Can be
579
+ # mere formatting, or serious execution of logic.
580
+ hdl = desc.get('handler', '{!r}')
581
+ if isinstance(hdl, str):
582
+ text = [hdl.format(*values)]
583
+ elif isinstance(hdl, (list, tuple)):
584
+ text = [f.format(*values) for f in hdl]
585
+ elif hdl:
586
+ text = hdl(values)
587
+ cls = desc.get('anncls', ANN_ANON_DATA)
588
+
589
+ # Emit annotation unless the handler routine already did.
590
+ if cls is not None and text:
591
+ self.putg(self.ann_ss, self.ann_es, cls, text)
592
+ self.ann_ss, self.ann_es = None, None
593
+
594
+ # Advance scan position for to-get-received field.
595
+ self.field_desc_idx += 1
596
+ self.field_desc_got = 0
597
+ return
598
+
599
+ # Unknown phase, not collecting. Not synced yet to the input?
600
+ return
601
+
602
+ # Unknown or unhandled kind of link layer output.
603
+ return
@@ -0,0 +1,26 @@
1
+ ##
2
+ ## This file is part of the libsigrokdecode project.
3
+ ##
4
+ ## Copyright (C) 2016 Daniel Schulte <trilader@schroedingers-bit.net>
5
+ ##
6
+ ## This program is free software; you can redistribute it and/or modify
7
+ ## it under the terms of the GNU General Public License as published by
8
+ ## the Free Software Foundation; either version 2 of the License, or
9
+ ## (at your option) any later version.
10
+ ##
11
+ ## This program is distributed in the hope that it will be useful,
12
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ ## GNU General Public License for more details.
15
+ ##
16
+ ## You should have received a copy of the GNU General Public License
17
+ ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ ##
19
+
20
+ '''
21
+ This protocol decoder can decode PS/2 device -> host communication.
22
+
23
+ Host -> device communication is currently not supported.
24
+ '''
25
+
26
+ from .pd import Decoder