diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index bee412b..bb5997c 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -31,8 +31,10 @@ pybind11_add_module(icsneopy icsneopy/communication/message/gptpstatusmessage.cpp icsneopy/communication/message/ethernetstatusmessage.cpp icsneopy/communication/message/macsecmessage.cpp + icsneopy/communication/message/scriptstatusmessage.cpp icsneopy/communication/message/callback/messagecallback.cpp icsneopy/communication/message/filter/messagefilter.cpp + icsneopy/disk/diskdriver.cpp icsneopy/device/device.cpp icsneopy/icsneocpp.cpp ) diff --git a/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp b/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp new file mode 100644 index 0000000..358afb4 --- /dev/null +++ b/bindings/python/icsneopy/communication/message/scriptstatusmessage.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +#include "icsneo/communication/message/scriptstatusmessage.h" + +namespace icsneo { + +void init_scriptstatusmessage(pybind11::module_& m) { + pybind11::class_, Message>(m, "ScriptStatusMessage") + .def_readonly("isEncrypted", &ScriptStatusMessage::isEncrypted) + .def_readonly("isCoreminiRunning", &ScriptStatusMessage::isCoreminiRunning) + .def_readonly("sectorOverflows", &ScriptStatusMessage::sectorOverflows) + .def_readonly("numRemainingSectorBuffers", &ScriptStatusMessage::numRemainingSectorBuffers) + .def_readonly("lastSector", &ScriptStatusMessage::lastSector) + .def_readonly("readBinSize", &ScriptStatusMessage::readBinSize) + .def_readonly("minSector", &ScriptStatusMessage::minSector) + .def_readonly("maxSector", &ScriptStatusMessage::maxSector) + .def_readonly("currentSector", &ScriptStatusMessage::currentSector) + .def_readonly("coreminiCreateTime", &ScriptStatusMessage::coreminiCreateTime) + .def_readonly("fileChecksum", &ScriptStatusMessage::fileChecksum) + .def_readonly("coreminiVersion", &ScriptStatusMessage::coreminiVersion) + .def_readonly("coreminiHeaderSize", &ScriptStatusMessage::coreminiHeaderSize) + .def_readonly("diagnosticErrorCode", &ScriptStatusMessage::diagnosticErrorCode) + .def_readonly("diagnosticErrorCodeCount", &ScriptStatusMessage::diagnosticErrorCodeCount) + .def_readonly("maxCoreminiSizeKB", &ScriptStatusMessage::maxCoreminiSizeKB); +} + +} // namespace icsneo + diff --git a/bindings/python/icsneopy/device/device.cpp b/bindings/python/icsneopy/device/device.cpp index ab4b8e8..ebb99b3 100644 --- a/bindings/python/icsneopy/device/device.cpp +++ b/bindings/python/icsneopy/device/device.cpp @@ -5,43 +5,51 @@ #include "icsneo/device/device.h" +#include + namespace icsneo { void init_device(pybind11::module_& m) { pybind11::class_>(m, "Device") - .def("get_type", &Device::getType) - .def("get_serial", &Device::getSerial) - .def("get_serial_number", &Device::getSerialNumber) - .def("get_product_name", &Device::getProductName) - .def("open", [](Device& device) { return device.open(); }, pybind11::call_guard()) - .def("close", &Device::close, pybind11::call_guard()) - .def("is_open", &Device::isOpen) - .def("go_online", &Device::goOnline, pybind11::call_guard()) - .def("go_offline", &Device::goOffline, pybind11::call_guard()) - .def("is_online", &Device::isOnline) - .def("enable_message_polling", &Device::enableMessagePolling, pybind11::call_guard()) - .def("disable_message_polling", &Device::disableMessagePolling, pybind11::call_guard()) - .def("is_message_polling_enabled", &Device::isMessagePollingEnabled) - .def("get_messages", [](Device& device) { return device.getMessages(); }, pybind11::call_guard()) - .def("get_current_message_count", &Device::getCurrentMessageCount) - .def("get_polling_message_limit", &Device::getPollingMessageLimit) - .def("set_polling_message_limit", &Device::setPollingMessageLimit) + .def("__repr__", &Device::describe) .def("add_message_callback", &Device::addMessageCallback, pybind11::call_guard()) - .def("remove_message_callback", &Device::removeMessageCallback, pybind11::call_guard()) - .def("transmit", pybind11::overload_cast>(&Device::transmit), pybind11::call_guard()) + .def("clear_script", &Device::clearScript, pybind11::call_guard()) + .def("close", &Device::close, pybind11::call_guard()) + .def("describe", &Device::describe) + .def("disable_message_polling", &Device::disableMessagePolling, pybind11::call_guard()) + .def("enable_message_polling", &Device::enableMessagePolling, pybind11::call_guard()) + .def("get_current_message_count", &Device::getCurrentMessageCount) + .def("get_gptp_status", &Device::getGPTPStatus, pybind11::arg("timeout") = std::chrono::milliseconds(100), pybind11::call_guard()) + .def("get_messages", [](Device& device) { return device.getMessages(); }, pybind11::call_guard()) + .def("get_polling_message_limit", &Device::getPollingMessageLimit) + .def("get_product_name", &Device::getProductName) + .def("get_rtc", &Device::getRTC, pybind11::call_guard()) + .def("get_script_status", &Device::getScriptStatus, pybind11::call_guard()) + .def("get_serial_number", &Device::getSerialNumber) + .def("get_serial", &Device::getSerial) .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_rtc", &Device::getRTC, pybind11::call_guard()) - .def("set_rtc", &Device::setRTC, pybind11::call_guard()) - .def("describe", &Device::describe) - .def("is_online_supported", &Device::isOnlineSupported) - .def("supports_tc10", &Device::supportsTC10) - .def("request_tc10_wake", &Device::requestTC10Wake, pybind11::call_guard()) - .def("request_tc10_sleep", &Device::requestTC10Sleep, pybind11::call_guard()) .def("get_tc10_status", &Device::getTC10Status, pybind11::call_guard()) - .def("get_gptp_status", &Device::getGPTPStatus, pybind11::arg("timeout") = std::chrono::milliseconds(100), pybind11::call_guard()) - .def("write_macsec_config", &Device::writeMACsecConfig) - .def("__repr__", &Device::describe); + .def("get_type", &Device::getType) + .def("go_offline", &Device::goOffline, pybind11::call_guard()) + .def("go_online", &Device::goOnline, pybind11::call_guard()) + .def("is_message_polling_enabled", &Device::isMessagePollingEnabled) + .def("is_online_supported", &Device::isOnlineSupported) + .def("is_online", &Device::isOnline) + .def("is_open", &Device::isOpen) + .def("open", [](Device& device) { return device.open(); }, pybind11::call_guard()) + .def("prepare_script_load", &Device::prepareScriptLoad, pybind11::call_guard()) + .def("remove_message_callback", &Device::removeMessageCallback, pybind11::call_guard()) + .def("request_tc10_sleep", &Device::requestTC10Sleep, pybind11::call_guard()) + .def("request_tc10_wake", &Device::requestTC10Wake, pybind11::call_guard()) + .def("set_polling_message_limit", &Device::setPollingMessageLimit) + .def("set_rtc", &Device::setRTC, pybind11::call_guard()) + .def("start_script", &Device::startScript, pybind11::call_guard()) + .def("stop_script", &Device::stopScript, pybind11::call_guard()) + .def("supports_tc10", &Device::supportsTC10) + .def("transmit", pybind11::overload_cast>(&Device::transmit), pybind11::call_guard()) + .def("upload_coremini", [](Device& device, std::string& path, Disk::MemoryType memType) { std::ifstream ifs(path, std::ios::binary); return device.uploadCoremini(ifs, memType); }, pybind11::call_guard()) + .def("write_macsec_config", &Device::writeMACsecConfig, pybind11::call_guard()); } } // namespace icsneo diff --git a/bindings/python/icsneopy/disk/diskdriver.cpp b/bindings/python/icsneopy/disk/diskdriver.cpp new file mode 100644 index 0000000..49169fb --- /dev/null +++ b/bindings/python/icsneopy/disk/diskdriver.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +#include "icsneo/disk/diskdriver.h" + +namespace icsneo { + +void init_diskdriver(pybind11::module_& m) { + auto disk = m.def_submodule("disk"); + pybind11::enum_(disk, "Access") + .value("None", Disk::Access::None) + .value("EntireCard", Disk::Access::EntireCard) + .value("VSA", Disk::Access::VSA); + pybind11::enum_(disk, "MemoryType") + .value("Flash", Disk::MemoryType::Flash) + .value("SD", Disk::MemoryType::SD); +} + +} // namespace icsneo diff --git a/bindings/python/icsneopy/icsneocpp.cpp b/bindings/python/icsneopy/icsneocpp.cpp index 2260f35..8acf5cd 100644 --- a/bindings/python/icsneopy/icsneocpp.cpp +++ b/bindings/python/icsneopy/icsneocpp.cpp @@ -21,6 +21,8 @@ void init_gptpstatusmessage(pybind11::module_&); void init_mdiomessage(pybind11::module_&); void init_ethernetstatusmessage(pybind11::module_&); void init_macsecmessage(pybind11::module_&); +void init_scriptstatusmessage(pybind11::module_&); +void init_diskdriver(pybind11::module_&); void init_device(pybind11::module_&); void init_messagefilter(pybind11::module_&); void init_messagecallback(pybind11::module_&); @@ -47,8 +49,10 @@ PYBIND11_MODULE(icsneopy, m) { init_mdiomessage(m); init_ethernetstatusmessage(m); init_macsecmessage(m); + init_scriptstatusmessage(m); init_messagefilter(m); init_messagecallback(m); + init_diskdriver(m); init_device(m); m.def("find_all_devices", &FindAllDevices); diff --git a/pyproject.toml b/pyproject.toml index 11abae7..78fdd8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,3 +48,6 @@ local_scheme = "no-local-version" LIBICSNEO_ENABLE_BINDINGS_PYTHON = true LIBICSNEO_ENABLE_TCP = true CMAKE_MSVC_RUNTIME_LIBRARY = "MultiThreaded" + +[tool.cibuildwheel] +skip = "pp*"