I've several i2c devices in my Rpi setup working together with pipicpowerd and sometimes i get error in syslog: " Failed to lock i2c port" from pipicpowerd.
I think problem is in this part of code (writecmd.c, readdata.c):
rd=flock(fd, LOCK_EX|LOCK_NB);
cnt=i2lockmax;
while((rd==1)&&(cnt>0)) // try again if port locking failed
{
sleep(1);
rd=flock(fd, LOCK_EX|LOCK_NB);
cnt--;
}
if(rd)
{
syslog(LOG_ERR, "Failed to lock i2c port");
close(fd);
return -2;
}
flock can never return 1, it returns 0 on success and -1 in case of problem, so this while loops ends after 1st failed flock, cnt is never used. while should be:
while((rd==-1)&&(cnt>0)) // try again if port locking failed
{
sleep(1);
rd=flock(fd, LOCK_EX|LOCK_NB);
cnt--;
}
Hi,
I've several i2c devices in my Rpi setup working together with pipicpowerd and sometimes i get error in syslog: " Failed to lock i2c port" from pipicpowerd.
I think problem is in this part of code (writecmd.c, readdata.c):
rd=flock(fd, LOCK_EX|LOCK_NB);
}
flock can never return 1, it returns 0 on success and -1 in case of problem, so this while loops ends after 1st failed flock, cnt is never used. while should be:
while((rd==-1)&&(cnt>0)) // try again if port locking failed { sleep(1); rd=flock(fd, LOCK_EX|LOCK_NB); cnt--; }
/Mladen