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

David T. Lewis lewis at mail.msen.com
Thu Jan 11 03:53:33 UTC 2018


On Wed, Jan 10, 2018 at 05:42:40PM -0800, tim Rowledge wrote:
>  
> 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 -


>From looking at the Makefile, I would say that the init script is being
installed but it has not been wired into the system boot processing.
Possibly the person who wrote the makefile left that part as an "exercise
for the reader".

Give this a try and see if it works: Reboot the Pi, at which point the servo
will not be working. Then run this command (possibly with sudo in front if
it if you are not root):

# /etc/init.d/pca9685servo start

At this point, the servo will probably be working.

If the above works out, then you will just need to set up a symlink to
one of the /etc/rc?.d/ directories. That will cause the init script to be
run when the system boots up.

Let me know if this works, and if so we'll figure out the symlink to add.

Dave



More information about the Vm-dev mailing list