Skip to content

Commit

Permalink
only try what is to be traught
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Jun 8, 2024
1 parent 1834bde commit db3750f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion can/packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CANPacker::CANPacker(const std::string& dbc_name) {
std::vector<uint8_t> CANPacker::pack(uint32_t address, const std::vector<SignalPackValue> &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 {};
}

Expand Down
14 changes: 7 additions & 7 deletions can/packer_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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, (<char *>&val[0])[:val.size()], bus]

0 comments on commit db3750f

Please sign in to comment.