Hey there ! This is a great tool.
Ive found that ALLWAYS leaves behind 1 record when calling getAttendance(). That is because last record in first commented line at last while loop len() is 38. Ive solved that by duplicating some code for last record and changing H80 to H60.
Im using x628c for time attendance.
$u = unpack( 'H80', substr( $attendancedata, 0, 40 ) );
//24s1s4s11s
//print_r($u);
$uid = hex2bin( substr( $u[1], 0, 24 ) );
$uid = explode(chr(0), $uid);
$uid = intval( $uid[0] );
$state = hexdec( substr( $u[1], 48, 2 ) );
$timestamp = decode_time( hexdec( reverseHex( substr($u[1], 50, 8) ) ) );
# Clean up some messy characters from the user name
#uid = unicode(uid.strip('\x00|\x01\x10x'), errors='ignore')
#uid = uid.split('\x00', 1)[0]
#print "%s, %s, %s" % (uid, state, decode_time( int( reverseHex( timestamp.encode('hex') ), 16 ) ) )
array_push( $attendance, array( $uid, $state, $timestamp ) );
$attendancedata = substr( $attendancedata, 40 );
//echo "at: '$attendancedata'".strlen($attendancedata)."<br/>";
}
$u = unpack( 'H60', $attendancedata);
//24s1s4s11s
//print_r($u);
$uid = hex2bin( substr( $u[1], 0, 24 ) );
$uid = explode(chr(0), $uid);
$uid = intval( $uid[0] );
$state = hexdec( substr( $u[1], 48, 2 ) );
$timestamp = decode_time( hexdec( reverseHex( substr($u[1], 50, 8) ) ) );
# Clean up some messy characters from the user name
#uid = unicode(uid.strip('\x00|\x01\x10x'), errors='ignore')
#uid = uid.split('\x00', 1)[0]
#print "%s, %s, %s" % (uid, state, decode_time( int( reverseHex( timestamp.encode('hex') ), 16 ) ) )
array_push( $attendance, array( $uid, $state, $timestamp ) );