[vdr] VDR continuously initializing CAM

Klaus Schmidinger Klaus.Schmidinger at cadsoft.de
Tue Apr 8 17:51:07 CEST 2008


On 04/08/08 10:25, Tuomas Jormola wrote:
> Hi,
> 
> I forgot to post this earlier, but in the attachment you'll find logs of 
> this issue on my system. I modified the code like this:
> 
> eModuleStatus cCamSlot::ModuleStatus(void)
> {
>   cMutexLock MutexLock(&mutex);
>   eModuleStatus ms = ciAdapter ? ciAdapter->ModuleStatus(slotIndex) : 
> msNone;
>   isyslog("CAM DEBUG: ms: %d resetTime: %d", ms, resetTime);
>   if (resetTime) {
>      if (ms <= msReset) {
>         isyslog("CAM DEBUG: ms le msReset");
>         if (time(NULL) - resetTime < MODULE_RESET_TIMEOUT) {
>            isyslog("CAM DEBUG: return msReset");
>            return msReset;
>         }
>      }
>      isyslog("CAM DEBUG: resetTime zero");
>      resetTime = 0;
>   }
>   return ms;
> }
> 
> btw. it looks like a bug crept into Arthur's code below. After
> if (time(NULL) - resetTime < MODULE_RESET_TIMEOUT)
> if this if expression evaluates true, only the debug message is printed, 
> and return msReset is executed always due to missing brackets. 

While you are right about this, I don't think that it even got there,
because resetTime was actually 0 when the switch from 3 ("ready") to
2 ("present") occurred:

Apr  7 09:06:41 vdr vdr: [4862] ms: 3
Apr  7 09:06:41 vdr vdr: [4862] resetTime1: 0
Apr  7 09:06:41 vdr vdr: [4862] ms: 2

> Intendation of the closing brackets of the if blocks in the original 
> piece of code seem to be incorrect, which makes it difficult to spot 
> things like this.

Closing brackets are of course indented, since they are part of
the block. But I guess this is a philosophical argument, so let's not
get into this ;-)

Klaus

> Tuomas Jormola
> 
> On 7 Apr 2008, at 19:12, Klaus Schmidinger wrote:
>> On 04/07/08 08:34, Arthur Konovalov wrote:
>>> Well,
>>> I'm not big guru of debugging.
>>> I made following changes to mentioned part of code:
>>>
>>> eModuleStatus cCamSlot::ModuleStatus(void)
>>> {
>>>  cMutexLock MutexLock(&mutex);
>>>  eModuleStatus ms = ciAdapter ? ciAdapter->ModuleStatus(slotIndex) :
>>> msNone;
>>>  isyslog("ms: %d", ms); //AKO
>>>  isyslog("resetTime1: %d", resetTime); //AK
>>>  if (resetTime) {
>>>  isyslog("resetTime2: %d", resetTime); //AK
>>>     if (ms <= msReset) {
>>>  isyslog("resetTime3: %d", resetTime); //AK
>>>        if (time(NULL) - resetTime < MODULE_RESET_TIMEOUT)
>>>  isyslog("resetTime4: %d", resetTime); //AK
>>>           return msReset;
>>>        }
>>>     resetTime = 0;
>>>     }
>>>  return ms;
>>> }
>>>
>>> Log file attached. I suspect that additional instructions are welcome.
>>
>> At this point...
>>
>>> Apr  7 09:06:41 vdr vdr: [4862] ms: 3
>>> Apr  7 09:06:41 vdr vdr: [4862] resetTime1: 0
>>> Apr  7 09:06:41 vdr vdr: [4862] ms: 2
>>
>> ...the module status changed from 3 ("ready") to 2 ("present").
>> The module status is retrieved from the driver in 
>> cDvbCiAdapter::ModuleStatus():
>>
>> eModuleStatus cDvbCiAdapter::ModuleStatus(int Slot)
>> {
>>   ca_slot_info_t sinfo;
>>   sinfo.num = Slot;
>>   if (ioctl(fd, CA_GET_SLOT_INFO, &sinfo) != -1) {
>>      if ((sinfo.flags & CA_CI_MODULE_READY) != 0)
>>         return msReady;
>>      else if ((sinfo.flags & CA_CI_MODULE_PRESENT) != 0)
>>         return msPresent;
>>      }
>>   else
>>      esyslog("ERROR: can't get info of CAM slot %d on device %d: %m", 
>> Slot, device->DeviceNumber());
>>   return msNone;
>> }
>>
>> So for some reason the sinfo.flags doesn't seem to have the 
>> CA_CI_MODULE_READY
>> flag set any longer.
>>
>>
>> Klaus



More information about the vdr mailing list