icsneopy fixes

David Rebbe 2024-12-05 13:59:28 -05:00
parent 86992b2612
commit dafcbac251
7 changed files with 65 additions and 69 deletions

View File

@ -7,7 +7,7 @@
namespace icsneo { namespace icsneo {
void init_canmessage(pybind11::module_& m) { void init_canmessage(pybind11::module_& m) {
pybind11::class_<CANMessage, std::shared_ptr<CANMessage>, Frame>(m, "CANMessage") pybind11::class_<CANMessage, std::shared_ptr<CANMessage>, BusMessage>(m, "CANMessage")
.def(pybind11::init()) .def(pybind11::init())
.def_readwrite("arbid", &CANMessage::arbid) .def_readwrite("arbid", &CANMessage::arbid)
.def_readwrite("dlcOnWire", &CANMessage::dlcOnWire) .def_readwrite("dlcOnWire", &CANMessage::dlcOnWire)

View File

@ -11,7 +11,7 @@ void init_ethernetmessage(pybind11::module_& m) {
.def("to_string", &MACAddress::toString) .def("to_string", &MACAddress::toString)
.def("__repr__", &MACAddress::toString); .def("__repr__", &MACAddress::toString);
pybind11::class_<EthernetMessage, std::shared_ptr<EthernetMessage>, Frame>(m, "EthernetMessage") pybind11::class_<EthernetMessage, std::shared_ptr<EthernetMessage>, BusMessage>(m, "EthernetMessage")
.def(pybind11::init()) .def(pybind11::init())
.def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled) .def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled)
.def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags) .def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags)

View File

@ -7,7 +7,7 @@
namespace icsneo { namespace icsneo {
void init_mdiomessage(pybind11::module_& m) { void init_mdiomessage(pybind11::module_& m) {
pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, Frame> mdioMessage(m, "MDIOMessage"); pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, BusMessage> mdioMessage(m, "MDIOMessage");
pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause") pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause")
.value("Clause45", MDIOMessage::Clause::Clause45) .value("Clause45", MDIOMessage::Clause::Clause45)
.value("Clause22", MDIOMessage::Clause::Clause22); .value("Clause22", MDIOMessage::Clause::Clause22);

View File

@ -41,7 +41,7 @@ void init_message(pybind11::module_& m) {
.def_readwrite("network", &InternalMessage::network) .def_readwrite("network", &InternalMessage::network)
.def_readwrite("data", &InternalMessage::data); .def_readwrite("data", &InternalMessage::data);
pybind11::class_<Frame, std::shared_ptr<Frame>, InternalMessage>(m, "BusMessage") pybind11::class_<BusMessage, std::shared_ptr<BusMessage>, InternalMessage>(m, "BusMessage")
.def_readwrite("description", &BusMessage::description) .def_readwrite("description", &BusMessage::description)
.def_readwrite("transmitted", &BusMessage::transmitted) .def_readwrite("transmitted", &BusMessage::transmitted)
.def_readwrite("error", &BusMessage::error); .def_readwrite("error", &BusMessage::error);

View File

@ -26,7 +26,7 @@ void init_device(pybind11::module_& m) {
.def("set_polling_message_limit", &Device::setPollingMessageLimit) .def("set_polling_message_limit", &Device::setPollingMessageLimit)
.def("add_message_callback", &Device::addMessageCallback) .def("add_message_callback", &Device::addMessageCallback)
.def("remove_message_callback", &Device::removeMessageCallback) .def("remove_message_callback", &Device::removeMessageCallback)
.def("transmit", pybind11::overload_cast<std::shared_ptr<Frame>>(&Device::transmit)) .def("transmit", pybind11::overload_cast<std::shared_ptr<BusMessage>>(&Device::transmit))
.def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference) .def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference)
.def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference) .def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference)
.def("get_rtc", &Device::getRTC) .def("get_rtc", &Device::getRTC)

View File

@ -3,72 +3,68 @@
#include <pybind11/functional.h> #include <pybind11/functional.h>
#include <icsneo/device/devicetype.h> #include <icsneo/device/devicetype.h>
#include <icsneo/icsneotypes.h>
namespace icsneo { namespace icsneo {
void init_devicetype(pybind11::module_& m) { void init_devicetype(pybind11::module_& m) {
pybind11::class_<DeviceType> deviceType(m, "DeviceType"); pybind11::class_<DeviceType> deviceType(m, "DeviceType");
pybind11::enum_<icsneo_devicetype_t>(deviceType, "Enum") // deviceType.def("get_device_type", &DeviceType::getDeviceType);
.value("Unknown", _icsneo_devicetype_t::Unknown) // deviceType.def("get_generic_product_name", &DeviceType::getGenericProductName);
.value("BLUE", _icsneo_devicetype_t::BLUE)
.value("ECU_AVB", _icsneo_devicetype_t::ECU_AVB) pybind11::enum_<_icsneo_devicetype_t>(m, "icsneo_devicetype_t")
.value("RADSupermoon", _icsneo_devicetype_t::RADSupermoon) .value("Unknown", icsneo_devicetype_unknown)
.value("DW_VCAN", _icsneo_devicetype_t::DW_VCAN) .value("BLUE", icsneo_devicetype_blue)
.value("RADMoon2", _icsneo_devicetype_t::RADMoon2) .value("ECU_AVB", icsneo_devicetype_ecu_avb)
.value("RADMars", _icsneo_devicetype_t::RADMars) .value("RADSupermoon", icsneo_devicetype_rad_supermoon)
.value("VCAN4_1", _icsneo_devicetype_t::VCAN4_1) .value("DW_VCAN", icsneo_devicetype_dw_vcan)
.value("FIRE", _icsneo_devicetype_t::FIRE) .value("RADMoon2", icsneo_devicetype_rad_moon2)
.value("RADPluto", _icsneo_devicetype_t::RADPluto) .value("RADMars", icsneo_devicetype_rad_mars)
.value("VCAN4_2EL", _icsneo_devicetype_t::VCAN4_2EL) .value("VCAN4_1", icsneo_devicetype_vcan41)
.value("RADIO_CANHUB", _icsneo_devicetype_t::RADIO_CANHUB) .value("FIRE", icsneo_devicetype_fire)
.value("NEOECU12", _icsneo_devicetype_t::NEOECU12) .value("RADPluto", icsneo_devicetype_rad_pluto)
.value("OBD2_LCBADGE", _icsneo_devicetype_t::OBD2_LCBADGE) .value("VCAN4_2EL", icsneo_devicetype_vcan42_el)
.value("RADMoonDuo", _icsneo_devicetype_t::RADMoonDuo) .value("RADIO_CANHUB", icsneo_devicetype_radio_canhub)
.value("FIRE3", _icsneo_devicetype_t::FIRE3) .value("NEOECU12", icsneo_devicetype_neo_ecu12)
.value("VCAN3", _icsneo_devicetype_t::VCAN3) .value("OBD2_LCBADGE", icsneo_devicetype_obd2_lc_badge)
.value("RADJupiter", _icsneo_devicetype_t::RADJupiter) .value("RADMoonDuo", icsneo_devicetype_rad_moon_duo)
.value("VCAN4_IND", _icsneo_devicetype_t::VCAN4_IND) .value("FIRE3", icsneo_devicetype_fire3)
.value("RADGigastar", _icsneo_devicetype_t::RADGigastar) .value("VCAN3", icsneo_devicetype_vcan3)
.value("RED2", _icsneo_devicetype_t::RED2) .value("RADJupiter", icsneo_devicetype_rad_jupiter)
.value("EtherBADGE", _icsneo_devicetype_t::EtherBADGE) .value("VCAN4_IND", icsneo_devicetype_vcan4_industrial)
.value("RAD_A2B", _icsneo_devicetype_t::RAD_A2B) .value("RADGigastar", icsneo_devicetype_rad_gigastar)
.value("RADEpsilon", _icsneo_devicetype_t::RADEpsilon) .value("RED2", icsneo_devicetype_red2)
.value("RADMoon3", _icsneo_devicetype_t::RADMoon3) .value("EtherBADGE", icsneo_devicetype_etherbadge)
.value("RADComet", _icsneo_devicetype_t::RADComet) .value("RAD_A2B", icsneo_devicetype_rad_a2b)
.value("FIRE3_FlexRay", _icsneo_devicetype_t::FIRE3_FlexRay) .value("RADEpsilon", icsneo_devicetype_rad_epsilon)
.value("Connect", _icsneo_devicetype_t::Connect) .value("RADMoon3", icsneo_devicetype_rad_moon3)
.value("RADComet3", _icsneo_devicetype_t::RADComet3) .value("RADComet", icsneo_devicetype_rad_comet)
.value("RADMoonT1S", _icsneo_devicetype_t::RADMoonT1S) .value("FIRE3_FlexRay", icsneo_devicetype_fire3_flexray)
.value("RADGigastar2", _icsneo_devicetype_t::RADGigastar2) .value("Connect", icsneo_devicetype_connect)
.value("RED", _icsneo_devicetype_t::RED) .value("RADComet3", icsneo_devicetype_rad_comet3)
.value("ECU", _icsneo_devicetype_t::ECU) .value("RADMoonT1S", icsneo_devicetype_rad_moon_t1s)
.value("IEVB", _icsneo_devicetype_t::IEVB) .value("RADGigastar2", icsneo_devicetype_rad_gigastar2)
.value("Pendant", _icsneo_devicetype_t::Pendant) .value("RED", icsneo_devicetype_red)
.value("OBD2_PRO", _icsneo_devicetype_t::OBD2_PRO) .value("ECU", icsneo_devicetype_ecu)
.value("ECUChip_UART", _icsneo_devicetype_t::ECUChip_UART) .value("IEVB", icsneo_devicetype_ievb)
.value("PLASMA", _icsneo_devicetype_t::PLASMA) .value("Pendant", icsneo_devicetype_pendant)
.value("DONT_REUSE0", _icsneo_devicetype_t::DONT_REUSE0) .value("OBD2_PRO", icsneo_devicetype_obd2_pro)
.value("NEOAnalog", _icsneo_devicetype_t::NEOAnalog) .value("ECUChip_UART", icsneo_devicetype_ecuchip_uart)
.value("CT_OBD", _icsneo_devicetype_t::CT_OBD) .value("PLASMA", icsneo_devicetype_plasma)
.value("DONT_REUSE1", _icsneo_devicetype_t::DONT_REUSE1) .value("NEOAnalog", icsneo_devicetype_neo_analog)
.value("DONT_REUSE2", _icsneo_devicetype_t::DONT_REUSE2) .value("CT_OBD", icsneo_devicetype_ct_obd)
.value("ION", _icsneo_devicetype_t::ION) .value("ION", icsneo_devicetype_ion)
.value("RADStar", _icsneo_devicetype_t::RADStar) .value("RADStar", icsneo_devicetype_rad_star)
.value("DONT_REUSE3", _icsneo_devicetype_t::DONT_REUSE3) .value("VCAN4_4", icsneo_devicetype_vcan44)
.value("VCAN4_4", _icsneo_devicetype_t::VCAN4_4) .value("VCAN4_2", icsneo_devicetype_vcan42)
.value("VCAN4_2", _icsneo_devicetype_t::VCAN4_2) .value("CMProbe", icsneo_devicetype_cm_probe)
.value("CMProbe", _icsneo_devicetype_t::CMProbe) .value("EEVB", icsneo_devicetype_eevb)
.value("EEVB", _icsneo_devicetype_t::EEVB) .value("FIRE2", icsneo_devicetype_fire2)
.value("VCANrf", _icsneo_devicetype_t::VCANrf) .value("Flex", icsneo_devicetype_flex)
.value("FIRE2", _icsneo_devicetype_t::FIRE2) .value("RADGalaxy", icsneo_devicetype_rad_galaxy)
.value("Flex", _icsneo_devicetype_t::Flex) .value("RADStar2", icsneo_devicetype_rad_star2)
.value("RADGalaxy", _icsneo_devicetype_t::RADGalaxy) .value("VividCAN", icsneo_devicetype_vividcan)
.value("RADStar2", _icsneo_devicetype_t::RADStar2) .value("OBD2_SIM", icsneo_devicetype_obd2_sim);
.value("VividCAN", _icsneo_devicetype_t::VividCAN)
.value("OBD2_SIM", _icsneo_devicetype_t::OBD2_SIM);
deviceType.def(pybind11::init<icsneo_devicetype_t>());
deviceType.def("get_device_type", &_icsneo_devicetype_t::getDeviceType);
deviceType.def("get_generic_product_name", &_icsneo_devicetype_t::getGenericProductName);
} }
} // namespace icsneo } // namespace icsneo

View File

@ -170,7 +170,7 @@ int main() {
auto handler = device->addMessageCallback(std::make_shared<icsneo::MessageCallback>([](std::shared_ptr<icsneo::Message> message) { auto handler = device->addMessageCallback(std::make_shared<icsneo::MessageCallback>([](std::shared_ptr<icsneo::Message> message) {
switch(message->type) { switch(message->type) {
case icsneo::Message::Type::BusMessage: { case icsneo::Message::Type::BusMessage: {
// A message of type Frame is guaranteed to be a Frame, so we can static cast safely // A message of type BusMessage is guaranteed to be a BusMessage, so we can static cast safely
auto frame = std::static_pointer_cast<icsneo::BusMessage>(message); auto frame = std::static_pointer_cast<icsneo::BusMessage>(message);
switch(frame->network.getType()) { switch(frame->network.getType()) {
case icsneo_msg_bus_type_can: { case icsneo_msg_bus_type_can: {
@ -202,7 +202,7 @@ int main() {
case icsneo_msg_bus_type_ethernet: { case icsneo_msg_bus_type_ethernet: {
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message); auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec std::cout << "\t\t" << ethMessage->network << " BusMessage - " << std::dec
<< ethMessage->data.size() << " bytes on wire\n"; << ethMessage->data.size() << " bytes on wire\n";
std::cout << "\t\t Timestamped:\t"<< ethMessage->timestamp << " ns since 1/1/2007\n"; std::cout << "\t\t Timestamped:\t"<< ethMessage->timestamp << " ns since 1/1/2007\n";
@ -249,7 +249,7 @@ int main() {
break; break;
} }
break; break;
} // end of icsneo::Message::Type::Frame } // end of icsneo::Message::Type::BusMessage
case icsneo::Message::Type::CANErrorCount: { case icsneo::Message::Type::CANErrorCount: {
// A message of type CANErrorCount is guaranteed to be a CANErrorCount, so we can static cast safely // A message of type CANErrorCount is guaranteed to be a CANErrorCount, so we can static cast safely
auto cec = std::static_pointer_cast<icsneo::CANErrorCountMessage>(message); auto cec = std::static_pointer_cast<icsneo::CANErrorCountMessage>(message);