emupos 0.1.0__tar.gz

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 (218) hide show
  1. emupos-0.1.0/.gitignore +27 -0
  2. emupos-0.1.0/CHANGELOG.md +8 -0
  3. emupos-0.1.0/CONTRIBUTING.md +145 -0
  4. emupos-0.1.0/LICENSE +202 -0
  5. emupos-0.1.0/NOTICE +21 -0
  6. emupos-0.1.0/PKG-INFO +314 -0
  7. emupos-0.1.0/README.md +278 -0
  8. emupos-0.1.0/SECURITY.md +30 -0
  9. emupos-0.1.0/docs/README.md +37 -0
  10. emupos-0.1.0/docs/api/openapi-v1.json +1652 -0
  11. emupos-0.1.0/docs/automation.md +475 -0
  12. emupos-0.1.0/docs/cli.md +457 -0
  13. emupos-0.1.0/docs/configuration.md +162 -0
  14. emupos-0.1.0/docs/keyboard-scanning-checklist.md +84 -0
  15. emupos-0.1.0/docs/linux-x11.md +63 -0
  16. emupos-0.1.0/docs/macos-accessibility.md +45 -0
  17. emupos-0.1.0/docs/protocols/escpos-status.md +252 -0
  18. emupos-0.1.0/docs/protocols/toledo8217.md +239 -0
  19. emupos-0.1.0/docs/spikes/keyboard-wedge.md +67 -0
  20. emupos-0.1.0/docs/spikes/windows-serial.md +66 -0
  21. emupos-0.1.0/docs/spikes/windows-snmp.md +66 -0
  22. emupos-0.1.0/pyproject.toml +111 -0
  23. emupos-0.1.0/scripts/check_api_compat.py +105 -0
  24. emupos-0.1.0/scripts/generate_glyphs.py +142 -0
  25. emupos-0.1.0/scripts/test_check_api_compat.py +77 -0
  26. emupos-0.1.0/src/emupos/__init__.py +0 -0
  27. emupos-0.1.0/src/emupos/api/__init__.py +0 -0
  28. emupos-0.1.0/src/emupos/api/app.py +55 -0
  29. emupos-0.1.0/src/emupos/api/dependencies.py +72 -0
  30. emupos-0.1.0/src/emupos/api/errors.py +74 -0
  31. emupos-0.1.0/src/emupos/api/guard.py +86 -0
  32. emupos-0.1.0/src/emupos/api/routes/__init__.py +0 -0
  33. emupos-0.1.0/src/emupos/api/routes/barcodes.py +20 -0
  34. emupos-0.1.0/src/emupos/api/routes/devices.py +59 -0
  35. emupos-0.1.0/src/emupos/api/routes/events.py +40 -0
  36. emupos-0.1.0/src/emupos/api/routes/health.py +16 -0
  37. emupos-0.1.0/src/emupos/api/routes/printers.py +92 -0
  38. emupos-0.1.0/src/emupos/api/routes/scales.py +42 -0
  39. emupos-0.1.0/src/emupos/api/routes/scanners.py +31 -0
  40. emupos-0.1.0/src/emupos/api/schemas.py +84 -0
  41. emupos-0.1.0/src/emupos/api/test_api.py +434 -0
  42. emupos-0.1.0/src/emupos/barcodes/__init__.py +0 -0
  43. emupos-0.1.0/src/emupos/barcodes/test_weighed.py +257 -0
  44. emupos-0.1.0/src/emupos/barcodes/weighed.py +137 -0
  45. emupos-0.1.0/src/emupos/cli/__init__.py +0 -0
  46. emupos-0.1.0/src/emupos/cli/actions.py +163 -0
  47. emupos-0.1.0/src/emupos/cli/app.py +106 -0
  48. emupos-0.1.0/src/emupos/cli/barcode.py +66 -0
  49. emupos-0.1.0/src/emupos/cli/client.py +149 -0
  50. emupos-0.1.0/src/emupos/cli/config_cmd.py +97 -0
  51. emupos-0.1.0/src/emupos/cli/devices.py +115 -0
  52. emupos-0.1.0/src/emupos/cli/doctor.py +169 -0
  53. emupos-0.1.0/src/emupos/cli/event_lines.py +80 -0
  54. emupos-0.1.0/src/emupos/cli/output.py +92 -0
  55. emupos-0.1.0/src/emupos/cli/run.py +122 -0
  56. emupos-0.1.0/src/emupos/cli/setup_cmd.py +33 -0
  57. emupos-0.1.0/src/emupos/cli/test_barcode.py +76 -0
  58. emupos-0.1.0/src/emupos/cli/test_commands.py +182 -0
  59. emupos-0.1.0/src/emupos/cli/test_config_cmd.py +129 -0
  60. emupos-0.1.0/src/emupos/cli/test_end_to_end.py +210 -0
  61. emupos-0.1.0/src/emupos/cli/test_output.py +190 -0
  62. emupos-0.1.0/src/emupos/config.py +543 -0
  63. emupos-0.1.0/src/emupos/daemon/__init__.py +0 -0
  64. emupos-0.1.0/src/emupos/daemon/connections.py +162 -0
  65. emupos-0.1.0/src/emupos/daemon/runtime.py +57 -0
  66. emupos-0.1.0/src/emupos/daemon/scans.py +46 -0
  67. emupos-0.1.0/src/emupos/daemon/server.py +87 -0
  68. emupos-0.1.0/src/emupos/daemon/simulator.py +158 -0
  69. emupos-0.1.0/src/emupos/drawer/__init__.py +0 -0
  70. emupos-0.1.0/src/emupos/drawer/drawer.py +61 -0
  71. emupos-0.1.0/src/emupos/drawer/test_drawer.py +209 -0
  72. emupos-0.1.0/src/emupos/events.py +110 -0
  73. emupos-0.1.0/src/emupos/printer/__init__.py +0 -0
  74. emupos-0.1.0/src/emupos/printer/escpos/__init__.py +0 -0
  75. emupos-0.1.0/src/emupos/printer/escpos/cases/README.md +21 -0
  76. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-image/expected.png +0 -0
  77. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-image/expected.txt +1 -0
  78. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-image/input.hex +41 -0
  79. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-image/notes.md +12 -0
  80. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-receipt/expected.png +0 -0
  81. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-receipt/expected.txt +10 -0
  82. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-receipt/input.hex +12 -0
  83. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/node-thermal-printer-receipt/notes.md +35 -0
  84. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-arabic-image/expected.png +0 -0
  85. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-arabic-image/expected.txt +2 -0
  86. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-arabic-image/input.hex +127 -0
  87. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-arabic-image/notes.md +13 -0
  88. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-barcodes/expected.png +0 -0
  89. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-barcodes/expected.txt +4 -0
  90. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-barcodes/input.hex +3 -0
  91. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-barcodes/notes.md +19 -0
  92. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-cash-drawer/expected.txt +0 -0
  93. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-cash-drawer/input.hex +1 -0
  94. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-cash-drawer/notes.md +9 -0
  95. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-column-image/expected.png +0 -0
  96. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-column-image/expected.txt +3 -0
  97. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-column-image/input.hex +46 -0
  98. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-column-image/notes.md +13 -0
  99. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-graphics-image/expected.png +0 -0
  100. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-graphics-image/expected.txt +1 -0
  101. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-graphics-image/input.hex +41 -0
  102. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-graphics-image/notes.md +16 -0
  103. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-qr/expected.png +0 -0
  104. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-qr/expected.txt +2 -0
  105. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-qr/input.hex +3 -0
  106. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-qr/notes.md +17 -0
  107. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-raster-image/expected.png +0 -0
  108. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-raster-image/expected.txt +1 -0
  109. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-raster-image/input.hex +145 -0
  110. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-raster-image/notes.md +10 -0
  111. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-text-styles/expected.png +0 -0
  112. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-text-styles/expected.txt +9 -0
  113. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-text-styles/input.hex +15 -0
  114. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/python-escpos-text-styles/notes.md +21 -0
  115. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-arabic-codepage/expected.png +0 -0
  116. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-arabic-codepage/expected.txt +1 -0
  117. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-arabic-codepage/input.hex +2 -0
  118. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-arabic-codepage/notes.md +18 -0
  119. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-image/expected.png +0 -0
  120. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-image/expected.txt +4 -0
  121. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-image/input.hex +47 -0
  122. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-image/notes.md +20 -0
  123. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-receipt/expected.png +0 -0
  124. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-receipt/expected.txt +8 -0
  125. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-receipt/input.hex +9 -0
  126. emupos-0.1.0/src/emupos/printer/escpos/cases/captured/receipt-printer-encoder-receipt/notes.md +28 -0
  127. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/code-page-placeholder/expected.png +0 -0
  128. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/code-page-placeholder/expected.txt +2 -0
  129. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/code-page-placeholder/input.hex +1 -0
  130. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/code-page-placeholder/notes.md +5 -0
  131. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/ean13-and-qr/expected.png +0 -0
  132. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/ean13-and-qr/expected.txt +2 -0
  133. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/ean13-and-qr/input.hex +3 -0
  134. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/ean13-and-qr/notes.md +5 -0
  135. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/gs-8-l-graphics/expected.png +0 -0
  136. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/gs-8-l-graphics/expected.txt +2 -0
  137. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/gs-8-l-graphics/input.hex +2 -0
  138. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/gs-8-l-graphics/notes.md +5 -0
  139. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/tabs-margins-positions/expected.png +0 -0
  140. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/tabs-margins-positions/expected.txt +5 -0
  141. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/tabs-margins-positions/input.hex +4 -0
  142. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/tabs-margins-positions/notes.md +7 -0
  143. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/wrap-and-justify/expected.png +0 -0
  144. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/wrap-and-justify/expected.txt +8 -0
  145. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/wrap-and-justify/input.hex +7 -0
  146. emupos-0.1.0/src/emupos/printer/escpos/cases/handwritten/wrap-and-justify/notes.md +6 -0
  147. emupos-0.1.0/src/emupos/printer/escpos/fonts/font-a-12x24.hex +251 -0
  148. emupos-0.1.0/src/emupos/printer/escpos/fonts/font-b-9x17.hex +251 -0
  149. emupos-0.1.0/src/emupos/printer/escpos/glyphs.py +117 -0
  150. emupos-0.1.0/src/emupos/printer/escpos/model.py +503 -0
  151. emupos-0.1.0/src/emupos/printer/escpos/render.py +146 -0
  152. emupos-0.1.0/src/emupos/printer/escpos/status.py +203 -0
  153. emupos-0.1.0/src/emupos/printer/escpos/symbols.py +173 -0
  154. emupos-0.1.0/src/emupos/printer/escpos/test_cases.py +49 -0
  155. emupos-0.1.0/src/emupos/printer/escpos/test_render.py +461 -0
  156. emupos-0.1.0/src/emupos/printer/escpos/test_status.py +73 -0
  157. emupos-0.1.0/src/emupos/printer/escpos/test_tokenizer.py +169 -0
  158. emupos-0.1.0/src/emupos/printer/escpos/tokenizer.py +264 -0
  159. emupos-0.1.0/src/emupos/printer/printer.py +286 -0
  160. emupos-0.1.0/src/emupos/printer/receipts.py +113 -0
  161. emupos-0.1.0/src/emupos/printer/test_printer.py +502 -0
  162. emupos-0.1.0/src/emupos/printer/test_receipts.py +92 -0
  163. emupos-0.1.0/src/emupos/printer/test_support.py +94 -0
  164. emupos-0.1.0/src/emupos/profiles/printers/epson-tm-t20iii.yaml +27 -0
  165. emupos-0.1.0/src/emupos/profiles/printers/rongta-rp326.yaml +19 -0
  166. emupos-0.1.0/src/emupos/profiles/printers/xprinter-xp80t.yaml +18 -0
  167. emupos-0.1.0/src/emupos/profiles/scales/toledo8217-15kg.yaml +12 -0
  168. emupos-0.1.0/src/emupos/scale/__init__.py +0 -0
  169. emupos-0.1.0/src/emupos/scale/scale.py +129 -0
  170. emupos-0.1.0/src/emupos/scale/test_scale.py +278 -0
  171. emupos-0.1.0/src/emupos/scale/test_weights.py +29 -0
  172. emupos-0.1.0/src/emupos/scale/toledo8217/__init__.py +0 -0
  173. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/line-terminators-after-a-request.txt +4 -0
  174. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/net-weight-below-zero.txt +6 -0
  175. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/new-unstable-weight-restarts-settling.txt +9 -0
  176. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/over-capacity.txt +4 -0
  177. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/probe-dialogue.txt +3 -0
  178. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/reading-settles-after-the-settle-time.txt +11 -0
  179. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/several-conditions-at-once.txt +6 -0
  180. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/stable-gross-weight.txt +4 -0
  181. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/stable-net-weight.txt +7 -0
  182. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/under-zero.txt +4 -0
  183. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/unknown-command-byte.txt +6 -0
  184. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/weighing-after-a-completed-probe.txt +7 -0
  185. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/weight-exactly-at-capacity.txt +4 -0
  186. emupos-0.1.0/src/emupos/scale/toledo8217/dialogues/weight-in-motion.txt +4 -0
  187. emupos-0.1.0/src/emupos/scale/toledo8217/test_toledo8217.py +225 -0
  188. emupos-0.1.0/src/emupos/scale/toledo8217/toledo8217.py +134 -0
  189. emupos-0.1.0/src/emupos/scale/weights.py +24 -0
  190. emupos-0.1.0/src/emupos/scanner/__init__.py +0 -0
  191. emupos-0.1.0/src/emupos/scanner/keys.py +68 -0
  192. emupos-0.1.0/src/emupos/scanner/scanner.py +133 -0
  193. emupos-0.1.0/src/emupos/scanner/test_keys.py +62 -0
  194. emupos-0.1.0/src/emupos/scanner/test_scanner.py +232 -0
  195. emupos-0.1.0/src/emupos/starter.yaml +42 -0
  196. emupos-0.1.0/src/emupos/test_config.py +346 -0
  197. emupos-0.1.0/src/emupos/test_events.py +67 -0
  198. emupos-0.1.0/src/emupos/transports/__init__.py +0 -0
  199. emupos-0.1.0/src/emupos/transports/errors.py +3 -0
  200. emupos-0.1.0/src/emupos/transports/framing.py +109 -0
  201. emupos-0.1.0/src/emupos/transports/keyboard/__init__.py +0 -0
  202. emupos-0.1.0/src/emupos/transports/keyboard/keyboard.py +71 -0
  203. emupos-0.1.0/src/emupos/transports/keyboard/macos.py +109 -0
  204. emupos-0.1.0/src/emupos/transports/keyboard/test_keyboard.py +66 -0
  205. emupos-0.1.0/src/emupos/transports/keyboard/test_macos.py +134 -0
  206. emupos-0.1.0/src/emupos/transports/keyboard/test_x11.py +87 -0
  207. emupos-0.1.0/src/emupos/transports/keyboard/x11.py +196 -0
  208. emupos-0.1.0/src/emupos/transports/ports.py +26 -0
  209. emupos-0.1.0/src/emupos/transports/pty.py +179 -0
  210. emupos-0.1.0/src/emupos/transports/serial_port.py +87 -0
  211. emupos-0.1.0/src/emupos/transports/tcp.py +73 -0
  212. emupos-0.1.0/src/emupos/transports/test_framing.py +103 -0
  213. emupos-0.1.0/src/emupos/transports/test_ports.py +20 -0
  214. emupos-0.1.0/src/emupos/transports/test_pty.py +193 -0
  215. emupos-0.1.0/src/emupos/transports/test_serial_port.py +101 -0
  216. emupos-0.1.0/src/emupos/transports/test_tcp.py +150 -0
  217. emupos-0.1.0/src/emupos/windows_queue/__init__.py +0 -0
  218. emupos-0.1.0/uv.lock +1062 -0
@@ -0,0 +1,27 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .venv/
5
+ build/
6
+ dist/
7
+ *.egg-info/
8
+
9
+ # Tooling caches
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .hypothesis/
13
+ .coverage
14
+ htmlcov/
15
+
16
+ # emupos runtime output
17
+ receipts/
18
+
19
+ # Editors and OS
20
+ .idea/
21
+ .vscode/
22
+ .DS_Store
23
+
24
+ # Spike results (send them back instead of committing)
25
+ spikes/**/result-*.json
26
+ spikes/**/snmp-log.jsonl
27
+ spikes/**/jobs/
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-09-13)
4
+
5
+
6
+ ### Features
7
+
8
+ * bootstrap emupos v0.1 (printer, drawer, scale, scanner, CLI, API) ([#1](https://github.com/ahmedalrifai/emupos/issues/1)) ([b985398](https://github.com/ahmedalrifai/emupos/commit/b9853985026fff48dfc20e4d40087e5fa4669026))
@@ -0,0 +1,145 @@
1
+ # Contributing to emupos
2
+
3
+ Thanks for helping. emupos pretends to be POS hardware on the wire, so most contributions are one of three kinds: a **device profile** (data), a **protocol or command** (small pure code), or a **platform fix** (OS-specific code in `transports/`).
4
+
5
+ ## Setup
6
+
7
+ You need [uv](https://docs.astral.sh/uv/). It installs the right Python for you.
8
+
9
+ ```sh
10
+ git clone https://github.com/ahmedalrifai/emupos.git
11
+ cd emupos
12
+ uv sync
13
+ uv run emupos --version
14
+ ```
15
+
16
+ Run the same checks as CI before opening a pull request:
17
+
18
+ ```sh
19
+ uv run ruff format # format
20
+ uv run ruff check # lint, import order, security rules, the I/O boundary
21
+ uv run pyright # strict type checking
22
+ uv run pytest # tests (they live next to the code)
23
+ ```
24
+
25
+ ## How the code is organised
26
+
27
+ ```
28
+ src/emupos/
29
+ ├── cli/ the `emupos` command (Typer)
30
+ ├── daemon/ the running simulator: wires config → devices → connections → api
31
+ │ ├── simulator.py devices, device output, timers, the physical-world actions
32
+ │ ├── connections.py opening TCP/serial connections and pumping bytes to devices
33
+ │ ├── scans.py delivering scans after their countdown
34
+ │ ├── runtime.py per-device runtime state, building devices from config
35
+ │ └── server.py `emupos run`: the simulator plus the control API until Ctrl+C
36
+ ├── config.py emupos.yaml and profile loading/validation
37
+ ├── events.py events, device Output, event bus
38
+ ├── api/ local control API (FastAPI)
39
+ │ ├── app.py builds the app: middleware, error handlers, routers
40
+ │ ├── dependencies.py the simulator and devices looked up by id
41
+ │ ├── schemas.py request and response bodies
42
+ │ ├── errors.py, guard.py error body, browser-request protection
43
+ │ └── routes/ one router per resource: devices, printers, scales, scanners, ...
44
+ ├── transports/ everything that touches the OS: TCP, pty, COM ports, SNMP, keystrokes
45
+ ├── printer/ receipt printer; escpos/ holds the ESC/POS tokenizer, status and renderer
46
+ ├── drawer/ cash drawer
47
+ ├── scale/ scale state; one folder per protocol (toledo8217/)
48
+ ├── barcodes/ weighed-item EAN-13 barcodes
49
+ ├── scanner/ barcode scanner
50
+ └── profiles/ built-in device profiles (YAML)
51
+ ```
52
+
53
+ The rule that keeps this readable: **device and protocol code is pure.** It receives state and bytes and returns an `Output` (bytes to write, events to publish). Only `transports/`, `api/` and `daemon/` may do I/O. Ruff enforces this: importing `asyncio`, `socket`, `ctypes`, `termios` or a serial library anywhere else fails lint.
54
+
55
+ Pure code never reads the clock. Functions that depend on time take `now` as an argument, so tests are instant and deterministic.
56
+
57
+ ## Adding a device profile
58
+
59
+ Profiles are data. Copy the closest file in `src/emupos/profiles/printers/` or `src/emupos/profiles/scales/`, rename it after the model (`vendor-model.yaml`), and edit the values. Every value needs a source: add a comment naming the manual or spec sheet, and mark anything unconfirmed with `# UNVERIFIED`.
60
+
61
+ Then add the profile to the built-in profile test in `src/emupos/test_config.py` and run `uv run pytest`.
62
+
63
+ Found a wrong value in an existing profile (for example a code-page number)? Open a "profile correction" issue with a photo of the printer's self-test page.
64
+
65
+ ## Adding a protocol or an ESC/POS command
66
+
67
+ 1. Put the code in the device's folder, e.g. `src/emupos/scale/<protocol>/<protocol>.py`, as pure functions or a small class.
68
+ 2. Cite the source for every command you handle in a one-line comment: manual name and section.
69
+ 3. Add a test next to it, with a fixture that exercises the command.
70
+ 4. Register it with one line in the device's registry (a plain dict).
71
+
72
+ ### Fixture formats
73
+
74
+ Protocol bytes are always written as spaced hex, never as escaped strings:
75
+
76
+ ```python
77
+ request = bytes.fromhex("10 04 01")
78
+ ```
79
+
80
+ Dialogue fixtures (`dialogues/*.txt`) list what the POS sends (`>`) and what the device replies (`<`):
81
+
82
+ ```
83
+ # stable weight of 1.250 kg
84
+ > 57
85
+ < 02 30 31 2e 32 35 30 0d
86
+ ```
87
+
88
+ ESC/POS rendering cases live in `printer/escpos/cases/<family>/<case>/` as `input.hex`, `expected.png`, `expected.txt` and `notes.md`.
89
+
90
+ ## Code rules
91
+
92
+ - Python 3.13+. Modern type hints only: `list[str]`, `X | None`. Pyright runs in strict mode.
93
+ - `@dataclass(frozen=True, slots=True)` for state snapshots and events.
94
+ - Status bits are `enum.IntFlag`, named as in the manual.
95
+ - Weights and money are integers (grams, minor currency units) or `Decimal`. Never `float`.
96
+ - Unknown or broken input from a POS never raises: real devices skip it, so we emit an event and continue. Exceptions are for operator mistakes (bad config, missing driver), and their message names the fix.
97
+ - OS-specific files stay small, and every error message says what to do next.
98
+ - Keep `__init__.py` files empty. Import from the module where code lives.
99
+ - No plugin systems, abstract base classes or dependency-injection frameworks. Add an interface when a second real implementation exists.
100
+
101
+ ## Dependency budget
102
+
103
+ emupos keeps a small set of runtime dependencies, all permissively licensed (CI fails on GPL, LGPL or AGPL). A new runtime dependency needs a line here explaining why a few lines of code cannot replace it.
104
+
105
+ | Dependency | Why |
106
+ |---|---|
107
+ | typer (with rich) | The CLI: commands, styled output, shell completion |
108
+ | fastapi, uvicorn | The local control API, with request validation and an OpenAPI document |
109
+ | websockets | The control API event stream, and the CLI waiting for events |
110
+ | pydantic | Validates configuration, profiles and API bodies; exports JSON Schema |
111
+ | pyyaml | Reads configuration and profiles (safe loader only) |
112
+ | pillow | Renders receipts as 1-bit PNG images |
113
+ | segno | QR code matrices for printed QR codes |
114
+ | python-barcode | Bar patterns for printed 1D barcodes |
115
+ | pyobjc-framework-Quartz (macOS only) | Posts keyboard-wedge keystrokes |
116
+ | serialx (Windows only) | Asynchronous access to COM ports |
117
+
118
+ ## Generated files
119
+
120
+ Two files are generated and checked in CI. Regenerate them in the same pull request as the change:
121
+
122
+ ```sh
123
+ # after changing a command, option or help text
124
+ uv run typer emupos.cli.app utils docs --name emupos --title "emupos command reference" --output docs/cli.md
125
+
126
+ # after adding to the control API (new endpoints or fields are fine within /api/v1)
127
+ uv run python scripts/check_api_compat.py # must pass
128
+ uv run python scripts/check_api_compat.py --update # then record the new contract
129
+ ```
130
+
131
+ The API check fails when an endpoint or field is removed, a field changes type, or a request field becomes required. Those changes need a new `/api/v2` instead.
132
+
133
+ ## Pull requests
134
+
135
+ Pull requests are squash-merged, and the title becomes the commit message that drives the version number and changelog. Use [Conventional Commits](https://www.conventionalcommits.org/):
136
+
137
+ - `feat(scale): add NCI protocol` → new feature (minor release)
138
+ - `fix(printer): wrap Font B at 64 columns` → bug fix (patch release)
139
+ - `feat(config)!: rename receipts_dir` → breaking change
140
+
141
+ A CI check rejects titles that don't follow the format.
142
+
143
+ ## Licence
144
+
145
+ By contributing you agree that your contribution is licensed under the [Apache License 2.0](LICENSE).
emupos-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
emupos-0.1.0/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ emupos
2
+ Copyright 2026 emupos contributors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ This product includes data derived from third-party projects:
7
+
8
+ - escpos-printer-db (https://github.com/receipt-print-hq/escpos-printer-db)
9
+ Printer capability data. Licensed under the Creative Commons
10
+ Attribution 4.0 International License (CC-BY-4.0).
11
+
12
+ - ReceiptPrinterEncoder (https://github.com/NielsLeenheer/ReceiptPrinterEncoder)
13
+ Vendor code-page number mappings. Copyright (c) Niels Leenheer.
14
+ Licensed under the MIT License.
15
+
16
+ This product includes font data derived from:
17
+
18
+ - Spleen (https://github.com/fcambus/spleen)
19
+ Bitmap glyphs for receipt printer Fonts A and B (src/emupos/printer/escpos/fonts/).
20
+ Copyright (c) 2018-2026, Frederic Cambus. Licensed under the BSD 2-Clause License;
21
+ the full licence text is included at the top of each glyph table.