Jan-23-2022, 01:48 PM
Hello ,
starnge problem
I have a working python code that print me canbus data
today I enter the code to a new machine and I get this error (just copied the code)
waht is this , and what is wrong?
Thanks ,
starnge problem
I have a working python code that print me canbus data
today I enter the code to a new machine and I get this error (just copied the code)
def ReadCanBusData(): bus = can.interface.Bus(channel='can0', bustype='socketcan') while True: try: message = bus.recv(10) except Exception as e: print('error in CanBus!') else: if message is None: print('TimeOut!') else: TS = datetime.datetime.now() pid_temp = message.arbitration_id pid_int = int(pid_temp) data_byte = message.data try: data_temp = [f"{byte:02x}" for byte in data_byte] except Exception as e: print(e) Data = ' '.join(data_temp) PID = f"{pid_int:08X}" PID = PID.upper() print(str(TS) + ": " + PID + ": " + Data)when I try to run it I get :
python3 ReadCanbus.py File "ReadCanbus.py", line 39 data_temp = [f"{byte:02x}" for byte in data_byte] ^ SyntaxError: invalid syntaxand also this (when I disable line 39,40):
python3 ReadCanbus.py File "ReadCanbus.py", line 41 PID = f"{pid_int:08X}" ^ SyntaxError: invalid syntaxagain - it's the same file running on other machine
waht is this , and what is wrong?
Thanks ,