diff --git a/can/packer.cc b/can/packer.cc index 9e6c01dc72..277b17300f 100644 --- a/can/packer.cc +++ b/can/packer.cc @@ -43,7 +43,7 @@ CANPacker::CANPacker(const std::string& dbc_name) { std::vector CANPacker::pack(uint32_t address, const std::vector &signals) { auto msg_it = dbc->addr_to_msg.find(address); if (msg_it == dbc->addr_to_msg.end()) { - LOGE("invalid address %d\n", address); + LOGE("undefined address - %d", address); return {}; } diff --git a/can/packer_pyx.pyx b/can/packer_pyx.pyx index 4340cc4dea..7b25dcad1d 100644 --- a/can/packer_pyx.pyx +++ b/can/packer_pyx.pyx @@ -39,15 +39,15 @@ cdef class CANPacker: cpdef make_can_msg(self, name_or_addr, bus, values): cdef uint32_t address = 0 cdef const Msg* m - try: - if isinstance(name_or_addr, int): - address = name_or_addr - else: + if isinstance(name_or_addr, int): + address = name_or_addr + else: + try: m = self.dbc.name_to_msg.at(name_or_addr.encode("utf8")) address = m.address - except IndexError: - # The C++ pack function will log an error message for invalid addresses - pass + except IndexError: + # The C++ pack function will log an error message for invalid addresses + pass cdef vector[uint8_t] val = self.pack(address, values) return [address, 0, (&val[0])[:val.size()], bus]