我有"main".py和newcanmonitor.py'
-----主要.py公司----
import newcanmonitor
xy=newcanmonitor.read_bus('vcan0')
print(xy)
------newcanmonitor.py公司------
def read_bus(bus_device):
"""Read data from `bus_device` until the next newline character."""
message = bus.recv(0.2)
while True:
if message:
break
message = bus.recv(0.2)
try:
string = "{}:ID={}:LEN={}".format("RX", message.arbitration_id, message.dlc)
for x in range(message.dlc):
string += ":{:02x}".format(message.data[x])
except Exception as e:
print(e)
return string
显然这不起作用