Motion - Support Question 2007x 11x 23x 201806

Motion functions properly for a few minutes and then stops logging motion detection

Question

I have a Logitech 820 Clicksmart webcam, I am using the gvcaps driver.

"motion" logs images and movies to the local directory for a few minutes, and then all logging stops. No more images are logged, the movie size does not increase, when for example I move my hand in front of the camera in attempt to trigger motion detection.

For my configuration file, I made a copy of the config file auto-generated, or provided on install, located in /etc/motion.conf, naming the copy "myconfig".

At the top it had the comment

-------------------------------------------------------------
# /etc/motion.conf
#
# This config file was generated by motion 3.2.8

I made the following changes:

  • framerate chagned from 2 to 15
  • pre_capture changed from 0 to 5
  • post_capture changed from 0 to 5
  • gap changed from 60 to 0
  • target_dir changed from "/usr/local/apache2/htdocs/cam1" to commented out, so that it defaults to the current directory
  • webcam_port changed from 8081 to 0, to disable
  • control_port changed from 8080 to 0, to disable
  • sql_log_image changed from on to off
  • sql_log_snapshot changed from on to off

I ran motion using the command motion -d 9 -c myconfig

The output started as:


-----------------------------
[0] Processing thread 0 - config file motionconf
[0] Thread 1 is from motionconf
[1] Thread started
[1] Not a V4L2 device?
[1] Using VIDEO_PALETTE_YUV420P palette
[1] Using V4L1
[1] File of type 8 saved to: ./01-20071123153123.avi
[1] File of type 1 saved to: ./01-20071123153122-11.jpg
[1] File of type 1 saved to: ./01-20071123153122-12.jpg
[1] File of type 1 saved to: ./01-20071123153122-13.jpg
...

In this case, it stopped logging images and video after about 10 seconds.

Sometimes it seems that lack of motion for a long time causes it to stop logging, and other times it seems that too much causes it, for example, if I pick the camera up and move it.

Environment

Motion version: 3.2.8
ffmpeg version: 0.4.9pre1
Libraries: unkown
Server OS: 2.6.22.9 Mandriva desktop system

-- MichaelOverlin - 23 Nov 2007

Answer

Your config is a bit odd.

Running with gap 0 is normally not adviced. It means that many features related to events do not work at all.

Read up on the ConfigOptionGap

But besides this - does Motion write anything in the syslog? Normally /var/log/messages.

The command dmesg can give some hints if it is a camera problem.

A 3.2.9 was just released fixing some seg faults. Perhaps you should try that.

-- KennethLavrsen - 24 Nov 2007

Reply (MichaelOverlin)

I changed "gap" to the default value of 60, this made no difference.

I looked in the /var/log/messages, relevant messages seem to be:

ov 23 20:18:13 localhost motion: [0] Processing thread 0 - config file motionconf
Nov 23 20:18:13 localhost motion: [0] Thread 1 is from motionconf
Nov 23 20:18:13 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/Sunplus-jpeg/sp5xxfw2.h: [spca50x_GetFirmware:662] FirmWare : 2 0 0 5 4
Nov 23 20:18:13 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/gspca_core.c: [spca5xx_set_light_freq:1889] Sensor currently not support light frequency banding filters.
Nov 23 20:18:13 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/gspca_core.c: [gspca_set_isoc_ep:903] ISO EndPoint found 0x81 AlternateSet 7
Nov 23 20:18:14 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/Sunplus-jpeg/sp5xxfw2.h: [spca50x_GetFirmware:662] FirmWare : 2 0 0 5 4
Nov 23 20:18:16 localhost motion: [1] Not a V4L2 device?
Nov 23 20:20:02 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/gspca_core.c: [spca50x_isoc_irq:1110] Non-zero status (-84) in isoc completion handler.
Nov 23 20:24:13 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/gspca_core.c: [spca50x_isoc_irq:1110] Non-zero status (-84) in isoc completion handler.
Nov 23 20:25:27 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/gspca_core.c: [spca50x_isoc_irq:1110] Non-zero status (-84) in isoc completion handler.
Nov 23 20:25:28 localhost kernel: /var/lib/dkms/gspca/1.00.18-3mdv2008.0/build/gspca_core.c: [spca50x_isoc_irq:1110] Non-zero status (-18) in isoc completion handler.

The -84 and -18 errors might indicate a problem with the driver. Looking around on the internet a bit, I found that some suggest changing a costant in the gspca driver source file "gspca.h", FRAMES_PER_DESC , from 16 to 128. If I try this I'll let you know if it fixed the problem.

Thanks.

-- MichaelOverlin

Reply (MichaelOverlin)

Quite a few people seem to have this problem with the gspca driver. I found a solution that works for me. I made a few tiny changes to the driver that make it just ignore these -84, -18 etc. errors at these locations in the code, and I also increased the constant FRAMES_PER_DESC from 16 to 64.

With these changes my Logitech Clicksmart 820 works reliably for about two hours, and then it fails with a message (in /var/log/messages)

localhost kernel: usb 2-1: reset full speed USB device
using uhci_hcd and address 2

I work around this by writing a little perl-script that runs "motion" one hour at a time.

Here is my perl script

$motionCommand = "motion -c motionconf";
# RUN ONE HOUR AT A TIME
$motionTime = 3600; 

my $k = 0;
for(;;) {
    $k ++;
    print "DoMotion count $k \n";
    my $pid = DoMotion();
    sleep $motionTime;
    kill 9, $pid;
}

sub DoMotion {
    my $pid;
    if (!defined($pid = fork)) {
        print "fork failed\n";
        exit;
    } elsif ($pid) {
        print  "begat $pid \n";
        return $pid;
    }
    exec $motionCommand;
}

The hack I made to the gspca driver:

VERSION gspcav1-20070508

***** IN FILE "gspca_core.c" *****
** IN FUNCTION  "spca50x_isoc_irq" ABOUT LINE 1110
CHANGE SWITCH BLOCK FROM 
   switch (urb->status) {
   case 0:
      break;
   default:
      PDEBUG(0, "Non-zero status (%d) in isoc "
             "completion handler.", urb->status);
   case -ENOENT:      /* usb_kill_urb() called. */
   case -ECONNRESET:   /* usb_unlink_urb() called. */
   case -ESHUTDOWN:   /* The endpoint is being disabled. */
      return;
   }
TO
   switch (urb->status) {
   case 0:
      break;
   default:
      PDEBUG(0, "Ignoring non-zero status (%d) in isoc "
             "completion handler.", urb->status);
      break;
   case -ENOENT:      /* usb_kill_urb() called. */
   case -ECONNRESET:   /* usb_unlink_urb() called. */
   case -ESHUTDOWN:   /* The endpoint is being disabled. */
      PDEBUG(0, "Non-zero status (%d) in isoc "
             "completion handler.", urb->status);
      return;
   }
** IN FUNCTION "spca50x_move_data" ABOUT LINE 1565
WITHIN THE FIRST "for" LOOP THAT READ  "for (i = 0; i < urb->number_of_packets; i++) {"
CHANGE AN ERROR-CHECKING IF STATEMENT BLOCK FROM
      if (st) {
         PDEBUG(0, "ISOC data error: [%d] len=%d, status=%d \n",
                i, datalength, st);
         continue;
      }
TO
      if (st) {
         st = urb->iso_frame_desc[i].status = 0;
      }


***** IN FILE "gspca.h" *****
** CONSTANT "FRAMES_PER_DESC" ABOUT LINE 28
CHANGE FROM 
#define FRAMES_PER_DESC      16 /* Default value, should be reasonable */
TO 
#define FRAMES_PER_DESC      64 /* Default value, should be reasonable */

-- MichaelOverlin

Lets see if driver's authour can help you, that is out of motion scope.

-- AngelCarpintero - 06 Jan 2008

SupportForm edit

TopicTitle Motion functions properly for a few minutes and then stops logging motion detection
SupportStatus ClosedUnanswered
AssignedQuestionTo
SubmittedBy MichaelOverlin
Topic revision: r5 - 06 Jan 2008, AngelCarpintero
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.