[Vm-dev] linux systems startup stuff for a servo controller daemon

tim Rowledge tim at rowledge.org
Thu Jan 11 01:42:40 UTC 2018


This is a bit off topic but since it is for Squeak to be able to easily control PWM devices it shouldn’t upset anyone too much…

I’ve written a daemon to run on a Pi that provides /dev/pca9685servo so you can write commands to move a servo using a HAT that has a PCA9685 pwm chip. It in turn uses the pigpiod daemon that handles the i2c communications for me. It all works quite nicely *except*….

So, if I build the daemon and install it by doing the usual sort of terminal dance
sudo make install
then the code builds and gets copied and the init-script copied and all appears to be well. I can then do
echo 0=50% > /dev/pca9685servo
and have the servo connected to port 0 move to the centre of its range.
echo o=+10% > /dev/pca9685servo
will move it by 10% - you get the picture I’m sure. There a bucket load of options with some explanation in the help message.

Sounds great! Except if I reboot the Pi things go weird. Part of the problem is likely that the init-script is an old-style inti.d file and not a systemd unit file. Part is that it doesn’t automatically start pigpiod, so I have to manually do that and restart the pca9685servo daemon. If I do that, the status claism all is well. I can send commands. But nothing happens to the servos. Sigh.

If I kill the daemon with 
sudo systemctl stop pca9685servo
and then manually start it with 
sudo /usr/local/sbin/pca9685servod
well then my servos move around like the willing servants they are meant to be.

I’ve been around and around on this far too many times for my sanity and I could do with some advice/assistance from someone that actually has a grip on this level of stuff. Since the source tgz is a whole 8Kb I’ll just attach it here -
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pca9685servod.tgz
Type: application/octet-stream
Size: 7944 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20180110/f7787898/attachment.obj>
-------------- next part --------------


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Strange OpCodes: PSP: Push Stack Pointer




More information about the Vm-dev mailing list