I have following situation (and problem):
Setup:
Raspberry Pi Zero W, connected to a Windows client via USB-OTG in Ethernet emulation mode.
The Pi is controlling a single servo motor, via Python Scripts.
Goal:
I need to be able to execute the python scripts, which control the servo. Execution must be triggered from the Windows client via a Batch-file.
What I've tried:
As the Pi is connected via Ethernet emulation, it gets a (static) 169.x.x.x IP. I am able to connect to the Pi via SSH.
I tried writing a batch-file which does the following:
- Connect to Raspberry Pi (with given credentials) via "plink.exe"
- Execute Python script.
Problem:
While my solution generally works, it is way too slow. From executing the batch-file to the actual control of the servo-motor it needs about 8-10 Seconds.
This is mainly because of the SSH authentification process.
If I am connected to the Pi via Putty and execute the script directly, the motor reacts almost instantly.
Possible solution I have thought of:
I have thought of follwing - but am unable to find a way to realize it:
- Create shared folder on Windows Client
- (permanently) mount shared folder on Raspberry
- Some kind of Script or daemon running on the Raspberry monitors the folder (every Second or so)
- If folder contains file with name "rotate_right.xy": -> Execute "rotate_right.py" and delete "rotate_right.xy"
- Batch file on Windows Client: create file "rotate_right.xy"
As I am no coder whatsoever, I am (currently) unable to solve this. Maybe my thinking process is faulty - or there are more "elegant" ways to solve this -- I really hope someone can help me with this (or push me in the right direction)
Thanks in advance, Iring