Consegui configurar o raspberry Pi como servidor de wifi_router / firewall / gammu / weewex / ups / webcam. O problema que não consigo resolver é um problema de incompatibilidade entre o linux e a webcam da Microsoft. Após alguns dias desconecta e nada restaura a função exceto desconectar completamente a webcam do usb e da energia. O pior é que às vezes acontece que quando o script de foto fswebcam é chamado de cron e a webcam USB está em estado de falha após muitas chamadas com falha, ele quebra todo o sistema operacional.
Poderia, por favor, ajudar-me a encontrar uma maneira de testar se a webcam está bem conectada, para que o script de foto continue, caso contrário, o script parará para evitar problemas do sistema operacional?
O que estou fazendo em etapas:
1) script de punho de chamada do cron
*/10 6,7,8,9,10,11,12,13,14,15,16,17,18 * * * /home/pi/webcam.sh >/dev/null 2>&1
2) Iniciar tarefas do script "/home/pi/webcam.sh" #! / bin / bash
bash /home/pi/webcam2.sh
sleep 2
chmod 755 /var/www/weewx/webcam.JPG
3)launch photo script "webcam2.sh"
#!/bin/sh
I think, that this is the place where is the best to add some testing command something like if uvcvideo/lusb--->OK then fswebcam... else exit script and do nothing. I do not know how to write this :o)
3) script de lançamento webcam2.sh
OUTPUT_DIR=/var/www/weewx
OUT_FILE=webcam
TEMP=/var/www/weewx/temp
BRIGHTNESS_TRESHOLD_MAX=60 # for too bright images
#mkdir -p $OUTPUT_DIR
mkdir -p $TEMP
take_photo () {
fswebcam -S 2 --jpeg 90 \
-r 1200x720 \
--palette YUYV \
--set Gamma=50 \
--set Saturation=75 \
--set "Backlight Compensation"=0 \
--set Contrast=55% \
--timestamp "%Y-%m-%d %H:%M (%Z)" \
--set brightness=$2 \
--input 0 \
-q \
--title "Vápenná" \
--save $TEMP/$1.JPG
}
#echo ------------------------ first photo -------------
take_photo 0 "50%"
jasnosc='convert $TEMP/0.JPG -colorspace hsb -resize 1x1 txt:- | \
sed 1d | tr '()%' ' ' | awk -F "," '{print $6}''
#echo 'echo "$jasnosc <= $BRIGHTNESS_TRESHOLD" | bc'
#exit
if [ 'echo "$jasnosc >= $BRIGHTNESS_TRESHOLD_MAX" | bc' -eq 1 ]
then
# echo "Brightness: $jasnosc ... too high - reducing brightness ..."
take_photo 0 "30%"
mv $TEMP/0.JPG $OUTPUT_DIR/"$OUT_FILE".JPG
else
# echo "Brightness: $jasnosc : one photo is enoguh ...."
Failure if the usbwebcam fails looks like this :
Sep 19 06:40:02 raspberrypi kernel: [300219.357181] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 06:40:04 raspberrypi kernel: [300221.272042] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 06:50:04 raspberrypi kernel: [300820.754079] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 07:40:01 raspberrypi kernel: [303818.710821] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 07:50:04 raspberrypi kernel: [304420.777554] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 09:00:02 raspberrypi kernel: [308619.016454] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 09:10:04 raspberrypi kernel: [309221.417157] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 09:50:04 raspberrypi kernel: [311620.981589] uvcvideo: Failed to resubmit video URB (-1).
Sep 19 10:30:01 raspberrypi kernel: [314017.777896] usb 1-1.4.4.4: USB disconnect, device number 14
Sep 19 10:30:01 raspberrypi kernel: [314017.974685] ------------[ cut here ]------------
Sep 19 10:30:01 raspberrypi kernel: [314017.974736] WARNING: CPU: 3 PID: 20956 at fs/sysfs/group.c:237 sysfs_remove_group+0xa0/0xa4()
Sep 19 10:30:01 raspberrypi kernel: [314017.974748] sysfs group 808a93dc not found for kobject 'event0'
Sep 19 10:30:01 raspberrypi kernel: [314017.974756] Modules linked in: evdev uvcvideo snd_usb_audio videobuf2_vmalloc videobuf2_memops snd_hwdep videobuf2_v4l2 snd_usbmidi_lib videobuf2_co$
Sep 19 10:30:01 raspberrypi kernel: [314017.974969] CPU: 3 PID: 20956 Comm: fswebcam Not tainted 4.4.19-v7+ #906
Sep 19 10:30:01 raspberrypi kernel: [314017.974977] Hardware name: BCM2709
Sep 19 10:30:01 raspberrypi kernel: [314017.975012] [<80018784>] (unwind_backtrace) from [<80014058>] (show_stack+0x20/0x24)
Sep 19 10:30:01 raspberrypi kernel: [314017.975031] [<80014058>] (show_stack) from [<80320c84>] (dump_stack+0xd4/0x118)
Sep 19 10:30:01 raspberrypi kernel: [314017.975053] [<80320c84>] (dump_stack) from [<80025360>] (warn_slowpath_common+0x98/0xc8)
Sep 19 10:30:01 raspberrypi kernel: [314017.975071] [<80025360>] (warn_slowpath_common) from [<800253d0>] (warn_slowpath_fmt+0x40/0x48)
Sep 19 10:30:01 raspberrypi kernel: [314017.975088] [<800253d0>] (warn_slowpath_fmt) from [<801cdc10>] (sysfs_remove_group+0xa0/0xa4)
Sep 19 10:30:01 raspberrypi kernel: [314017.975108] [<801cdc10>] (sysfs_remove_group) from [<803afbc0>] (dpm_sysfs_remove+0x5c/0x60)
Sep 19 10:30:01 raspberrypi kernel: [314017.975128] [<803afbc0>] (dpm_sysfs_remove) from [<803a51b0>] (device_del+0x48/0x220)
Sep 19 10:30:01 raspberrypi kernel: [314017.975153] [<803a51b0>] (device_del) from [<7f4171cc>] (evdev_disconnect+0x28/0x50 [evdev])
Sep 19 10:30:01 raspberrypi kernel: [314017.975209] [<7f4171cc>] (evdev_disconnect [evdev]) from [<804506d4>] (__input_unregister_device+0xc4/0x164)
Sep 19 10:30:01 raspberrypi kernel: [314017.975227] [<804506d4>] (__input_unregister_device) from [<80450ffc>] (input_unregister_device+0x58/0x80)
Sep 19 10:30:01 raspberrypi kernel: [314017.975266] [<80450ffc>] (input_unregister_device) from [<7f40852c>] (uvc_status_cleanup+0x40/0x44 [uvcvideo])
Sep 19 10:30:01 raspberrypi kernel: [314017.975302] [<7f40852c>] (uvc_status_cleanup [uvcvideo]) from [<7f3fe31c>] (uvc_delete+0x1c/0x138 [uvcvideo])
Sep 19 10:30:01 raspberrypi kernel: [314017.975332] [<7f3fe31c>] (uvc_delete [uvcvideo]) from [<7f3fe570>] (uvc_release+0x4c/0x50 [uvcvideo])
Sep 19 10:30:01 raspberrypi kernel: [314017.975390] [<7f3fe570>] (uvc_release [uvcvideo]) from [<7f35d800>] (v4l2_device_release+0xcc/0xf0 [videodev])
Sep 19 10:30:01 raspberrypi kernel: [314017.975425] [<7f35d800>] (v4l2_device_release [videodev]) from [<803a48a4>] (device_release+0x3c/0xa0)
Sep 19 10:30:01 raspberrypi kernel: [314017.975443] [<803a48a4>] (device_release) from [<80322ec0>] (kobject_release+0x50/0x84)
Sep 19 10:30:01 raspberrypi kernel: [314017.975461] [<80322ec0>] (kobject_release) from [<80322f48>] (kobject_put+0x54/0x80)
Sep 19 10:30:01 raspberrypi kernel: [314017.975477] [<80322f48>] (kobject_put) from [<803a4c4c>] (put_device+0x24/0x28)
Sep 19 10:30:01 raspberrypi kernel: [314017.975505] [<803a4c4c>] (put_device) from [<7f35d518>] (v4l2_release+0x60/0x84 [videodev])
Sep 19 10:30:01 raspberrypi kernel: [314017.975537] [<7f35d518>] (v4l2_release [videodev]) from [<80158fc8>] (__fput+0x94/0x1e4)
Sep 19 10:30:01 raspberrypi kernel: [314017.975557] [<80158fc8>] (__fput) from [<80159188>] (____fput+0x18/0x1c)
Sep 19 10:30:01 raspberrypi kernel: [314017.975578] [<80159188>] (____fput) from [<800409dc>] (task_work_run+0xa0/0xd4)
Sep 19 10:30:01 raspberrypi kernel: [314017.975613] [<800409dc>] (task_work_run) from [<80013914>] (do_work_pending+0xcc/0xd0)
Sep 19 10:30:01 raspberrypi kernel: [314017.975645] [<80013914>] (do_work_pending) from [<8000fb68>] (slow_work_pending+0xc/0x20)
Sep 19 10:30:01 raspberrypi kernel: [314017.975656] ---[ end trace 7180a93b6f0e3115 ]---