hardbyte / hardbyte/python-can

Kvaser Shutdown Error With Multiple Tasks

Đang mở
#899 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
backend:kvaser question
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ả

I observed (on python-can 3.3.3 / Python 3.7.0) that with multiple periodic tasks, when calling the shutdown() function for a kvaser interface, the following error message is shown, maybe :
```
RESTART: testfile.py
Message sent on Kvaser Memorator, S/N XXXX (#1)
>>> Function canWrite failed - Handle is invalid
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\can\broadcastmanager.py", line 136, in _run
self.bus.send(self.message)
File "C:\Program Files\Python37\lib\site-packages\can\interfaces\kvaser\canlib.py", line 555, in send
flags)
File "C:\Program Files\Python37\lib\site-packages\can\interfaces\kvaser\canlib.py", line 99, in __check_status
raise CANLIBError(function, result, arguments)
can.interfaces.kvaser.canlib.CANLIBError: Function canWrite failed - Handle is invalid
```
Does anyone have any idea?

Code for issue reproduction:
(with only one task, there is no error message)
```
import can
import time

from can.bus import BusABC

def send_periodic(bus_a):

msg1 = can.Message(arbitration_id=0x444,
data=[0, 25, 0, 1, 3, 1, 4, 1],
is_extended_id=False)

msg2 = can.Message(arbitration_id=0x454,
data=[1, 26, 1, 2, 4, 2, 5, 2],
is_extended_id=False)

msg3 = can.Message(arbitration_id=0x464,
data=[2, 27, 2, 3, 5, 3, 6, 3],
is_extended_id=False)

try:
#task1 = bus_a.send_periodic(msg1, 0.3)
task2 = bus_a.send_periodic(msg2, 0.5)
task3 = bus_a.send_periodic(msg3, 1.0)
if not isinstance(task1, can.ModifiableCyclicTaskABC):
print("This interface doesn't seem to support modification")
task1.stop()
return
counter=0
while counter<10:
msg2.data[0] = msg2.data[0] + 1
task2.modify_data(msg2)
time.sleep(1)
counter+=1
print("Message sent on {}".format(bus.channel_info))
except can.CanError:
print("Message NOT sent")

if __name__ == '__main__':
counter=0
bus = can.interface.Bus(bustype='kvaser', channel=0, bitrate=250000)
send_periodic(bus)
time.sleep(10)
bus.stop_all_periodic_tasks()
bus.shutdown()
```

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.