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

readProperty - "Invalid Date" for property 130 (event-time-stamps) #175

Closed
1 of 3 tasks
cdriks opened this issue Sep 29, 2022 · 1 comment
Closed
1 of 3 tasks

readProperty - "Invalid Date" for property 130 (event-time-stamps) #175

cdriks opened this issue Sep 29, 2022 · 1 comment

Comments

@cdriks
Copy link

cdriks commented Sep 29, 2022

Node Version: 0.0.1-beta.14

Node BACstack Version: 18.9.0

  • Bug Report
  • Feature Request
  • Question

Current Behaviour (Bug Report)

Hi,

by performing a readProperty to property 130 (event-time-stamps), the returned value is seen as "Invalid Date".

Steps to reproduce Issue (Bug Report)

const bacstack = require('bacstack');

const client = new bacstack()

client.readProperty('10.12.44.11', { type: 2, instance: 8194 }, 130, (err, value) => {
    console.log(err)
    console.log(JSON.stringify(value.values))
    console.log(value.values)
})

returns :

[
  { type: 104, value: Invalid Date },
  { type: 104, value: Invalid Date },
  { type: 104, value: Invalid Date }
]

The cause from this can be found at asn1.js, line 1000.

The date variable has the following value : {"len":5,"value":{"len":4,"value":"2022-10-26T22:00:00.000Z"}}, and the time : {"len":5,"value":{"len":4,"value":"1901-02-01T15:26:22.600Z"}}

Suggested correction

The bug can be corrected, in changing for example :

asn1.js, line 1000

new Date(...) into :

  value: new Date(date.value.value.getFullYear(), date.value.value.getMonth() -1 , date.value.value.getDate(), time.value.value.getHours(), time.value.value.getMinutes(), time.value.value.getSeconds(), time.value.value.getMilliseconds())};

Then, the result of the above-mentioned command is :

[
  { type: 104, value: 2022-09-27T14:26:22.600Z },
  { type: 104, value: 1900-12-31T23:00:00.000Z },
  { type: 104, value: 2022-09-27T15:34:59.800Z }
]

There, the second item of the array is not completely correct (it should be unspecified), but it makes the job...

Thanks in advance,

Cédric

@cdriks
Copy link
Author

cdriks commented Nov 3, 2022

PR made : #178

@cdriks cdriks closed this as completed Nov 3, 2022
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

1 participant