You are not logged in.
Pages: 1
I'm currently running build 3342.
I'm trying to control my projector using some python code.
When I ssh into my raspberry pi I can run python code without issue. I have 4 scripts: turn the projector on/off and turn the LED on/off.
I've added custom buttons on the projector calibration page using "[[Exec python /home/pi/printer/pythonScripts/projectorLEDOff.py]]"
When I run the script this way I don't see the corresponding behavior as when I run it through ssh, and I get the following in the application log: "Execute Command Without Waiting For the Result python /home/pi/printer/pythonScripts/projectorLEDOff.py"
Is [[Exec ]] broken? Am I doing something wrong?
Any ideas?
Last edited by tomres (2020-07-22 19:19:26)
Offline
Change Exec to ExecReturn, then check activity log on dashboard to see why it does not run correctly
Offline
Using [[ExecReturn ]]
I have this message:
Debug 0 2020-07-26 16:17:51.353706 Gcode Execute Command and Return the Result python /home/pi/printer/pythonScripts/p_OFF.py
running the same script over ssh using "python p_OFF.py" turns the projector off, through nanoDLP there is no behavior.
Offline
So it does not throw any error? May I check you python source code.
Offline
No errors.
This is my python code to turn the projector off:
#!/usr/bin/python
import os
import sys
import re
import struct
import ctypes
from ctypes import *
USB3DPrinter = ctypes.CDLL('/home/pi/printer/pythonScripts/LibUSB3DPrinter.so')
USB3DPrinter.CloseUsbDevice()
USB3DPrinter.OpenUsbDevice()
USB3DPrinter.PowerOnOff(2)
USB3DPrinter.Delay10Ms(3000)
USB3DPrinter.CloseUsbDevice()
This is taken from a sample python script provided by the projector manufacturer, and as I've mentioned, this works when I run it over ssh.
Offline
Try add sh -c before your command see if does help or not.
Offline
Tried the following:
[[Exec sh -c python /home/pi/printer/pythonScripts/projectorLEDOff.py]]
with no change.. Is that the correct usage of sh -c?
Last edited by tomres (2020-07-29 15:22:21)
Offline
Yes it is correct, try add bash script and call bash script instead of python.
Also instead of python use full path /usr/bin/python
The issue probably something to do with how binary being called.
Offline
Tried using full path to python with no result.
Added a bash script that calls the python script. Just contains the following:
#!/bin/sh
python /home/pi/printer/pythonScripts/p_OFF.py
had to adjust permissions using sudo chmod +x p_OFF.sh
Added a button that calls the shell script (is this the correct usage?):
[[ExecReturn /home/pi/printer/pythonScripts/p_OFF.sh]]
No errors in application log, again just says "Execute Command and Return the Results /home/pi/printer/pythonScripts/p_OFF.sh"
No results.
added sh -c before calling the bash script, no result.
tried:
[[ExecReturn bash /home/pi/printer/pythonScripts/p_OFF.sh]]
still no result.
Would love to get to the bottom of this issue!
Let me know if you have any other ideas.
Offline
I think I have the same situation, I can play wav files using putty, but not from inside nanoDLP, this was not a problem some versions ago.
But it gets weirder, I can execute some python scripts that control the light engine from inside nanoDLP.
There is one python script (not written by me) that tells the light engine to flip the image. I am guessing it has stopped working because I just noticed that letters print in reverse. (I remedy this now with the new options in machine settings)
I also hope you can identify and fix this problem, UV light engines are sensitive to improper shutdown, I have many blown pixels.
Offline
Tom,
Maybe you have not used full path as I advised above.
[[ExecReturn /usr/bin/python /home/pi/printer/pythonScripts/p_OFF.py]]
I also another reason could be how it get run by systemd. Disable nanodlp service and run it manually
cd /home/pi/printer
sudo ./printer
If it works you need to adjust nanodlp systemd service file.
https://wiki.archlinux.org/index.php/systemd
Offline
Hi Shahin, sorry for delay in testing this.
I tried using the full path and also tried your suggestion to disable the nanoDLP service. Neither of these resulted in the python script executing. Please let me know if you have other suggestions!
Offline
Can I have a sample python script which I can run (does not require special library) and see if I could find the issue?
Offline
Hi Shahin,
here is the python example I received from the manufacturer (which works over SSH)
https://we.tl/t-6maEXBdvIm
It does require a custom library (which I have included)
Offline
Tom,
Sorry I missed this thread. Try remove python itself.
[[ExecReturn /home/pi/printer/pythonScripts/p_OFF.py]]
Offline
Pages: 1