I am trying to get the python script@Peter_Johnson wrote for the color sensor running on a raspberry pi imaged with wpilib at startup. I am not running it in the vision app as that is already used.
busybox-klogd.service loaded active exited LSB: Starts klogd
busybox-syslogd.service loaded active running LSB: Starts syslogd
â—Ź colorSensor.service loaded failed failed Color Sensor
console-setup.service loaded active exited Set console font and keym
If I change my .service file to add > /home/pi/colorSensor.log 2>&1 no file shows up.
I am not a linux guy nor python so any help is appreciated.
Before I tried to daemonize this I could run the /usr/bin/python3.7 rpi-colorsensor.py and get meaningful results (I have some prints that aren’t in Peters project just so I could know it is working.
Thank you. This gave me what I needed. I forgot the path to my script
My ExecStart should have been
ExecStart=/usr/bin/python3.7 /home/pi/rpi-colorsensor.py
Glad you got it working with systemd. Note the readme also has the configuration steps needed to make it a background service using svc (which is how the vision program is started).
Ok, trying to move to the pi 4 we will be using and having some issues. I only have one thing plugged in and am trying to run foreground not daemon yet
pi@wpilibpi(ro):~$ /usr/bin/python3.7 rpi-colorsensor.py
Setting up NetworkTables client for team 5013
Unknown device found with same I2C addres as REV color sensor
Traceback (most recent call last):
File "rpi-colorsensor.py", line 484, in <module>
color = sensor1.getColor()
File "rpi-colorsensor.py", line 266, in getColor
return Color(r / mag, g / mag, b / mag)
ZeroDivisionError: division by zero
pi@wpilibpi(ro):~$
boot config for a 4 setup
pi@wpilibpi(ro):~$ cat /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Enable camera
start_x=1
gpu_mem=128
disable_camera_led=1
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
dtoverlay=i2c3
dtoverlay=i2c4
dtoverlay=i2c5
dtoverlay=i2c6
[all]
#dtoverlay=vc4-fkms-v3d
I don’t have to do the 3 part on the 4 do i? when I did my session froze up
So it worked on the 3 but not the 4? You might try turning on I2C via the raspi-config method, potentially the config is a little different? Also the I2C bus numbering could conceivably be different between the two. My Pi4 recently died so I don’t have a good way to test