You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a working project with python importing my Lib.so that contains some cpp code with pybind11 binding.
My cpp code is calling an imported python library, isotp. This lib has an option to register a callback function, but I have not been able to find any details on how to define this in cpp.
My working code is setup like this
` pybind11::print("using Pcan ...");
auto PcanBus = pybind11::module_::import("can.interfaces.pcan").attr("PcanBus");
can_message = new pybind11::object(pybind11::module_::import("can").attr("Message"));
can_bus = new pybind11::object(PcanBus("channel"_a ="PCAN_USBBUS1", "bitrate"_a=250000, "timeout"_a=0.2));
can_bus_send_method = new pybind11::object(can_bus->attr("send"));
can_bus_recv_method = new pybind11::object(can_bus->attr("recv"));
auto Isotp = pybind11::module_::import("isotp");
Isotp_address = new pybind11::object(Isotp.attr("Address"));
Isotp_CanStack = new pybind11::object(Isotp.attr("CanStack"));
isotp_myAddr = new pybind11::object((*Isotp_address)(0, "rxid"_a=0x303, "txid"_a=0x302));
isotp_bus = new pybind11::object((*Isotp_CanStack)(*can_bus, "address"_a=(*isotp_myAddr)));`
and I need to change the last line to something like this isotp_bus = new pybind11::object((*Isotp_CanStack)(*can_bus, "address"_a=(*isotp_myAddr) , "error_handler"_a=my_cpp_error_handler ));
However, I have been unable to figure out the definition of my_cpp_error_handler.
Anyone know where I can find the documentation that will help me out here?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a working project with python importing my Lib.so that contains some cpp code with pybind11 binding.
My cpp code is calling an imported python library, isotp. This lib has an option to register a callback function, but I have not been able to find any details on how to define this in cpp.
My working code is setup like this
` pybind11::print("using Pcan ...");
auto PcanBus = pybind11::module_::import("can.interfaces.pcan").attr("PcanBus");
can_message = new pybind11::object(pybind11::module_::import("can").attr("Message"));
can_bus = new pybind11::object(PcanBus("channel"_a ="PCAN_USBBUS1", "bitrate"_a=250000, "timeout"_a=0.2));
can_bus_send_method = new pybind11::object(can_bus->attr("send"));
can_bus_recv_method = new pybind11::object(can_bus->attr("recv"));
and I need to change the last line to something like this
isotp_bus = new pybind11::object((*Isotp_CanStack)(*can_bus, "address"_a=(*isotp_myAddr) , "error_handler"_a=my_cpp_error_handler ));
However, I have been unable to figure out the definition of my_cpp_error_handler.
Anyone know where I can find the documentation that will help me out here?
Beta Was this translation helpful? Give feedback.
All reactions