You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The result should be around 0 but it is around 3600 which drive me directly to timezone, which is at my PC: time.timezone = -3600.
However I can not find any information about configuring timezones for CAN, and I believe it should not be possible to do it.
Therefore here is my question. Is python-can wrong here or I miss something?
uptime.boottime() takes the timezone into account but datetime.utcfromtimestamp() obviously does not. This creates a spurious timedelta equal to the timezone. datetime.fromtimestamp() should be used instead.
uptime.boottime() takes the timezone into account but datetime.utcfromtimestamp() obviously does not. This creates a spurious timedelta equal to the timezone. datetime.fromtimestamp() should be used instead.
OSError: [Errno 22] Invalid argument is generally related to file access, typically trying to open incorrectly formatted paths. Please post a small piece of sample code which reproduces the issue. For example, does the following generate the same error?
OSError: [Errno 22] Invalid argument is generally related to file access, typically trying to open incorrectly formatted paths. Please post a small piece of sample code which reproduces the issue. For example, does the following generate the same error?
importcanbus=can.Bus(interface="pcan")
I just use a small piece of code.
import can
bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000)
And the error is still reported as occurring at uptime.boottime() - datetime.datetime.fromtimestamp(0)? If so, does simply running uptime.boottime() or datetime.datetime.fromtimestamp(0) individually cause an error?
import datetime
datetime.datetime.fromtimestamp(0)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in
datetime.datetime.fromtimestamp(0)
OSError: [Errno 22] Invalid argument
I find two library 'datetime' in my python37.One path is 'D:\Python37\Lib\datetime.py',Another path is 'D:\Python37\Lib\site-packages\future\backports\datetime.py'.
I find the function as follow:
1、 @classmethod
def fromtimestamp(cls, t, tz=None):
"""Construct a datetime from a POSIX timestamp (like time.time()).
A timezone info object may be passed in as well.
"""
_check_tzinfo_arg(tz)
return cls._fromtimestamp(t, tz is not None, tz)
2、 @classmethod
def fromtimestamp(cls, t, tz=None):
"""Construct a datetime from a POSIX timestamp (like time.time()).
A timezone info object may be passed in as well.
"""
_check_tzinfo_arg(tz)
converter = _time.localtime if tz is None else _time.gmtime
t, frac = divmod(t, 1.0)
us = int(frac * 1e6)
# If timestamp is less than one microsecond smaller than a
# full second, us can be rounded up to 1000000. In this case,
# roll over to seconds, otherwise, ValueError is raised
# by the constructor.
if us == 1000000:
t += 1
us = 0
y, m, d, hh, mm, ss, weekday, jday, dst = converter(t)
ss = min(ss, 59) # clamp out leap seconds if the platform has them
result = cls(y, m, d, hh, mm, ss, us, tz)
if tz is not None:
result = tz.fromutc(result)
return result
I do not knonw to which one of name 'datetime' lib
It should be fixed already, according to the tracker. Are you using the latest version of Python3.7? Regardless, since the issue is unrelated to python-can I suggest we close this again.
Activity
bessman commentedon Feb 24, 2020
This looks like a bug in pcan:
python-can/can/interfaces/pcan/pcan.py
Lines 19 to 21 in cb138c0
uptime.boottime()takes the timezone into account butdatetime.utcfromtimestamp()obviously does not. This creates a spurious timedelta equal to the timezone.datetime.fromtimestamp()should be used instead.tiger86023086 commentedon Apr 27, 2021
I use the script
but there is error. The error is:
Is there is error or Am i use it in wrong?
bessman commentedon Apr 27, 2021
OSError: [Errno 22] Invalid argumentis generally related to file access, typically trying to open incorrectly formatted paths. Please post a small piece of sample code which reproduces the issue. For example, does the following generate the same error?tiger86023086 commentedon Apr 29, 2021
I just use a small piece of code.
import can
bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000)
The code will genenrate error 22
bessman commentedon Apr 29, 2021
And the error is still reported as occurring at
uptime.boottime() - datetime.datetime.fromtimestamp(0)? If so, does simply runninguptime.boottime()ordatetime.datetime.fromtimestamp(0)individually cause an error?tiger86023086 commentedon Apr 29, 2021
Now my python version is python37(64).
I find two library 'datetime' in my python37.One path is 'D:\Python37\Lib\datetime.py',Another path is 'D:\Python37\Lib\site-packages\future\backports\datetime.py'.
I find the function as follow:
1、
@classmethod
def fromtimestamp(cls, t, tz=None):
"""Construct a datetime from a POSIX timestamp (like time.time()).
2、
@classmethod
def fromtimestamp(cls, t, tz=None):
"""Construct a datetime from a POSIX timestamp (like time.time()).
I do not knonw to which one of name 'datetime' lib
bessman commentedon Apr 30, 2021
You are using the first one. The second would need to be imported as
from future.backports import datetime.Your issue is not a bug in python-can, but rather in Python itself: https://bugs.python.org/issue29097
It should be fixed already, according to the tracker. Are you using the latest version of Python3.7? Regardless, since the issue is unrelated to python-can I suggest we close this again.
felixdivo commentedon Apr 30, 2021
@bessman Thanks for assisting! Indeed, it seems like there's nothing to be fixed by us here.