hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.26k stars 599 forks source link

Use can.logger only log received msg to file, but send msg can not logged #1222

Open hongjojjay opened 2 years ago

hongjojjay commented 2 years ago

Describe the bug

I use this below code, only received msg can save to hello.asc file, but send msg can not be saved. How to save the send msg? tmplogger = can.Logger("hello.asc") self.bus.add_listener(tmplogger )

To Reproduce

None

Expected behavior

None

Additional context

OS and version: win10 Python version: 3.7.7 python-can version: 37.0.1 python-can interface/s (if applicable): pcan

zariiii9003 commented 2 years ago

Most interfaces support the receive_own_messages keyword for that.

felixdivo commented 2 years ago

However, pcan does not seem to have that: https://python-can.readthedocs.io/en/develop/interfaces/pcan.html#bus

zariiii9003 commented 2 years ago

However, pcan does not seem to have that: https://python-can.readthedocs.io/en/develop/interfaces/pcan.html#bus

Also VectorBus says this: https://github.com/hardbyte/python-can/blob/d8e9dc5a64326926f744ecd2a9d0658a2acac5ed/can/interfaces/vector/canlib.py#L98 But BusABC does not mention receive_own_messages. Maybe we should add it to the BusABC arguments.

felixdivo commented 2 years ago

I think we should close this issue (not a bug, just bad docs) and open a new one for improving documentation (and possibly the naming) of common parameters. Maybe we could also add a table comparing all the interfaces and their capabilities.

zhoulian1992 commented 2 years ago

Can you show me how to log receive message? I don't know how to log can datas.

felixdivo commented 2 years ago

@zhoulian1992 This has nothing to do with this issue. Have you tried print(message) or str(message)? If that does not work, open a new issue.