Compare commits
5 Commits
fa529e40cf
...
e952e603bb
| Author | SHA1 | Date |
|---|---|---|
|
|
e952e603bb | |
|
|
d328d314b6 | |
|
|
7b5b94d980 | |
|
|
fedb4b88f3 | |
|
|
31d4a750d8 |
|
|
@ -392,7 +392,7 @@ endif()
|
|||
include(FetchContent)
|
||||
FetchContent_Declare(icspb
|
||||
GIT_REPOSITORY ${LIBICSNEO_ICSPB_REPO}
|
||||
GIT_TAG 2881dc4239319214dbf72fd3aa0427a4aefddd42
|
||||
GIT_TAG 48df5dd7fd0c38034f82a2f94e0eada404d5e2b9
|
||||
)
|
||||
FetchContent_MakeAvailable(icspb)
|
||||
target_link_libraries(icsneocpp PRIVATE icspb::icspb)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ else()
|
|||
FetchContent_Declare(
|
||||
pybind11
|
||||
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
||||
GIT_TAG v2.13.6
|
||||
GIT_TAG v3.0.1
|
||||
)
|
||||
FetchContent_MakeAvailable(pybind11)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/native_enum.h>
|
||||
|
||||
#include "icsneo/api/event.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
void init_event(pybind11::module_& m) {
|
||||
pybind11::class_<APIEvent, std::shared_ptr<APIEvent>> apiEvent(m, "APIEvent");
|
||||
pybind11::enum_<APIEvent::Type>(apiEvent, "Type")
|
||||
pybind11::classh<APIEvent> apiEvent(m, "APIEvent");
|
||||
pybind11::native_enum<APIEvent::Type>(apiEvent, "Type", "enum.IntEnum")
|
||||
.value("Any", APIEvent::Type::Any)
|
||||
.value("InvalidNeoDevice", APIEvent::Type::InvalidNeoDevice)
|
||||
.value("RequiredParameterNull", APIEvent::Type::RequiredParameterNull)
|
||||
|
|
@ -132,13 +133,15 @@ void init_event(pybind11::module_& m) {
|
|||
.value("DXXErrorArg", APIEvent::Type::DXXErrorArg)
|
||||
.value("NoErrorFound", APIEvent::Type::NoErrorFound)
|
||||
.value("TooManyEvents", APIEvent::Type::TooManyEvents)
|
||||
.value("Unknown", APIEvent::Type::Unknown);
|
||||
.value("Unknown", APIEvent::Type::Unknown)
|
||||
.finalize();
|
||||
|
||||
pybind11::enum_<APIEvent::Severity>(apiEvent, "Severity")
|
||||
pybind11::native_enum<APIEvent::Severity>(apiEvent, "Severity", "enum.IntEnum")
|
||||
.value("Any", APIEvent::Severity::Any)
|
||||
.value("EventInfo", APIEvent::Severity::EventInfo)
|
||||
.value("EventWarning", APIEvent::Severity::EventWarning)
|
||||
.value("Error", APIEvent::Severity::Error);
|
||||
.value("Error", APIEvent::Severity::Error)
|
||||
.finalize();
|
||||
|
||||
apiEvent
|
||||
.def("get_type", &APIEvent::getType)
|
||||
|
|
@ -147,7 +150,7 @@ void init_event(pybind11::module_& m) {
|
|||
.def("describe", &APIEvent::describe)
|
||||
.def("__repr__", &APIEvent::describe);
|
||||
|
||||
pybind11::class_<EventFilter, std::shared_ptr<EventFilter>>(m, "EventFilter")
|
||||
pybind11::classh<EventFilter>(m, "EventFilter")
|
||||
.def(pybind11::init())
|
||||
.def(pybind11::init<APIEvent::Type>())
|
||||
.def(pybind11::init<APIEvent::Severity>())
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_messagecallback(pybind11::module_& m) {
|
||||
pybind11::class_<MessageCallback, std::shared_ptr<MessageCallback>>(m, "MessageCallback")
|
||||
pybind11::classh<MessageCallback>(m, "MessageCallback")
|
||||
.def(pybind11::init<MessageCallback::fn_messageCallback, std::shared_ptr<MessageFilter>>());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/native_enum.h>
|
||||
|
||||
#include "icsneo/communication/message/canerrormessage.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
void init_errorcodes(pybind11::module_& m) {
|
||||
pybind11::enum_<CANErrorCode>(m, "CANErrorCode")
|
||||
pybind11::native_enum<CANErrorCode>(m, "CANErrorCode", "enum.IntEnum")
|
||||
.value("NoError", CANErrorCode::NoError)
|
||||
.value("StuffError", CANErrorCode::StuffError)
|
||||
.value("FormError", CANErrorCode::FormError)
|
||||
|
|
@ -15,12 +16,13 @@ void init_errorcodes(pybind11::module_& m) {
|
|||
.value("Bit1Error", CANErrorCode::Bit1Error)
|
||||
.value("Bit0Error", CANErrorCode::Bit0Error)
|
||||
.value("CRCError", CANErrorCode::CRCError)
|
||||
.value("NoChange", CANErrorCode::NoChange);
|
||||
.value("NoChange", CANErrorCode::NoChange)
|
||||
.finalize();
|
||||
}
|
||||
|
||||
void init_canerrormessage(pybind11::module_& m) {
|
||||
init_errorcodes(m);
|
||||
pybind11::class_<CANErrorMessage, std::shared_ptr<CANErrorMessage>, Message>(m, "CANErrorMessage")
|
||||
pybind11::classh<CANErrorMessage, Message>(m, "CANErrorMessage")
|
||||
.def_readonly("network", &CANErrorMessage::network)
|
||||
.def_readonly("transmitErrorCount", &CANErrorMessage::transmitErrorCount)
|
||||
.def_readonly("receiveErrorCount", &CANErrorMessage::receiveErrorCount)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_canmessage(pybind11::module_& m) {
|
||||
pybind11::class_<CANMessage, std::shared_ptr<CANMessage>, Frame>(m, "CANMessage")
|
||||
pybind11::classh<CANMessage, Frame>(m, "CANMessage")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("arbid", &CANMessage::arbid)
|
||||
.def_readwrite("dlcOnWire", &CANMessage::dlcOnWire)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ void init_ethernetmessage(pybind11::module_& m) {
|
|||
.def("to_string", &MACAddress::toString)
|
||||
.def("__repr__", &MACAddress::toString);
|
||||
|
||||
pybind11::class_<EthernetMessage, std::shared_ptr<EthernetMessage>, Frame>(m, "EthernetMessage")
|
||||
pybind11::classh<EthernetMessage, Frame>(m, "EthernetMessage")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled)
|
||||
.def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_ethernetstatusmessage(pybind11::module_& m) {
|
||||
pybind11::class_<EthernetStatusMessage, std::shared_ptr<EthernetStatusMessage>, Message> ethernetStatusMessage(m, "EthernetStatusMessage");
|
||||
pybind11::classh<EthernetStatusMessage, Message> ethernetStatusMessage(m, "EthernetStatusMessage");
|
||||
|
||||
pybind11::enum_<EthernetStatusMessage::LinkSpeed>(ethernetStatusMessage, "LinkSpeed")
|
||||
.value("LinkSpeedAuto", EthernetStatusMessage::LinkSpeed::LinkSpeedAuto)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_ethphymessage(pybind11::module_& m) {
|
||||
pybind11::class_<PhyMessage, std::shared_ptr<PhyMessage>>(m, "PhyMessage")
|
||||
pybind11::classh<PhyMessage>(m, "PhyMessage")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("Enabled", &PhyMessage::Enabled)
|
||||
.def_readwrite("WriteEnable", &PhyMessage::WriteEnable)
|
||||
|
|
@ -28,7 +28,7 @@ void init_ethphymessage(pybind11::module_& m) {
|
|||
.def_readwrite("device", &Clause45Message::device)
|
||||
.def_readwrite("regAddr", &Clause45Message::regAddr)
|
||||
.def_readwrite("regVal", &Clause45Message::regVal);
|
||||
pybind11::class_<EthPhyMessage, std::shared_ptr<EthPhyMessage>, Message>(m, "EthPhyMessage")
|
||||
pybind11::classh<EthPhyMessage, Message>(m, "EthPhyMessage")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("messages", &EthPhyMessage::messages);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_messagefilter(pybind11::module_& m) {
|
||||
pybind11::class_<MessageFilter, std::shared_ptr<MessageFilter>>(m, "MessageFilter")
|
||||
pybind11::classh<MessageFilter>(m, "MessageFilter")
|
||||
.def(pybind11::init())
|
||||
.def(pybind11::init<Message::Type>())
|
||||
.def(pybind11::init<Network::NetID>());
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_gptpstatusmessage(pybind11::module_& m) {
|
||||
pybind11::class_<GPTPStatus, std::shared_ptr<GPTPStatus>, Message> gptpStatus(m, "GPTPStatus");
|
||||
pybind11::classh<GPTPStatus, Message> gptpStatus(m, "GPTPStatus");
|
||||
|
||||
pybind11::class_<GPTPStatus::Timestamp>(gptpStatus, "Timestamp")
|
||||
.def_readonly("seconds", &GPTPStatus::Timestamp::seconds)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void init_linmessage(pybind11::module_& m) {
|
|||
.def_readwrite("BusRecovered", &LINStatusFlags::BusRecovered)
|
||||
.def_readwrite("BreakOnly", &LINStatusFlags::BreakOnly);
|
||||
|
||||
pybind11::class_<LINMessage, std::shared_ptr<LINMessage>, Frame> linMessage(m, "LINMessage");
|
||||
pybind11::classh<LINMessage, Frame> linMessage(m, "LINMessage");
|
||||
|
||||
pybind11::enum_<LINMessage::Type>(linMessage, "Type")
|
||||
.value("NOT_SET", LINMessage::Type::NOT_SET)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_mdiomessage(pybind11::module_& m) {
|
||||
pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, Frame> mdioMessage(m, "MDIOMessage");
|
||||
pybind11::classh<MDIOMessage, Frame> mdioMessage(m, "MDIOMessage");
|
||||
pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause")
|
||||
.value("Clause45", MDIOMessage::Clause::Clause45)
|
||||
.value("Clause22", MDIOMessage::Clause::Clause22);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/native_enum.h>
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
void init_message(pybind11::module_& m) {
|
||||
pybind11::class_<Message, std::shared_ptr<Message>> message(m, "Message");
|
||||
pybind11::enum_<Message::Type>(message, "Type")
|
||||
// Using py::smart_holder for safer lifetime management
|
||||
pybind11::classh<Message> message(m, "Message");
|
||||
pybind11::native_enum<Message::Type>(message, "Type", "enum.IntEnum")
|
||||
.value("Frame", Message::Type::Frame)
|
||||
.value("CANErrorCount", Message::Type::CANErrorCount)
|
||||
.value("CANError", Message::Type::CANError)
|
||||
|
|
@ -34,17 +36,18 @@ void init_message(pybind11::module_& m) {
|
|||
.value("TC10Status", Message::Type::TC10Status)
|
||||
.value("AppError", Message::Type::AppError)
|
||||
.value("GPTPStatus", Message::Type::GPTPStatus)
|
||||
.value("EthernetStatus", Message::Type::EthernetStatus);
|
||||
.value("EthernetStatus", Message::Type::EthernetStatus)
|
||||
.finalize();
|
||||
|
||||
message.def(pybind11::init<Message::Type>());
|
||||
message.def_readonly("type", &Message::type);
|
||||
message.def_readwrite("timestamp", &Message::timestamp);
|
||||
|
||||
pybind11::class_<RawMessage, std::shared_ptr<RawMessage>, Message>(m, "RawMessage")
|
||||
pybind11::classh<RawMessage, Message>(m, "RawMessage")
|
||||
.def_readwrite("network", &RawMessage::network)
|
||||
.def_readwrite("data", &RawMessage::data);
|
||||
|
||||
pybind11::class_<Frame, std::shared_ptr<Frame>, RawMessage>(m, "Frame")
|
||||
pybind11::classh<Frame, RawMessage>(m, "Frame")
|
||||
.def_readwrite("description", &Frame::description)
|
||||
.def_readwrite("transmitted", &Frame::transmitted)
|
||||
.def_readwrite("error", &Frame::error);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_scriptstatusmessage(pybind11::module_& m) {
|
||||
pybind11::class_<ScriptStatusMessage, std::shared_ptr<ScriptStatusMessage>, Message>(m, "ScriptStatusMessage")
|
||||
pybind11::classh<ScriptStatusMessage, Message>(m, "ScriptStatusMessage")
|
||||
.def_readonly("isEncrypted", &ScriptStatusMessage::isEncrypted)
|
||||
.def_readonly("isCoreminiRunning", &ScriptStatusMessage::isCoreminiRunning)
|
||||
.def_readonly("sectorOverflows", &ScriptStatusMessage::sectorOverflows)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_spimessage(pybind11::module_& m) {
|
||||
pybind11::class_<SPIMessage, std::shared_ptr<SPIMessage>, Frame> spiMessage(m, "SPIMessage");
|
||||
pybind11::classh<SPIMessage, Frame> spiMessage(m, "SPIMessage");
|
||||
pybind11::enum_<SPIMessage::Direction>(spiMessage, "Direction")
|
||||
.value("Write", SPIMessage::Direction::Write)
|
||||
.value("Read", SPIMessage::Direction::Read);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ void init_tc10statusmessage(pybind11::module_& m) {
|
|||
.value("SleepFailed", TC10SleepStatus::SleepFailed)
|
||||
.value("SleepAborted", TC10SleepStatus::SleepAborted);
|
||||
|
||||
pybind11::class_<TC10StatusMessage, std::shared_ptr<TC10StatusMessage>, Message>(m, "TC10StatusMessage")
|
||||
pybind11::classh<TC10StatusMessage, Message>(m, "TC10StatusMessage")
|
||||
.def_readonly("wakeStatus", &TC10StatusMessage::wakeStatus)
|
||||
.def_readonly("sleepStatus", &TC10StatusMessage::sleepStatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/native_enum.h>
|
||||
|
||||
#include "icsneo/communication/network.h"
|
||||
|
||||
|
|
@ -9,7 +10,7 @@ namespace icsneo {
|
|||
void init_network(pybind11::module_& m) {
|
||||
pybind11::class_<Network> network(m, "Network");
|
||||
|
||||
pybind11::enum_<Network::NetID>(network, "NetID")
|
||||
pybind11::native_enum<Network::NetID>(network, "NetID", "enum.IntEnum")
|
||||
.value("Device", Network::NetID::Device)
|
||||
.value("DWCAN_01", Network::NetID::DWCAN_01)
|
||||
.value("DWCAN_08", Network::NetID::DWCAN_08)
|
||||
|
|
@ -166,9 +167,10 @@ void init_network(pybind11::module_& m) {
|
|||
.value("LIN_15", Network::NetID::LIN_15)
|
||||
.value("LIN_16", Network::NetID::LIN_16)
|
||||
.value("Any", Network::NetID::Any)
|
||||
.value("Invalid", Network::NetID::Invalid);
|
||||
.value("Invalid", Network::NetID::Invalid)
|
||||
.finalize();
|
||||
|
||||
pybind11::enum_<Network::Type>(network, "Type")
|
||||
pybind11::native_enum<Network::Type>(network, "Type", "enum.Enum")
|
||||
.value("Invalid", Network::Type::Invalid)
|
||||
.value("Internal", Network::Type::Internal)
|
||||
.value("CAN", Network::Type::CAN)
|
||||
|
|
@ -185,7 +187,8 @@ void init_network(pybind11::module_& m) {
|
|||
.value("MDIO", Network::Type::MDIO)
|
||||
.value("AutomotiveEthernet", Network::Type::AutomotiveEthernet)
|
||||
.value("Any", Network::Type::Any)
|
||||
.value("Other", Network::Type::Other);
|
||||
.value("Other", Network::Type::Other)
|
||||
.finalize();
|
||||
|
||||
network
|
||||
.def(pybind11::init<Network::NetID>())
|
||||
|
|
|
|||
|
|
@ -35,17 +35,17 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.value("GCM_AES_128_XPN", MACsecCipherSuite::GcmAes128Xpn)
|
||||
.value("GCM_AES_256_XPN", MACsecCipherSuite::GcmAes256Xpn);
|
||||
|
||||
pybind11::class_<MACsecVLANTag, std::shared_ptr<MACsecVLANTag>>(m, "MACsecVLANTag")
|
||||
pybind11::classh<MACsecVLANTag>(m, "MACsecVLANTag")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("vid", &MACsecVLANTag::vid)
|
||||
.def_readwrite("pri_cfi", &MACsecVLANTag::priCfi);
|
||||
|
||||
pybind11::class_<MACsecMPLSOuter, std::shared_ptr<MACsecMPLSOuter>>(m, "MACsecMPLSOuter")
|
||||
pybind11::classh<MACsecMPLSOuter>(m, "MACsecMPLSOuter")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("mpls_label", &MACsecMPLSOuter::mplsLabel)
|
||||
.def_readwrite("exp", &MACsecMPLSOuter::exp);
|
||||
|
||||
pybind11::class_<MACsecTci, std::shared_ptr<MACsecTci>>(m, "MACsecTci")
|
||||
pybind11::classh<MACsecTci>(m, "MACsecTci")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("es", &MACsecTci::es)
|
||||
.def_readwrite("sc", &MACsecTci::sc)
|
||||
|
|
@ -53,7 +53,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.def_readwrite("e", &MACsecTci::e)
|
||||
.def_readwrite("c", &MACsecTci::c);
|
||||
|
||||
pybind11::class_<MACsecRxRule, std::shared_ptr<MACsecRxRule>>(m, "MACsecRxRule")
|
||||
pybind11::classh<MACsecRxRule>(m, "MACsecRxRule")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("key_mac_da", &MACsecRxRule::keyMacDa)
|
||||
.def_readwrite("mask_mac_da", &MACsecRxRule::maskMacDa)
|
||||
|
|
@ -85,7 +85,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.def_readwrite("mask_express", &MACsecRxRule::maskExpress)
|
||||
.def_readwrite("is_mpls", &MACsecRxRule::isMpls);
|
||||
|
||||
pybind11::class_<MACsecTxSecY, std::shared_ptr<MACsecTxSecY>>(m, "MACsecTxSecY")
|
||||
pybind11::classh<MACsecTxSecY>(m, "MACsecTxSecY")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("enable_control_port", &MACsecTxSecY::enableControlPort)
|
||||
.def_readwrite("cipher", &MACsecTxSecY::cipher)
|
||||
|
|
@ -99,7 +99,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.def_readwrite("auxiliary_policy", &MACsecTxSecY::auxiliaryPolicy)
|
||||
.def_readwrite("sci", &MACsecTxSecY::sci);
|
||||
|
||||
pybind11::class_<MACsecRxSecY, std::shared_ptr<MACsecRxSecY>>(m, "MACsecRxSecY")
|
||||
pybind11::classh<MACsecRxSecY>(m, "MACsecRxSecY")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("enable_control_port", &MACsecRxSecY::enableControlPort)
|
||||
.def_readwrite("frame_validation", &MACsecRxSecY::frameValidation)
|
||||
|
|
@ -112,7 +112,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.def_readwrite("is_control_packet", &MACsecRxSecY::isControlPacket)
|
||||
.def_readwrite("sci", &MACsecRxSecY::sci);
|
||||
|
||||
pybind11::class_<MACsecTxSa, std::shared_ptr<MACsecTxSa>>(m, "MACsecTxSa")
|
||||
pybind11::classh<MACsecTxSa>(m, "MACsecTxSa")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("sak", &MACsecTxSa::sak)
|
||||
.def_readwrite("hash_key", &MACsecTxSa::hashKey)
|
||||
|
|
@ -121,7 +121,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.def_readwrite("next_pn", &MACsecTxSa::nextPn)
|
||||
.def_readwrite("an", &MACsecTxSa::an);
|
||||
|
||||
pybind11::class_<MACsecRxSa, std::shared_ptr<MACsecRxSa>>(m, "MACsecRxSa")
|
||||
pybind11::classh<MACsecRxSa>(m, "MACsecRxSa")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("sak", &MACsecRxSa::sak)
|
||||
.def_readwrite("hash_key", &MACsecRxSa::hashKey)
|
||||
|
|
@ -129,7 +129,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||
.def_readwrite("ssci", &MACsecRxSa::ssci)
|
||||
.def_readwrite("next_pn", &MACsecRxSa::nextPn);
|
||||
|
||||
pybind11::class_<MACsecConfig, std::shared_ptr<MACsecConfig>>(m, "MACsecConfig")
|
||||
pybind11::classh<MACsecConfig>(m, "MACsecConfig")
|
||||
.def(pybind11::init<icsneo::DeviceType>())
|
||||
.def("add_rx_secy", &MACsecConfig::addRxSecY, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
.def("add_tx_secY", &MACsecConfig::addTxSecY, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/native_enum.h>
|
||||
|
||||
#include "icsneo/device/chipid.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
void init_chipid(pybind11::module_& m) {
|
||||
pybind11::enum_<ChipID>(m, "ChipID")
|
||||
pybind11::native_enum<ChipID>(m, "ChipID", "enum.IntEnum")
|
||||
.value("neoVIFIRE_MCHIP", ChipID::neoVIFIRE_MCHIP)
|
||||
.value("neoVIFIRE_LCHIP", ChipID::neoVIFIRE_LCHIP)
|
||||
.value("neoVIFIRE_UCHIP", ChipID::neoVIFIRE_UCHIP)
|
||||
|
|
@ -130,7 +131,8 @@ void init_chipid(pybind11::module_& m) {
|
|||
.value("Connect_LINUX", ChipID::Connect_LINUX)
|
||||
.value("RADGigastar2_ZYNQ", ChipID::RADGigastar2_ZYNQ)
|
||||
.value("RADGemini_MCHIP", ChipID::RADGemini_MCHIP)
|
||||
.value("Invalid", ChipID::Invalid);
|
||||
.value("Invalid", ChipID::Invalid)
|
||||
.finalize();
|
||||
}
|
||||
|
||||
} // namespace icsneo
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_device(pybind11::module_& m) {
|
||||
pybind11::class_<Device, std::shared_ptr<Device>>(m, "Device")
|
||||
pybind11::classh<Device>(m, "Device")
|
||||
.def("__repr__", &Device::describe)
|
||||
.def("add_message_callback", &Device::addMessageCallback, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
.def("clear_script", &Device::clearScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/native_enum.h>
|
||||
|
||||
#include "icsneo/device/devicetype.h"
|
||||
|
||||
|
|
@ -8,7 +9,7 @@ namespace icsneo {
|
|||
|
||||
void init_devicetype(pybind11::module_& m) {
|
||||
pybind11::class_<DeviceType> deviceType(m, "DeviceType");
|
||||
pybind11::enum_<DeviceType::Enum>(deviceType, "Enum")
|
||||
pybind11::native_enum<DeviceType::Enum>(deviceType, "Enum", "enum.IntEnum")
|
||||
.value("Unknown", DeviceType::Enum::Unknown)
|
||||
.value("BLUE", DeviceType::Enum::BLUE)
|
||||
.value("ECU_AVB", DeviceType::Enum::ECU_AVB)
|
||||
|
|
@ -70,7 +71,8 @@ void init_devicetype(pybind11::module_& m) {
|
|||
.value("RADGalaxy", DeviceType::Enum::RADGalaxy)
|
||||
.value("RADStar2", DeviceType::Enum::RADStar2)
|
||||
.value("VividCAN", DeviceType::Enum::VividCAN)
|
||||
.value("OBD2_SIM", DeviceType::Enum::OBD2_SIM);
|
||||
.value("OBD2_SIM", DeviceType::Enum::OBD2_SIM)
|
||||
.finalize();
|
||||
deviceType.def(pybind11::init<DeviceType::Enum>());
|
||||
deviceType.def("get_device_type", &DeviceType::getDeviceType);
|
||||
deviceType.def("get_generic_product_name", &DeviceType::getGenericProductName);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
void init_deviceextension(pybind11::module_& m) {
|
||||
pybind11::class_<DeviceExtension, std::shared_ptr<DeviceExtension>>(m, "DeviceExtension")
|
||||
pybind11::classh<DeviceExtension>(m, "DeviceExtension")
|
||||
.def("get_name", &DeviceExtension::getName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void init_idevicesettings(pybind11::module_& m) {
|
|||
.value("Speed5G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_5000)
|
||||
.value("Speed10G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_10000);
|
||||
|
||||
pybind11::class_<IDeviceSettings, std::shared_ptr<IDeviceSettings>>(m, "IDeviceSettings")
|
||||
pybind11::classh<IDeviceSettings>(m, "IDeviceSettings")
|
||||
.def("apply", &IDeviceSettings::apply, pybind11::arg("temporary") = 0, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
.def("apply_defaults", &IDeviceSettings::applyDefaults, pybind11::arg("temporary") = 0, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
.def("get_phy_enable", &IDeviceSettings::getPhyEnable, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct ClusterNamespace {
|
|||
};
|
||||
|
||||
void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
||||
pybind11::class_<MessageBuffer, std::shared_ptr<MessageBuffer>>(c, "MessageBuffer")
|
||||
pybind11::classh<MessageBuffer>(c, "MessageBuffer")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("is_dynamic", &MessageBuffer::isDynamic)
|
||||
.def_readwrite("is_sync", &MessageBuffer::isSync)
|
||||
|
|
@ -39,7 +39,7 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||
.def_readwrite("cycle_repetition", &MessageBuffer::cycleRepetition)
|
||||
.def_readwrite("continuous_mode", &MessageBuffer::continuousMode);
|
||||
|
||||
auto controller = pybind11::class_<Controller, std::shared_ptr<Controller>>(c, "Controller")
|
||||
auto controller = pybind11::classh<Controller>(c, "Controller")
|
||||
.def("get_network", &Controller::getNetwork)
|
||||
.def("get_configuration", &Controller::getConfiguration)
|
||||
.def("set_configuration", &Controller::setConfiguration)
|
||||
|
|
@ -143,7 +143,7 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||
} // namespace FlexRay
|
||||
|
||||
void init_flexraymessage(pybind11::module_& m) {
|
||||
pybind11::class_<FlexRayMessage, std::shared_ptr<FlexRayMessage>, Frame>(m, "FlexRayMessage")
|
||||
pybind11::classh<FlexRayMessage, Frame>(m, "FlexRayMessage")
|
||||
.def(pybind11::init())
|
||||
.def_readwrite("slotid", &FlexRayMessage::slotid)
|
||||
.def_readwrite("tsslen", &FlexRayMessage::tsslen)
|
||||
|
|
|
|||
|
|
@ -133,6 +133,10 @@ EthernetPacketizer::EthernetPacket::EthernetPacket(const uint8_t* data, size_t s
|
|||
|
||||
int EthernetPacketizer::EthernetPacket::loadBytestream(const std::vector<uint8_t>& bytestream) {
|
||||
errorWhileDecodingFromBytestream = 0;
|
||||
if (bytestream.size() < 24) {
|
||||
errorWhileDecodingFromBytestream = 1;
|
||||
return errorWhileDecodingFromBytestream;
|
||||
}
|
||||
for(size_t i = 0; i < 6; i++)
|
||||
destMAC[i] = bytestream[i];
|
||||
for(size_t i = 0; i < 6; i++)
|
||||
|
|
|
|||
|
|
@ -74,3 +74,11 @@ Device Firmware/Chip Versions
|
|||
|
||||
.. literalinclude:: ../../examples/python/device/chip_versions.py
|
||||
:language: python
|
||||
|
||||
SPI Example for 10BASE-T1S
|
||||
=============================
|
||||
|
||||
:download:`Download example <../../examples/python/spi/spi_example.py>`
|
||||
|
||||
.. literalinclude:: ../../examples/python/spi/spi_example.py
|
||||
:language: python
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
"""
|
||||
Complete SPI example for 10BASE-T1S MACPHYs using icsneopy library.
|
||||
|
||||
Demonstrates device setup and SPI frame transmission/reception.
|
||||
"""
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
|
||||
|
||||
def setup_device():
|
||||
"""Initialize SPI device."""
|
||||
devices = icsneopy.find_all_devices()
|
||||
if not devices:
|
||||
raise RuntimeError("No devices found")
|
||||
|
||||
device = devices[0]
|
||||
print(f"Using device: {device}")
|
||||
return device
|
||||
|
||||
|
||||
def open_device(device):
|
||||
"""Open device connection."""
|
||||
try:
|
||||
if not device.open():
|
||||
raise RuntimeError("Failed to open device")
|
||||
|
||||
if not device.go_online():
|
||||
device.close()
|
||||
raise RuntimeError("Failed to go online")
|
||||
|
||||
print("Device initialized successfully")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"Device setup failed: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def transmit_spi_frame(device, mms, addr, dir, write_data=None):
|
||||
"""Transmit a SPI frame."""
|
||||
frame = icsneopy.SPIMessage()
|
||||
frame.network = icsneopy.Network(icsneopy.Network.NetID.SPI_01)
|
||||
frame.direction = dir
|
||||
frame.mms = mms
|
||||
frame.address = addr
|
||||
if dir == icsneopy.SPIMessage.Direction.Read:
|
||||
frame.payload = [0] # single register
|
||||
else:
|
||||
frame.payload = [write_data]
|
||||
|
||||
success = device.transmit(frame)
|
||||
if success:
|
||||
print("Frame transmitted")
|
||||
else:
|
||||
print("Failed to transmit frame")
|
||||
|
||||
return success
|
||||
|
||||
|
||||
def setup_spi_reception(device):
|
||||
"""Configure SPI frame reception with callback."""
|
||||
|
||||
def frame_handler(frame):
|
||||
access = (
|
||||
"Write"
|
||||
if frame.direction == icsneopy.SPIMessage.Direction.Write
|
||||
else "Read"
|
||||
)
|
||||
print(
|
||||
f"{access}, "
|
||||
f"MMS: 0x{frame.mms:02X}, "
|
||||
f"Register: 0x{frame.address:03X}, "
|
||||
f"Data: {[hex(b) for b in frame.payload]}, "
|
||||
f"Length: {len(frame.payload)}"
|
||||
)
|
||||
|
||||
frame_filter = icsneopy.MessageFilter(icsneopy.Network.NetID.SPI_01)
|
||||
callback = icsneopy.MessageCallback(frame_handler, frame_filter)
|
||||
device.add_message_callback(callback)
|
||||
|
||||
print("SPI frame reception configured")
|
||||
|
||||
|
||||
def cleanup_device(device):
|
||||
"""Close device connection."""
|
||||
if device:
|
||||
device.close()
|
||||
print("Device connection closed")
|
||||
|
||||
|
||||
def main():
|
||||
"""Complete SPI example with proper error handling."""
|
||||
device = None
|
||||
|
||||
try:
|
||||
# Setup device
|
||||
device = setup_device()
|
||||
|
||||
# Open device
|
||||
if not open_device(device):
|
||||
raise RuntimeError("Failed to initialize device")
|
||||
|
||||
# Setup frame reception
|
||||
setup_spi_reception(device)
|
||||
|
||||
# Read 10BASE-T1S MACPHY ID register
|
||||
transmit_spi_frame(device, 0x0, 0x0001, icsneopy.SPIMessage.Direction.Read)
|
||||
|
||||
# Change 10BASE-T1S Test mode control
|
||||
transmit_spi_frame(device, 0x3, 0x08FB, icsneopy.SPIMessage.Direction.Read)
|
||||
transmit_spi_frame(
|
||||
device, 0x3, 0x08FB, icsneopy.SPIMessage.Direction.Write, 0x6000
|
||||
)
|
||||
transmit_spi_frame(device, 0x3, 0x08FB, icsneopy.SPIMessage.Direction.Read)
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
# Listen for responses
|
||||
print("Listening for SPI frames for 5 seconds...")
|
||||
time.sleep(5)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return 1
|
||||
|
||||
finally:
|
||||
cleanup_device(device)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue