Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Attendance Data #23

Open
tahseenafzal opened this issue Jun 4, 2020 · 9 comments
Open

Getting Attendance Data #23

tahseenafzal opened this issue Jun 4, 2020 · 9 comments

Comments

@tahseenafzal
Copy link

When I get data using getAttendance() function and console log it:

showing result:

[Object Object], [Object Object]

how to read it

@caobo171
Copy link
Owner

can you show your code, when I use getAttendances() , it will return attendances object with data and error (if it has )

@pierrejoye
Copy link

pierrejoye commented Oct 6, 2020

Hi :)

Thanks for this great package!

Trying out and also have an issue with that method (all other is fine, some small things about string data, will do PRs :)

However with that method (getAttendances), using the sample code (smallest repro :)

const logs = await zkInstance.getAttendances((percent, total)=>{ // this callbacks take params is the percent of data downloaded and total data need to download console.log(percent) console.log(total) }).catch((o)=> {console.log(o)}) console.log(logs)

all I can get back:

ZKError { err: Error: TIMEOUT_ON_RECEIVING_REQUEST_DATA at Timeout._onTimeout (/home/pierre/zklib/node_modules/node-zklib/zklibtcp.js:133:20) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7), ip: '169.254.202.38', command: '[TCP] undefined' }
before I go back debug, I was wondering if that rings a bell to you?

using:
platform: 'ZLM60_TFT',
version: '10'

It is called 'THAI01' here, but it is surely the same model everywhere only with localization,

Best,

@pierrejoye
Copy link

Ah and this comes too (only when calling getAttendances)

``

(node:11608) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'subarray' of null

at /home/pierre/zklib/node_modules/node-zklib/zklibtcp.js:234:44

at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)

at processPromiseRejections (internal/process/promises.js:247:11)

at processTicksAndRejections (internal/process/task_queues.js:94:32)

(node:11608) TypeError: Cannot read property 'subarray' of null
at /home/pierre/zklib/node_modules/node-zklib/zklibtcp.js:234:44

(node:11608) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections
that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)

at processPromiseRejections (internal/process/promises.js:249:13)

at processTicksAndRejections (internal/process/task_queues.js:94:32

``

@pierrejoye
Copy link

Also (was trying it before)

https://github.com/vodvud/php_zklib/blob/master/zklib/src/Attendance.php works.

So I suppose some part about the size of the data is not correct ending up with waiting for too much data.

@pierrejoye
Copy link

I confirm it is the parsing of the incoming data being wrong.

I am not that quick with JS as I am with C or other, but I will try to debug.

Also most recent devices provide a status field, which defines what kind of clock in/out was done. The full data from the attendance log looks like (json for the example):
{
"uid": 26,
"user_id": "1",
"timestamp": 1602042126.0,
"status": 1,
"punch": 0
}

I will try this week to provide a standalone script using executecommand with a new parser (at least for the data stream)

@pierrejoye
Copy link

ok.

Case 1:
Empty Attendance produces:

ZKError {
  err: Error: TIMEOUT_ON_RECEIVING_REQUEST_DATA
      at Timeout._onTimeout (/home/pierre/projects/pos/node-zklib/node_modules/node-zklib/zklibtcp.js:133:20)
      at listOnTimeout (internal/timers.js:554:17)
      at processTimers (internal/timers.js:497:7),
  ip: '169.254.202.38',
  command: '[TCP] undefined'
}

@pierrejoye
Copy link

The 2nd error, will update once figured out what causes it (it appears whether the attendance is empty or not)

@pierrejoye
Copy link

For the empty log error:

WIthout the TCP Header, the data is:

{
"0": 80,
"1": 80,
"2": 130,
"3": 125,
"4": 8,
"5": 0,
"6": 0,
"7": 0,
"8": 125,
"9": 19,
"10": 95,
"11": 32,
"12": 30,
"13": 204,
"14": 5,
"15": 0,
}

in zklibtcp.js:132

if(header.commandId === COMMANDS.CMD_DATA){

fails, heading to the false clause on line 136:

      const packetLength = data.readUIntLE(4, 2)
      if (packetLength > 8) {

as the packetLength == 8, timeout is not renew, catching the timeout catch and error out.

the header.commandId is: 4989

@WalterPrz
Copy link

I need help, getAttendances() only get a few data, but i need all history data, ¿how can i do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants