.. _program_listing_file_src_adi_iio.cpp: Program Listing for File adi_iio.cpp ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/adi_iio.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2025 Analog Devices, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include #include "adi_iio/srv/attr_read_string.hpp" #include "adi_iio/srv/attr_write_string.hpp" #include "adi_iio/iio_node.hpp" int main(int argc, char ** argv) { rclcpp::init(argc, argv); std::shared_ptr node = std::make_shared(); if (!node->initialized()) { RCLCPP_FATAL(rclcpp::get_logger("rclcpp"), "Node initialization failed."); return EXIT_FAILURE; // Fail if the node isn't properly initialized } node->initBuffers(); rclcpp::Service::SharedPtr attrReadSrv = node->create_service( std::string(node->get_name()) + "/AttrReadString", std::bind(&IIONode::attrReadSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr attrWriteSrv = node->create_service( std::string(node->get_name()) + "/AttrWriteString", std::bind(&IIONode::attrWriteSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr attrEnableTopicSrv = node->create_service( std::string(node->get_name()) + "/AttrEnableTopic", std::bind(&IIONode::attrEnableTopicSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr attrDisableTopicSrv = node->create_service( std::string(node->get_name()) + "/AttrDisableTopic", std::bind(&IIONode::attrDisableTopicSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffReadSrv = node->create_service( std::string(node->get_name()) + "/BufferRead", std::bind(&IIONode::buffReadSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffWriteSrv = node->create_service( std::string(node->get_name()) + "/BufferWrite", std::bind(&IIONode::buffWriteSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffCreateSrv = node->create_service( std::string(node->get_name()) + "/BufferCreate", std::bind(&IIONode::buffCreateSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffDestroySrv = node->create_service( std::string(node->get_name()) + "/BufferDestroy", std::bind(&IIONode::buffDestroySrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffRefillSrv = node->create_service( std::string(node->get_name()) + "/BufferRefill", std::bind(&IIONode::buffRefillSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffEnableTopicSrv = node->create_service( std::string(node->get_name()) + "/BufferEnableTopic", std::bind(&IIONode::buffEnableTopicSrv, node, std::placeholders::_1, std::placeholders::_2)); rclcpp::Service::SharedPtr buffDisableTopicSrv = node->create_service( std::string(node->get_name()) + "/BufferDisableTopic", std::bind(&IIONode::buffDisableTopicSrv, node, std::placeholders::_1, std::placeholders::_2)); RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "IIO Node"); rclcpp::spin(node); rclcpp::shutdown(); return 0; }