Skip to content

Commit

Permalink
Merge branch 'issue_365__add_python_binding' into 'main'
Browse files Browse the repository at this point in the history
Added python binding methods

See merge request syntron/support/csr/ifm3d/ifm3d!435
  • Loading branch information
vksgaikwad3 committed Jan 8, 2025
2 parents 1ece903 + ccb5008 commit 70efd52
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- Added missing Python binding methods
- Added support for Python 3.13 and dropped support for Python 3.8.10
- Added support for Ubuntu `24.04` and dropped support for Ubuntu `18.04`

Expand Down
50 changes: 50 additions & 0 deletions modules/pybind11/src/bindings/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,34 @@

#include <pybind11/pybind11.h>

void
bind_ifmnetworkdevice(pybind11::module_& m)
{
py::class_<ifm3d::IFMNetworkDevice>(m, "IFMNetworkDevice")
.def(py::init<std::vector<unsigned char>&, const std::string&>(),
py::arg("data"),
py::arg("ip_address_via_interface"))

.def_property_readonly("ip_address",
&ifm3d::IFMNetworkDevice::GetIPAddress)
.def_property_readonly("mac_address",
&ifm3d::IFMNetworkDevice::GetMACAddress)
.def_property_readonly("netmask", &ifm3d::IFMNetworkDevice::GetNetmask)
.def_property_readonly("gateway", &ifm3d::IFMNetworkDevice::GetGateway)
.def_property_readonly("port", &ifm3d::IFMNetworkDevice::GetPort)
.def_property_readonly("flag", &ifm3d::IFMNetworkDevice::GetFlag)
.def_property_readonly("host_name", &ifm3d::IFMNetworkDevice::GetHostName)
.def_property_readonly("device_name",
&ifm3d::IFMNetworkDevice::GetDeviceName)
.def_property_readonly("vendor_id", &ifm3d::IFMNetworkDevice::GetVendorId)
.def_property_readonly("device_id", &ifm3d::IFMNetworkDevice::GetDeviceId)
.def_property_readonly("found_via", &ifm3d::IFMNetworkDevice::GetFoundVia);
}

void
bind_device(pybind11::module_& m)
{
bind_ifmnetworkdevice(m);
// clang-format off
py::class_<ifm3d::Device, ifm3d::Device::Ptr> device(
m, "Device",
Expand Down Expand Up @@ -329,6 +354,31 @@ bind_device(pybind11::module_& m)
as descriptive as possible as to the specific error that has
occured.
)");

device.def(
"device_discovery", &ifm3d::Device::DeviceDiscovery,
R"(
Discover the list of devices in the network.
Returns:
list[dict]: A list of dictionaries, each containing the device's
IP address, MAC address and type.
)");

device.def(
"set_temp_ip_address",
&ifm3d::Device::SetTempIPAddress,
R"(
Set temporary IP address
Parameters
----------
mac : string
MAC address of the device
temp_ip : string
Temporary IP addres of the device
)");
// clang-format on
}

Expand Down

0 comments on commit 70efd52

Please sign in to comment.