class TPCANTimestamp (Structure):
"""
Represents a timestamp of a received PCAN message
Total Microseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
"""
_fields_ = [ ("millis", c_uint), # Base-value: milliseconds: 0.. 2^32-1
("millis_overflow", c_ushort), # Roll-arounds of millis
("micros", c_ushort) ]
如何使用TPCANTimestamp
类中的字段?
答案 0 :(得分:0)
如何使用 TPCANTimestamp类中的字段?
将它们用作Structure
的属性:
from ctypes import *
class TPCANTimestamp(Structure):
"""
Represents a timestamp of a received PCAN message
Total Microseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
"""
_fields_ = [ ("millis", c_uint), # Base-value: milliseconds: 0.. 2^32-1
("millis_overflow", c_ushort), # Roll-arounds of millis
("micros", c_ushort)]
t = TPCANTimestamp(100, 20, 30)
print(t.millis, t.micros)
输出:
100 30