Answer the question
In order to leave comments, you need to log in
How to solve python type conversion error?
I work with CAN adapter directly via COM port (I use CANard)
import canard, serial
from canard import can
from canard.hw import cantact
f = can.Frame(41)
f.dlc = 8
f.data = [32,23,4,5,6,7,8,9]
dev = cantact.CantactDev('COM4')
dev.set_bitrate(125000)
dev.start()
dev.send(f)
Msg = dev.recv()
dev.stop()
rx_str = ""
while rx_str == "" or rx_str[-1] != '\r':
rx_str = rx_str + self.ser.read().decode('UTF-8', 'ignore')
# parse the id, create a frame
frame_id = int(rx_str[1:4], 16) #строка с ошибкой
frame = can.Frame(frame_id)
Answer the question
In order to leave comments, you need to log in
And what is wrong ?
You are being told that "" (nothing) is not a valid hexadecimal number
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question