Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a Pause Flag on RPC server? #1409

Open
STS-ATS opened this issue Jan 28, 2024 · 7 comments
Open

Is there a Pause Flag on RPC server? #1409

STS-ATS opened this issue Jan 28, 2024 · 7 comments

Comments

@STS-ATS
Copy link

STS-ATS commented Jan 28, 2024

Hi there,

Ive been working on a little code for getting a notification with the printing characteristics and sending some commands to control it remotely

But, in some Gcodes i need to know when the printing got paused to send a notification

Is there any form or a kind of "flag" that could be accesed via RPC server?
I have a couple of ideas on how to solve the problem, like reading the eta if its equal to 0, but, if its already integrated, could be cleaner solution.

Ive read the rpc.py code but, cant find something like that status report on pause

Thanks to the pronterface team for their work.

Thanks for your suggestions and answers.

@DivingDuck
Copy link
Collaborator

One possible way is to add https://reprap.org/wiki/G-code#M118:_Echo_message_on_host before a pause. You can catch up the message then and use this as a trigger in your action chain.

@STS-ATS
Copy link
Author

STS-ATS commented Jan 30, 2024

Ok, got it
Thanks

But, how could i capture the message?

Ive been reading some .py files of pronterface, ive found the eventhandler.py https://github.com/kliment/Printrun/blob/master/printrun/eventhandler.py
and ive found some interesting "flags", like error, on_end, on_layerchange, on_printsend and the on_recv
i wonder if there is any way to access that data from the rpc server?

or do i have to change the rpc.py to add options to read that data and re-make the pronterface.exe?

i have another question, how could i know in which exact number line of the G code, the software is sending to the printer?
other than counting the number of events of the on_printsend of the eventhandler

I will really appreciate your ideas, and comments

@rockstorm101
Copy link
Collaborator

ive found some interesting "flags", like error, on_end, on_layerchange, on_printsend and the on_recv
i wonder if there is any way to access that data from the rpc server?

No, such functionality does not seem implemented as of today.

how could i know in which exact number line of the G code, the software is sending to the printer?

Good question (note to self to document this attribute) The printcore.printcore.queueindex attribute holds the current index in the queue of commands to be sent

@DivingDuck
Copy link
Collaborator

Good question (note to self to document this attribute) The printcore.printcore.queueindex attribute holds the current index in the queue of commands to be sent

I did never use or play myself with printcore.printcore.queueindex but I saw you mentioned this in #1397. I saw an old issue #263 where @kliment mentioned !print self.p.queueindex as well.

@STS-ATS
Copy link
Author

STS-ATS commented Mar 7, 2024

Hey there, i have an update, jejeje

Guys, the RPC server is already reporting the current line, on the ETA, its the third value, i have already been able to extract it and use it

Somehow i didn't notice it when i was working with that

Thanks, hope it would be usefull

@DivingDuck
Copy link
Collaborator

DivingDuck commented Mar 7, 2024

I just run the rpc server it myself as I didn't use it in the past. I can see the following output:

On print:

{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG_ohneTemp.gcode', 'progress': 2.4973348391931687, 'eta': [7276.893032068913, 7471.893032068913, 4732], 'temps': {'T': ['23.7', '0.0'], 'T1': ['24.0', '0.0'], 'B': ['23.4', '0.0'], 'B1': ['22.8', '0.0']}, 'z': 0.6000000238418579}

On Pause:

>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG_ohneTemp.gcode', 'progress': None, 'eta': None, 'temps': {'T': ['23.7', '0.0'], 'T1': ['24.0', '0.0'], 'B': ['23.4', '0.0'], 'B1': ['22.8', '0.0']}, 'z': 0.800000011920929}

I can see that there are some quirks, like format of eta, z high not showing on first layer or when printing from SD do not show any information except temperature.

Here an example where I start a real print from start to manually pausing and then aborting the print:

Pay attention on my --> marks for understanding what happen during a print and where some wrong information occur.


>>> import xmlrpc.client
>>> rpc = xmlrpc.client.ServerProxy('http://localhost:7978')
>>> print(rpc.status()) --> after start heating the bed. Target as well as actual temp and z arn't updated what is actual a bad situation...
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.005805300767355211, 'eta': [6551.908890955335, 6551.908890955335, 11], 'temps': {'T': ['24.7', '0.0'], 'T1': ['24.4', '0.0'], 'B': ['23.9', '0.0'], 'B1': ['23.2', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.005805300767355211, 'eta': [6551.908890955335, 6551.908890955335, 11], 'temps': {'T': ['24.7', '0.0'], 'T1': ['24.4', '0.0'], 'B': ['23.9', '0.0'], 'B1': ['23.2', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.007388564612997541, 'eta': [6551.820835508195, 6713.820835508195, 14], 'temps': {'T': ['25.8', '0.0'], 'T1': ['24.3', '0.0'], 'B': ['81.0', '81.0'], 'B1': ['23.2', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status()) --> after bed temp reached the target temp. Still wrong temps before and then only heater temp is shown while bed temp is at 81 °C, z isn't updated...
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.008444073843425761, 'eta': [6551.762131876768, 6719.762131876768, 16], 'temps': {'T': ['105.3', '240.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.008444073843425761, 'eta': [6551.762131876768, 6719.762131876768, 16], 'temps': {'T': ['151.3', '240.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.008444073843425761, 'eta': [6551.762131876768, 6719.762131876768, 16], 'temps': {'T': ['192.4', '240.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.008444073843425761, 'eta': [6551.762131876768, 6719.762131876768, 16], 'temps': {'T': ['219.7', '240.0']}, 'z': 1.600000023841858}
>>> print(rpc.status()) --> bed and heater reached target temp and started the print. z still not updated... 
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.031137522297632492, 'eta': [6550.500003801096, 6818.500003801096, 59], 'temps': {'T': ['245.2', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.4', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.10396765919717968, 'eta': [6546.44945323266, 6826.44945323266, 197], 'temps': {'T': ['245.6', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.4', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.2153238830073569, 'eta': [6540.256220117151, 6838.256220117151, 408], 'temps': {'T': ['238.9', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.4', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.29712584836554395, 'eta': [6535.706688681589, 6846.706688681589, 563], 'temps': {'T': ['240.0', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.5', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.42748123832342916, 'eta': [6528.456790200402, 6853.456790200402, 810], 'temps': {'T': ['240.3', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.5', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 0.7995482420493767, 'eta': [6507.763760122521, 6843.763760122521, 1515], 'temps': {'T': ['239.9', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.5', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 1.2291404988336623, 'eta': [6483.871382131888, 6832.871382131888, 2329], 'temps': {'T': ['240.1', '240.0'], 'T1': ['24.5', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.6', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 1.520461046431851, 'eta': [6467.669179858142, 6827.669179858142, 2881], 'temps': {'T': ['240.1', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.6', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 1.697258842528578, 'eta': [6457.8363215941845, 6828.8363215941845, 3216], 'temps': {'T': ['240.1', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.0', '81.0'], 'B1': ['23.6', '0.0']}, 'z': 1.600000023841858}
>>> print(rpc.status()) --> now print on on second layer started, z have now a valid z height...
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 1.904138651692509, 'eta': [23872.17801305205, 24254.17801305205, 3608], 'temps': {'T': ['240.0', '240.0'], 'T1': ['24.5', '0.0'], 'B': ['81.1', '81.0'], 'B1': ['23.6', '0.0']}, 'z': 0.4000000059604645}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': 1.966413696287774, 'eta': [23855.779328443175, 24249.779328443175, 3726], 'temps': {'T': ['239.9', '240.0'], 'T1': ['24.5', '0.0'], 'B': ['81.0', '81.0'], 'B1': ['23.7', '0.0']}, 'z': 0.4000000059604645}
>>> print(rpc.status()) --> now pausing the print:
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': None, 'eta': None, 'temps': {'T': ['239.9', '240.0'], 'T1': ['24.4', '0.0'], 'B': ['81.0', '81.0'], 'B1': ['23.7', '0.0']}, 'z': 0.4000000059604645}
>>> print(rpc.status()) --> now stopping the print:
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': None, 'eta': None, 'temps': {'T': ['239.9', '0.0'], 'T1': ['24.5', '0.0'], 'B': ['80.5', '0.0'], 'B1': ['23.8', '0.0']}, 'z': 0.6000000238418579}
>>> print(rpc.status())
{'filename': 'C:\\Users\\Armin\\Documents\\3D-Printer\\3D Modelle\\3DBenchy\\Armin\\3DBenchyHEVOPETG.gcode', 'progress': None, 'eta': None, 'temps': {'T': ['207.2', '0.0'], 'T1': ['24.5', '0.0'], 'B': ['75.5', '0.0'], 'B1': ['23.9', '0.0']}, 'z': 0.6000000238418579}
>>> 

There is real potential for improving the code of Pronterface / RPC server. Be careful with interpreting the shown information.

@rockstorm101, we should leaf this open as I have some concern with the behavior of RPC (see in details). The shown information need to be at least correct, especially for temp values.

@rockstorm101
Copy link
Collaborator

@rockstorm101, we should leaf this open as I have some concern with the behavior of RPC (see in details). The shown information need to be at least correct, especially for temp values.

Agreed. We can definitely improve the code a bit. I would open a new issue with your findings and what exactly needs changing. Since this one was more like a question about pausing a print via RPC and not technically a bug report. But up to you. I'm happy either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants