You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+62-46Lines changed: 62 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -3,62 +3,72 @@ PrusaConnect SDK for Printer
3
3
4
4
Printer instance
5
5
----------------
6
-
You can create a Printer instance using the constructor and passing `server` and `token` to it. These you can find in `prusa_printer_settings.ini`.
6
+
You can create a Printer instance using the constructor passing printer type,
7
+
serial number and printer fingerprint to it. Serial number can be found on the printer label.
8
+
For I3MK3 and SL1, printer fingerprint is a SHA256 HEX digest of the serial number.
7
9
8
10
.. code:: python
9
11
10
12
from prusa.connect.printer import Printer, const
11
13
14
+
SN="Printer serial number"
15
+
FINGERPRINT= sha256(SN.encode()).hexdigest()
16
+
PRINTER_TYPE= const.PrinterType.I3MK3
17
+
printer = Printer(PRINTER_TYPE, SN, FINGERPRINT)
18
+
19
+
For setting the connection you should call `set_connection` passing `server` and `token` to it. These you can find in the `prusa_printer_settings.ini` file. You can download it after printer registration from the Connect web by selecting your printer -> Settings -> LAN settings -> Download settings. If the printer has not been registered yet, refer to the Registration section below.
20
+
21
+
.. code:: python
22
+
12
23
SERVER="https://connect.prusa3d.com"
13
-
SN='SERIAL_NUMBER_FROM_PRINTER'
14
-
FINGERPRINT='Printer fingerprint'
15
-
TOKEN='secret token from prusa_printer_settings.ini'
If the printer has not been registered yet, you need to use `Printer.register()` to get a temporary code. This code is then used in the **Add Printer** form in Connect Web. After the printer
37
-
has been added to Connect, `Printer.get_token()` will return printer's persistent token.
41
+
If the printer has not been registered yet, you need to use `Printer.register()` to get a temporary code. Enter this code in the **Add Printer** form in Connect Web. After the printer has been added to Connect, your Printer instance will automatically retrieve the code in the background.
print(f"Use this code `{tmp_code}` in add printer form "
50
58
f"{SERVER}/printers/overview?code={tmp_code}.")
51
59
52
-
token =None
53
-
while token isNone:
54
-
token = printer.get_token(tmp_code)
60
+
while printer.token isNone:
61
+
print("Waiting for the printer registration on the Connect web...")
55
62
sleep(1)
56
63
57
-
print("Printer is registered with token %s"% token)
64
+
print(f"Printer is registered with token {printer.token}")
65
+
66
+
Note: For I3MK3 the Add Printer form does not allow you manually enter the temporary code.
67
+
You can use this url to add it directly: https://connect.prusa3d.com:443/add-printer/connect/{PRINTER_TYPE}/{tmp_code}
58
68
59
69
Telemetry
60
70
---------
61
-
Printer must send telemetry to connect at least each second. Because obtaining telemetry values might not be atomic, this must be done in a different thread than `Printer.loop`.
71
+
Printer must send telemetry to Connect at least once per second. Because obtaining telemetry values might not be atomic, this must be done in a separate thread from `Printer.loop`.
62
72
63
73
.. code:: python
64
74
@@ -67,29 +77,32 @@ Printer must send telemetry to connect at least each second. Because obtaining t
67
77
68
78
...
69
79
70
-
#start communication loop
80
+
#Start communication loop in a separate thread
71
81
thread = Thread(target=printer.loop)
72
82
thread.start()
73
83
74
-
#each second send telemetry to internal queue in the main-thread
84
+
#Send telemetry to the main thread queue once per second
0 commit comments