-
Notifications
You must be signed in to change notification settings - Fork 54
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
MessageListener No Longer Works With Latest Python-Can Listener #78
Comments
Does |
I can take a look, but I can't say I've noticed anything unusual where I've used it. Maybe @khauersp can comment on this as well. Is there anywhere you're calling stop from? It only stops notifying if stop() was called on the message listener. |
This works good import can
bus = can.Bus(interface="canalystii", channel="0", bitrate=250000)
while True:
try:
msg = bus.recv(1)
print(msg)
except KeyboardInterrupt:
break
bus.shutdown()
But this doesn't output anything from time import sleep
import j1939
def on_message(priority, pgn, sa, timestamp, data):
print(f"PGN {pgn} length {len(data)}")
ecu = j1939.ElectronicControlUnit()
ecu.connect(interface="canalystii", channel="0", bitrate=250000)
ecu.subscribe(on_message)
while True:
try:
sleep(1)
except KeyboardInterrupt:
break
print("Deinitializing")
ecu.disconnect() |
I'm not quite sure the issues you are having. I did your example and am seeing traffic from the bus: import j1939
import time
def on_message(priority, pgn, sa, timestamp, data):
print(f"PGN {pgn} length {len(data)}")
def main():
ecu = j1939.ElectronicControlUnit()
ecu.connect(interface="vector", channel="0", bitrate=250000)
ecu.subscribe(on_message)
while True:
try:
time.sleep(0.5)
except KeyboardInterrupt:
break
print("Deinitializing")
ecu.disconnect()
if __name__ == "__main__":
main()
|
I needed to add the address to my subscription to get the same result. ecu.subscribe(on_message, 0x56) Looks like my fault, sorry for misunderstanding |
No worries :) |
By the way, should this work without the address being declared? I have a problem where I only need to read CAN traffic without interfering, but subscribing with an address causes my CAN analyzer to interfere with the bus. |
I don't think this issue you're having is directly related to this issue about the listener, but not entirely sure on that. It looks like the subscribe method should potentially support subscribing without a destination address. One thing I noticed between the two examples you had linked @kossnikita and one thing to keep in mind is the can.Bus method to make the bus may not entirely be the same as the way the ecu.connect() works. It probably should be but they do call different functions in the code. |
Looks like Python-Can had a recent update to add a new abstract method stop
The text was updated successfully, but these errors were encountered: