hardbyte / hardbyte/python-can

Timestamp when message is transmitted

Đang mở
#2,029 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
1.6k
Fork
697
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Is your feature request related to a problem? Please describe.
I would like to measure the time it takes for a CAN node to respond to a given message.
_Received_ messages have their timestamp correctly set, however there is no direct way to get the timestamp when a message is _transmitted_.

As a workaround, I'm using the timestamp when I call bus.send, however this is not necessarily the time when the message is actually transmitted on the bus (up to 30 ms difference).
The timings I'm measuring with this workaround do not match the timings I'm directly recording in the PCAN software.

### Describe the solution you'd like
Ideally, the bus.send implementation would override the .timestamp property of the message object I called it with.
By default, the timestamp is 0.0 on newly constructed messages. Calling bus.sent does not immediately cause a transmission but only puts the message into the transmit buffer of the can device. For best results, the can driver implementation should set the correct timestamp once message was actually sent.
```py
msg = can.Message(...)
print(msg.timestamp) # 0.0 - default
bus.send(msg)
print(msg.timestamp) # 0.0 - message given to can device but not physically sent yet
time.sleep(0.5)
print(msg.timestamp) # 1773217081.775475 - can driver sets timestamp property once message was actually transmitted
```

### Describe alternatives you've considered
I have considered setting up a virtual can or configuring some loopback setup, such that i can use the receive timestamps for both received & transmitted messages. However this seems rather complicated for a seemingly simple task.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.