Hi Guys,
was busy and had to to postbone this project.
But as always, now its urgent
wanted to update for future reference:
the printer is a MCS KSM 345
they have cups driver but you need to install a ton of extra services in order to make it run.
biggest issue I had, was that while USB was recocnized, the printer was not found via ethnert. Ping is working, so no idea.
The nc command provided by you is working, so I wasnt wasting to much time on this.
Maybe for the future I will use the USB connection.
for my code:
what I did so far is this:
which works.
I mostly just copied commands and tutorials for this. I never actually learned how to do this, and its my first real project. so dont ask why I solved this or that
Im quite sure there are some flaws. Happy if you point them out.
One thing which I would likle to solve:
When running this on my Pi via Thonny I can see the print output. But once the subprocess was activated the print command seems to stop working.
sending the .bin files via my buttons is still working. Any idea what I did wrong?
was busy and had to to postbone this project.
But as always, now its urgent

wanted to update for future reference:
the printer is a MCS KSM 345
they have cups driver but you need to install a ton of extra services in order to make it run.
biggest issue I had, was that while USB was recocnized, the printer was not found via ethnert. Ping is working, so no idea.
The nc command provided by you is working, so I wasnt wasting to much time on this.
Maybe for the future I will use the USB connection.
for my code:
what I did so far is this:
Code:
import RPi.GPIO as GPIO from time import sleep import subprocessimport RPi.GPIO as GPIOBASEMODELL = 21RETRACTOR = 20PRESENTER = 16 GPIO.setmode(GPIO.BCM) GPIO.setup(BASEMODELL,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(RETRACTOR,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(PRESENTER,GPIO.IN,pull_up_down=GPIO.PUD_UP) # Define a threaded callback function to run in another thread when events are detected def print_RETRACTOR(channel): if GPIO.input(RETRACTOR): print ("falling 20") result = subprocess.run(["bash", "-c", "cat /home/tps/1.bin | nc -w 1 192.168.0.100 9000"],shell=False) else: print ("rising 20") GPIO.add_event_detect(RETRACTOR, GPIO.BOTH, callback=print_RETRACTOR, bouncetime=200) def print_PRESENTER(channel): if GPIO.input(PRESENTER): print ("falling 16") result = subprocess.run(["bash", "-c", "cat /home/tps/specs.bin | nc -w 1 192.168.0.100 9000"],shell=False) else: print ("rising 16") GPIO.add_event_detect(PRESENTER, GPIO.BOTH, callback=print_PRESENTER, bouncetime=200) def print_BASEMODELL(channel): if GPIO.input(BASEMODELL): print ("falling 21") result = subprocess.run(["bash", "-c", "cat /home/tps/specs.bin | nc -w 1 192.168.0.100 9000"],shell=False) else: print ("rising 21") GPIO.add_event_detect(BASEMODELL, GPIO.BOTH, callback=print_BASEMODELL, bouncetime=200) try: while True: print ("When pressed, you'll see: falling Edge ") print ("When released, you'll see: rising") sleep(5) print ("Time's up. Finished!") finally: GPIO.cleanup()
I mostly just copied commands and tutorials for this. I never actually learned how to do this, and its my first real project. so dont ask why I solved this or that

Im quite sure there are some flaws. Happy if you point them out.
One thing which I would likle to solve:
When running this on my Pi via Thonny I can see the print output. But once the subprocess was activated the print command seems to stop working.
sending the .bin files via my buttons is still working. Any idea what I did wrong?
Statistics: Posted by SIG-Ricker — Tue Feb 20, 2024 2:16 pm