diff --git a/source_common/comms/comms_interface.hpp b/source_common/comms/comms_interface.hpp index 8d5890b..187bf31 100644 --- a/source_common/comms/comms_interface.hpp +++ b/source_common/comms/comms_interface.hpp @@ -70,7 +70,7 @@ class CommsInterface * * @return Returns @c true if connected, @c false otherwise. */ - virtual bool is_connected() = 0; + virtual bool isConnected() = 0; /** * @brief Get the service endpoint address for the named service. @@ -79,7 +79,7 @@ class CommsInterface * * @return The service address, or @c NO_ENDPOINT if service is not found. */ - virtual EndpointID get_endpoint_id( + virtual EndpointID getEndpointID( const std::string& name) = 0; /** @@ -91,7 +91,7 @@ class CommsInterface * @param endpoint The address of the destination service. * @param data The data to transmit. */ - virtual void tx_async( + virtual void txAsync( EndpointID endpoint, std::unique_ptr data) = 0; @@ -122,7 +122,7 @@ class CommsInterface * * @return The response message data payload. */ - virtual std::unique_ptr tx_rx( + virtual std::unique_ptr txRx( EndpointID endpoint, std::unique_ptr data) = 0; }; diff --git a/source_common/comms/comms_message.hpp b/source_common/comms/comms_message.hpp index b88fa24..4dbb88c 100644 --- a/source_common/comms/comms_message.hpp +++ b/source_common/comms/comms_message.hpp @@ -59,10 +59,10 @@ enum class MessageType: uint8_t { */ typedef struct __attribute__((packed)) { - uint8_t message_type; // Is this tx_async (0), tx (1), or tx_rx (2)? - uint8_t endpoint_id; // The endpoint service address. - uint64_t message_id; // The unique message ID for a tx_rx pair. - uint32_t payload_size; // The size of the payload in bytes. + uint8_t messageType; // Is this tx_async (0), tx (1), or tx_rx (2)? + uint8_t endpointID; // The endpoint service address. + uint64_t messageID; // The unique message ID for a tx_rx pair. + uint32_t payloadSize; // The size of the payload in bytes. } MessageHeader; /** @@ -74,53 +74,53 @@ class Message: public Task /** * @brief Construct a new message. * - * @param endpoint_id The destination endpoint. - * @param message_type The type of the message. - * @param message_id The sequence ID of the message. - * @param transmit_data The data to transmit. + * @param endpointID The destination endpoint. + * @param messageType The type of the message. + * @param messageID The sequence ID of the message. + * @param transmitData The data to transmit. */ Message( - EndpointID endpoint_id, - MessageType message_type, - MessageID message_id, - std::unique_ptr transmit_data) : - endpoint_id(endpoint_id), - message_type(message_type), - message_id(message_id), - transmit_data(std::move(transmit_data)) { } + EndpointID endpointID, + MessageType messageType, + MessageID messageID, + std::unique_ptr transmitData) : + endpointID(endpointID), + messageType(messageType), + messageID(messageID), + transmitData(std::move(transmitData)) { } /** * @brief The type of the message. */ - EndpointID endpoint_id; + EndpointID endpointID; /** * @brief The type of the message. */ - MessageType message_type; + MessageType messageType; /** * @brief The sequence ID of the message. * - * Only required if @c message_type is @c TX_RX and we have to match a + * Only required if @c messageType is @c TX_RX and we have to match a * response to a triggering message. */ - MessageID message_id; + MessageID messageID; /** * @brief The data to transmit. * * Can be reset and data discarded once the data is transmitted. */ - std::unique_ptr transmit_data; + std::unique_ptr transmitData; /** * @brief The data that was received. * - * Only present if @c message_type is @c TX_RX and we have received a + * Only present if @c messageType is @c TX_RX and we have received a * response from the host. */ - std::unique_ptr response_data; + std::unique_ptr responseData; }; } diff --git a/source_common/comms/comms_module.cpp b/source_common/comms/comms_module.cpp index a0eddec..b0fbcd1 100644 --- a/source_common/comms/comms_module.cpp +++ b/source_common/comms/comms_module.cpp @@ -43,7 +43,7 @@ namespace Comms /** See header for documentation. */ CommsModule::CommsModule( - const std::string& domain_address + const std::string& domainAddress ) { sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) @@ -52,17 +52,17 @@ CommsModule::CommsModule( return; } - struct sockaddr_un serv_addr {}; - serv_addr.sun_family = AF_UNIX; + struct sockaddr_un servAddr {}; + servAddr.sun_family = AF_UNIX; // Copy the domain address, inserting leading NUL needed for abstract UDS - std::strcpy(serv_addr.sun_path + 1, domain_address.c_str()); - serv_addr.sun_path[0] = '\0'; + std::strcpy(servAddr.sun_path + 1, domainAddress.c_str()); + servAddr.sun_path[0] = '\0'; int conn = connect( sockfd, - reinterpret_cast(&serv_addr), - sizeof(serv_addr)); + reinterpret_cast(&servAddr), + sizeof(servAddr)); if (conn != 0) { std::cout << " - ERROR: Client connection failed" << std::endl; @@ -77,7 +77,7 @@ CommsModule::CommsModule( /** See header for documentation. */ CommsModule::CommsModule( - const std::string& host_address, + const std::string& hostAddress, int port ) { sockfd = socket(AF_INET, SOCK_STREAM, 0); @@ -87,15 +87,15 @@ CommsModule::CommsModule( return; } - struct sockaddr_in serv_addr {}; - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(port); - serv_addr.sin_addr.s_addr = inet_addr(host_address.c_str()); + struct sockaddr_in servAddr {}; + servAddr.sin_family = AF_INET; + servAddr.sin_port = htons(port); + servAddr.sin_addr.s_addr = inet_addr(hostAddress.c_str()); int conn = connect( sockfd, - reinterpret_cast(&serv_addr), - sizeof(serv_addr)); + reinterpret_cast(&servAddr), + sizeof(servAddr)); if (conn != 0) { std::cout << " - ERROR: Client connection failed" << std::endl; @@ -132,21 +132,21 @@ CommsModule::~CommsModule() } /** See header for documentation. */ -bool CommsModule::is_connected() +bool CommsModule::isConnected() { return sockfd >= 0; } /** See header for documentation. */ -EndpointID CommsModule::get_endpoint_id( +EndpointID CommsModule::getEndpointID( const std::string& name ) { - std::lock_guard lock(registry_lock); + std::lock_guard lock(registryLock); if (registry.empty()) { // Request the registry from the host auto data = std::make_unique>(); - auto resp = tx_rx(0, std::move(data)); + auto resp = txRx(0, std::move(data)); // Process the response while (resp->size()) @@ -192,7 +192,7 @@ EndpointID CommsModule::get_endpoint_id( } /** See header for documentation. */ -void CommsModule::tx_async( +void CommsModule::txAsync( EndpointID endpoint, std::unique_ptr data ) { @@ -202,7 +202,7 @@ void CommsModule::tx_async( 0, std::move(data)); - enqueue_message(std::move(message)); + enqueueMessage(std::move(message)); } /** See header for documentation. */ @@ -216,44 +216,44 @@ void CommsModule::tx( 0, std::move(data)); - enqueue_message(message); + enqueueMessage(message); message->wait(); } /** See header for documentation. */ -std::unique_ptr CommsModule::tx_rx( +std::unique_ptr CommsModule::txRx( EndpointID endpoint, std::unique_ptr data ) { auto message = std::make_shared( endpoint, MessageType::TX_RX, - assign_message_id(), + assignMessageID(), std::move(data)); - enqueue_message(message); + enqueueMessage(message); message->wait(); - return std::move(message->response_data); + return std::move(message->responseData); } /** See header for documentation. */ -MessageID CommsModule::assign_message_id() +MessageID CommsModule::assignMessageID() { - return next_message_id.fetch_add(1, std::memory_order_relaxed); + return nextMessageID.fetch_add(1, std::memory_order_relaxed); } /** See header for documentation. */ -void CommsModule::enqueue_message( +void CommsModule::enqueueMessage( std::shared_ptr message ) { - message_queue.put(std::move(message)); + messageQueue.put(std::move(message)); } /** See header for documentation. */ -std::shared_ptr CommsModule::dequeue_message() +std::shared_ptr CommsModule::dequeueMessage() { - return message_queue.get(); + return messageQueue.get(); } } diff --git a/source_common/comms/comms_module.hpp b/source_common/comms/comms_module.hpp index 8ee4ecb..d29f945 100644 --- a/source_common/comms/comms_module.hpp +++ b/source_common/comms/comms_module.hpp @@ -99,19 +99,19 @@ class CommsModule: public CommsInterface * here must NOT include the leading NUL character needed to create an * abstract domain socket. * - * @param domain_address The unix domain address to use. + * @param domainAddress The unix domain address to use. */ CommsModule( - const std::string& domain_address); + const std::string& domainAddress); /** * @brief Construct a new instance using a TCP/IP socket. * - * @param host_address The host name or IP address to use. - * @param port The port number to use. + * @param hostAddress The host name or IP address to use. + * @param port The port number to use. */ CommsModule( - const std::string& host_address, + const std::string& hostAddress, int port); /** @@ -124,14 +124,14 @@ class CommsModule: public CommsInterface virtual ~CommsModule(); /** See @c comms_interface.hpp for documentation. */ - virtual bool is_connected(); + virtual bool isConnected(); /** See @c comms_interface.hpp for documentation. */ - virtual EndpointID get_endpoint_id( + virtual EndpointID getEndpointID( const std::string& name); /** See @c comms_interface.hpp for documentation. */ - virtual void tx_async( + virtual void txAsync( EndpointID endpoint, std::unique_ptr data); @@ -141,7 +141,7 @@ class CommsModule: public CommsInterface std::unique_ptr data); /** See @c comms_interface.hpp for documentation. */ - virtual std::unique_ptr tx_rx( + virtual std::unique_ptr txRx( EndpointID endpoint, std::unique_ptr data); @@ -155,14 +155,14 @@ class CommsModule: public CommsInterface * * @return The message ID nonce to use. */ - MessageID assign_message_id(); + MessageID assignMessageID(); /** * @brief Add a message to the end of outbound message task queue. * * @param message The message to queue. */ - void enqueue_message( + void enqueueMessage( std::shared_ptr message); /** @@ -170,14 +170,14 @@ class CommsModule: public CommsInterface * * @return The message to send. */ - std::shared_ptr dequeue_message(); + std::shared_ptr dequeueMessage(); /** * @brief Get the host service endpoint list. * * @return The message to send. */ - void get_host_service_endpoints(); + void getHostServiceEndpoints(); private: /** @@ -186,14 +186,14 @@ class CommsModule: public CommsInterface int sockfd { -1 }; /** - * @brief The last message ID nonce used. + * @brief The next message ID nonce to use. */ - std::atomic next_message_id { 1 }; + std::atomic nextMessageID { 1 }; /** * @brief The FIFO queue of messages to send. */ - TaskQueue> message_queue; + TaskQueue> messageQueue; /** * @brief The transmitter - runs with its own worker thread. @@ -208,7 +208,7 @@ class CommsModule: public CommsInterface /** * @brief Lock protecting the registry. */ - std::mutex registry_lock; + std::mutex registryLock; /** * @brief Host endpoint registry. diff --git a/source_common/comms/comms_receiver.cpp b/source_common/comms/comms_receiver.cpp index f685e85..7a4b9ea 100644 --- a/source_common/comms/comms_receiver.cpp +++ b/source_common/comms/comms_receiver.cpp @@ -43,141 +43,141 @@ Receiver::Receiver( CommsModule& parent ) : parent(parent) { - int pipe_err = pipe(stop_request_pipe); + int pipe_err = pipe(stopRequestPipe); if (pipe_err) { std::cout << " - ERROR: Client pipe create failed" << std::endl; } // Create and start a worker thread - worker = std::thread(&Receiver::run_receiver, this); + worker = std::thread(&Receiver::runReceiver, this); } /** See header for documentation. */ Receiver::~Receiver() { // Stop the worker thread if it's not stopped already - if (!stop_requested) + if (!stopRequested) { stop(); } // Close the pipes - close(stop_request_pipe[0]); - close(stop_request_pipe[1]); + close(stopRequestPipe[0]); + close(stopRequestPipe[1]); } /** See header for documentation. */ void Receiver::stop() { // Mark the engine as stopping - stop_requested = true; + stopRequested = true; // Poke the pipe to wake the worker thread if it is blocked on a read int data = 0xdead; - write(stop_request_pipe[1], &data, sizeof(int)); + write(stopRequestPipe[1], &data, sizeof(int)); // Join on the worker thread worker.join(); } /** See header for documentation. */ -void Receiver::park_message( +void Receiver::parkMessage( std::shared_ptr message ) { - std::lock_guard lock(parking_lock); - parking_buffer.insert({ message->message_id, std::move(message) }); + std::lock_guard lock(parkingLock); + parkingBuffer.insert({ message->messageID, std::move(message) }); } /** See header for documentation. */ -void Receiver::run_receiver() +void Receiver::runReceiver() { - while (!stop_requested) + while (!stopRequested) { - bool data_ok; + bool dataOk; // Read the fixed size message header MessageHeader header; - data_ok = receive_data(reinterpret_cast(&header), sizeof(header)); - if (!data_ok) + dataOk = receiveData(reinterpret_cast(&header), sizeof(header)); + if (!dataOk) { break; } // Read the a payload based on the data size in the header - size_t payload_size = header.payload_size; + size_t payload_size = header.payloadSize; auto payload = std::make_unique(payload_size); - data_ok = receive_data(payload->data(), payload_size); - if (!data_ok) + dataOk = receiveData(payload->data(), payload_size); + if (!dataOk) { break; } - wake_message(header.message_id, std::move(payload)); + wakeMessage(header.messageID, std::move(payload)); } } /** See header for documentation. */ -void Receiver::wake_message( - MessageID message_id, +void Receiver::wakeMessage( + MessageID messageID, std::unique_ptr data ) { - std::lock_guard lock(parking_lock); + std::lock_guard lock(parkingLock); // Handle message not found ... - if (parking_buffer.count(message_id) == 0) + if (parkingBuffer.count(messageID) == 0) { - std::cout << " - ERROR: Cln: Message " << message_id << " not found" << std::endl; + std::cout << " - ERROR: Cln: Message " << messageID << " not found" << std::endl; return; } // Extract the message and remove from the parking buffer map - auto message = parking_buffer[message_id]; - parking_buffer.erase(message_id); + auto message = parkingBuffer[messageID]; + parkingBuffer.erase(messageID); // Notify the sending thread that the response is available - message->response_data = std::move(data); + message->responseData = std::move(data); message->notify(); } /** See header for documentation. */ -bool Receiver::receive_data( +bool Receiver::receiveData( uint8_t* data, - size_t data_size + size_t dataSize ) { int sockfd = parent.sockfd; - int pipefd = stop_request_pipe[0]; - int max_fd = std::max(sockfd, pipefd); + int pipefd = stopRequestPipe[0]; + int maxfd = std::max(sockfd, pipefd); - while (data_size) + while (dataSize) { - fd_set read_fds; - FD_ZERO(&read_fds); - FD_SET(sockfd, &read_fds); - FD_SET(pipefd, &read_fds); + fd_set readfds; + FD_ZERO(&readfds); + FD_SET(sockfd, &readfds); + FD_SET(pipefd, &readfds); - int sel_resp = select(max_fd + 1, &read_fds, NULL, NULL, NULL); + int selResp = select(maxfd + 1, &readfds, NULL, NULL, NULL); // Error - if (sel_resp <= 0) + if (selResp <= 0) { return false; } // Received a stop event on the pipe so exit - if (FD_ISSET(pipefd, &read_fds)) + if (FD_ISSET(pipefd, &readfds)) { return false; } // Otherwise keep reading bytes until we've read them all - int read_bytes = read(sockfd, data, data_size); - if (read_bytes <= 0) + int readBytes = read(sockfd, data, dataSize); + if (readBytes <= 0) { return false; } - data += read_bytes; - data_size -= read_bytes; + data += readBytes; + dataSize -= readBytes; } return true; diff --git a/source_common/comms/comms_receiver.hpp b/source_common/comms/comms_receiver.hpp index 498efbf..5a84702 100644 --- a/source_common/comms/comms_receiver.hpp +++ b/source_common/comms/comms_receiver.hpp @@ -72,36 +72,36 @@ class Receiver * * @param message The message waiting for a response. */ - void park_message( + void parkMessage( std::shared_ptr message); private: /** * @brief Entrypoint for the worker thread. */ - void run_receiver(); + void runReceiver(); /** * @brief Wake a message with the given message ID. * - * @param message_id The message to wake. - * @param data The response data payload from the host. + * @param messageID The message to wake. + * @param data The response data payload from the host. */ - void wake_message( - MessageID message_id, + void wakeMessage( + MessageID messageID, std::unique_ptr data); /** * @brief Receive N bytes of data from the socket. * - * @param data The data storage to write to. - * @param data_size The number of bytes expected in the message. + * @param data The data storage to write to. + * @param dataSize The number of bytes expected in the message. * * @return @c true if we received a message, @c false otherwise. */ - bool receive_data( + bool receiveData( uint8_t* data, - size_t data_size); + size_t dataSize); private: /** @@ -117,24 +117,24 @@ class Receiver /** * @brief Has the worker been asked to stop? */ - std::atomic stop_requested; + std::atomic stopRequested; /** * @brief Pipe used to unblock the read socket rather than use timeouts. * * Pipe fds are not duplex: [0] is read fd, [1] is write fd. */ - int stop_request_pipe[2] {-1, -1}; + int stopRequestPipe[2] {-1, -1}; /** * @brief Lock protecting the parking buffer. */ - std::mutex parking_lock; + std::mutex parkingLock; /** * @brief Parking buffer holding messages waiting for responses. */ - std::unordered_map> parking_buffer; + std::unordered_map> parkingBuffer; }; } \ No newline at end of file diff --git a/source_common/comms/comms_transmitter.cpp b/source_common/comms/comms_transmitter.cpp index d1b55bc..7ee224d 100644 --- a/source_common/comms/comms_transmitter.cpp +++ b/source_common/comms/comms_transmitter.cpp @@ -42,44 +42,44 @@ Transmitter::Transmitter( ) : parent(parent) { // Create and start a worker thread - worker = std::thread(&Transmitter::run_transmitter, this); + worker = std::thread(&Transmitter::runTransmitter, this); } /** See header for documentation. */ Transmitter::~Transmitter() { // Stop the worker thread if it's not stopped already - if (!stop_requested) + if (!stopRequested) { stop(); } } /** See header for documentation. */ -void Transmitter::run_transmitter() +void Transmitter::runTransmitter() { // Keep looping until we are told to stop and message queue is empty - while (!stop_requested || !parent.message_queue.is_empty()) + while (!stopRequested || !parent.messageQueue.is_empty()) { - auto message = parent.dequeue_message(); + auto message = parent.dequeueMessage(); // Stop messages are just used to wake the thread so do nothing - if (message->message_type == MessageType::STOP) + if (message->messageType == MessageType::STOP) { continue; } // TX_RX messages need to be parked waiting for a response before // we send the message to avoid a race condition - if (message->message_type == MessageType::TX_RX) + if (message->messageType == MessageType::TX_RX) { - parent.receiver->park_message(message); + parent.receiver->parkMessage(message); } - send_message(*message); + sendMessage(*message); // Notify TX messages to wake up the caller - if (message->message_type == MessageType::TX) + if (message->messageType == MessageType::TX) { message->notify(); } @@ -90,56 +90,56 @@ void Transmitter::run_transmitter() void Transmitter::stop() { // Mark the engine as stopping - stop_requested = true; + stopRequested = true; // Use a dummy message to wake worker thread if blocked on the queue - auto stop_data = std::make_unique(); + auto stopData = std::make_unique(); auto message = std::make_shared( - 0, MessageType::STOP, 0, std::move(stop_data)); - parent.enqueue_message(message); + 0, MessageType::STOP, 0, std::move(stopData)); + parent.enqueueMessage(message); // Join on the worker thread worker.join(); } /** See header for documentation. */ -void Transmitter::send_message( +void Transmitter::sendMessage( const Message& message ) { - uint8_t* data = message.transmit_data->data(); - size_t data_size = message.transmit_data->size(); + uint8_t* data = message.transmitData->data(); + size_t dataSize = message.transmitData->size(); MessageHeader header; - header.message_type = static_cast(message.message_type); - header.endpoint_id = message.endpoint_id; - header.message_id = message.message_id; - header.payload_size = static_cast(data_size); + header.messageType = static_cast(message.messageType); + header.endpointID = message.endpointID; + header.messageID = message.messageID; + header.payloadSize = static_cast(dataSize); // Send the packet header - uint8_t* header_data = reinterpret_cast(&header); - send_data(header_data, sizeof(header)); + uint8_t* headerData = reinterpret_cast(&header); + sendData(headerData, sizeof(header)); // Send the packet data - send_data(data, data_size); + sendData(data, dataSize); } /** See header for documentation. */ -void Transmitter::send_data( +void Transmitter::sendData( uint8_t* data, - size_t data_size + size_t dataSize ) { - while(data_size) + while(dataSize) { - ssize_t sent_size = send(parent.sockfd, data, data_size, 0); + ssize_t sentSize = send(parent.sockfd, data, dataSize, 0); // An error occurred or server disconnected - if (sent_size < 0) + if (sentSize < 0) { return; } // Update to indicate remaining data - data_size -= sent_size; - data += sent_size; + dataSize -= sentSize; + data += sentSize; } } diff --git a/source_common/comms/comms_transmitter.hpp b/source_common/comms/comms_transmitter.hpp index 576778e..13af90b 100644 --- a/source_common/comms/comms_transmitter.hpp +++ b/source_common/comms/comms_transmitter.hpp @@ -71,25 +71,25 @@ class Transmitter /** * @brief Entrypoint for the worker thread. */ - void run_transmitter(); + void runTransmitter(); /** * @brief Send a message on the socket. * * @param message The message to send. */ - void send_message( + void sendMessage( const Message& message); /** * @brief Send N bytes of data to the socket. * - * @param data The data to send. - * @param data_size The number of bytes in the data. + * @param data The data to send. + * @param dataSize The number of bytes in the data. */ - void send_data( + void sendData( uint8_t* data, - size_t data_size); + size_t dataSize); private: /** @@ -105,7 +105,7 @@ class Transmitter /** * @brief Has the worker been asked to stop? */ - std::atomic stop_requested; + std::atomic stopRequested; }; } diff --git a/source_common/comms/test/comms_test_server.cpp b/source_common/comms/test/comms_test_server.cpp index 2ae0c62..947d6d3 100644 --- a/source_common/comms/test/comms_test_server.cpp +++ b/source_common/comms/test/comms_test_server.cpp @@ -42,232 +42,232 @@ namespace CommsTest /** See header for documentation. */ CommsTestServer::CommsTestServer( - const std::string& domain_address + const std::string& domainAddress ) { - int pipe_err = pipe(stop_request_pipe); - if (pipe_err) + int pipeErr = pipe(stopRequestPipe); + if (pipeErr) { std::cout << " - ERROR: Svr pipe create failed" << std::endl; return; } - listen_sockfd = socket(AF_UNIX, SOCK_STREAM, 0); - if (listen_sockfd < 0) + listenSockfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (listenSockfd < 0) { std::cout << " - ERROR: Svr socket create failed" << std::endl; return; } // Build the address to listen on - struct sockaddr_un serv_addr {}; - serv_addr.sun_family = AF_UNIX; + struct sockaddr_un servAddr {}; + servAddr.sun_family = AF_UNIX; // Copy the domain address, inserting leading NUL needed for abstract UDS - std::strcpy(serv_addr.sun_path + 1, domain_address.c_str()); - serv_addr.sun_path[0] = '\0'; + std::strcpy(servAddr.sun_path + 1, domainAddress.c_str()); + servAddr.sun_path[0] = '\0'; // Bind the socket to the address - int bind_err = bind( - listen_sockfd, - reinterpret_cast(&serv_addr), + int bindErr = bind( + listenSockfd, + reinterpret_cast(&servAddr), sizeof(struct sockaddr_un)); - if (bind_err) + if (bindErr) { std::cout << " - ERROR: Svr socket bind failed" << std::endl; - close(listen_sockfd); - listen_sockfd = -1; + close(listenSockfd); + listenSockfd = -1; return; } // Listen on the socket - int listen_err = listen(listen_sockfd, 5); - if(listen_err) + int listenErr = listen(listenSockfd, 5); + if(listenErr) { std::cout << " - ERROR: Svr socket listen failed" << std::endl; - close(listen_sockfd); - listen_sockfd = -1; + close(listenSockfd); + listenSockfd = -1; return; } // Create and start a worker thread so we can respond while the test // thread is blocked waiting for a response to a tx_rx message - worker = std::thread(&CommsTestServer::run_server, this); + worker = std::thread(&CommsTestServer::runServer, this); } /** See header for documentation. */ CommsTestServer::CommsTestServer( int port ) { - int pipe_err = pipe(stop_request_pipe); - if (pipe_err) + int pipeErr = pipe(stopRequestPipe); + if (pipeErr) { std::cout << " - ERROR: Svr pipe create failed" << std::endl; return; } - listen_sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (listen_sockfd < 0) + listenSockfd = socket(AF_INET, SOCK_STREAM, 0); + if (listenSockfd < 0) { std::cout << " - ERROR: Svr socket create failed" << std::endl; return; } int reuse = 1; - int result = setsockopt(listen_sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); + int result = setsockopt(listenSockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); if (result < 0) { std::cout << " - WARN: Svr socket setsockopt failed" << std::endl; } - struct sockaddr_in serv_addr {}; - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(port); - serv_addr.sin_addr.s_addr = INADDR_ANY; + struct sockaddr_in servAddr {}; + servAddr.sin_family = AF_INET; + servAddr.sin_port = htons(port); + servAddr.sin_addr.s_addr = INADDR_ANY; // Bind the socket to the address - int bind_err = bind( - listen_sockfd, - reinterpret_cast(&serv_addr), + int bindErr = bind( + listenSockfd, + reinterpret_cast(&servAddr), sizeof(struct sockaddr_in)); - if (bind_err) + if (bindErr) { std::cout << " - ERROR: Svr socket bind failed " << std::endl; - close(listen_sockfd); - listen_sockfd = -1; + close(listenSockfd); + listenSockfd = -1; return; } // Listen on the socket - int listen_err = listen(listen_sockfd, 5); - if(listen_err) + int listenErr = listen(listenSockfd, 5); + if(listenErr) { std::cout << " - ERROR: Svr socket listen failed" << std::endl; - close(listen_sockfd); - listen_sockfd = -1; + close(listenSockfd); + listenSockfd = -1; return; } // Create and start a worker thread so we can respond while the test // thread is blocked waiting for a response to a tx_rx message - worker = std::thread(&CommsTestServer::run_server, this); + worker = std::thread(&CommsTestServer::runServer, this); } /** See header for documentation. */ CommsTestServer::~CommsTestServer() { // Stop the worker thread if it's not stopped already - if (!stop_requested) + if (!stopRequested) { stop(); } // Close all the sockets - if (listen_sockfd > 0) + if (listenSockfd > 0) { - close(listen_sockfd); + close(listenSockfd); } // Close the pipes - close(stop_request_pipe[0]); - close(stop_request_pipe[1]); + close(stopRequestPipe[0]); + close(stopRequestPipe[1]); } /** See header for documentation. */ void CommsTestServer::stop() { // Mark the engine as stopping - stop_requested = true; + stopRequested = true; // Wake the worker thread if it is blocked on socket read int data = 0xdead; - write(stop_request_pipe[1], &data, sizeof(int)); + write(stopRequestPipe[1], &data, sizeof(int)); // Wait for the worker to finish worker.join(); } /** See header for documentation. */ -void CommsTestServer::run_server() +void CommsTestServer::runServer() { - int data_sockfd = accept(listen_sockfd, NULL, NULL); - if(data_sockfd < 0) + int dataSockfd = accept(listenSockfd, NULL, NULL); + if(dataSockfd < 0) { std::cout << " - ERROR: Svr socket accept failed" << std::endl; - close(listen_sockfd); + close(listenSockfd); return; } - while (!stop_requested) + while (!stopRequested) { - bool data_ok; + bool dataOk; // Read the fixed size message header Comms::MessageHeader header; - data_ok = receive_data(data_sockfd, reinterpret_cast(&header), sizeof(header)); - if (!data_ok) + dataOk = receiveData(dataSockfd, reinterpret_cast(&header), sizeof(header)); + if (!dataOk) { break; } // Read the a payload based on the data size in the header - size_t payload_size = header.payload_size; - auto payload = std::make_unique(payload_size); - data_ok = receive_data(data_sockfd, payload->data(), payload_size); - if (!data_ok) + size_t payloadSize = header.payloadSize; + auto payload = std::make_unique(payloadSize); + dataOk = receiveData(dataSockfd, payload->data(), payloadSize); + if (!dataOk) { break; } // Store the message for later checking - std::string decoded_payload(payload->begin(), payload->end()); + std::string decodedPayload(payload->begin(), payload->end()); received.emplace_back( - static_cast(header.endpoint_id), - static_cast(header.message_type), + static_cast(header.endpointID), + static_cast(header.messageType), std::move(payload)); // If this is a tx_rx message reverse payload and send it back ... - if (header.message_type == static_cast(Comms::MessageType::TX_RX)) + if (header.messageType == static_cast(Comms::MessageType::TX_RX)) { // Response data is same size as request data so we can reuse header std::vector response_data; - if (decoded_payload.size() > 0) + if (decodedPayload.size() > 0) { - size_t data_len = decoded_payload.size(); + size_t data_len = decodedPayload.size(); for (size_t i = 0; i < data_len; i++) { - response_data.push_back(decoded_payload[data_len - i - 1]); + response_data.push_back(decodedPayload[data_len - i - 1]); } } // Send the packet header - uint8_t* header_data = reinterpret_cast(&header); - send_data(data_sockfd, header_data, sizeof(header)); + uint8_t* headerData = reinterpret_cast(&header); + send_data(dataSockfd, headerData, sizeof(header)); // Send the packet data - send_data(data_sockfd, response_data.data(), payload_size); + send_data(dataSockfd, response_data.data(), payloadSize); } } - close(data_sockfd); + close(dataSockfd); } /** See header for documentation. */ -bool CommsTestServer::receive_data( +bool CommsTestServer::receiveData( int sockfd, uint8_t* data, - size_t data_size + size_t dataSize ) { - int pipefd = stop_request_pipe[0]; - int max_fd = std::max(sockfd, pipefd); + int pipefd = stopRequestPipe[0]; + int maxfd = std::max(sockfd, pipefd); - while (data_size) + while (dataSize) { - fd_set read_fds; - FD_ZERO(&read_fds); - FD_SET(sockfd, &read_fds); - FD_SET(pipefd, &read_fds); + fd_set readfds; + FD_ZERO(&readfds); + FD_SET(sockfd, &readfds); + FD_SET(pipefd, &readfds); - int sel_resp = select(max_fd + 1, &read_fds, NULL, NULL, NULL); + int sel_resp = select(maxfd + 1, &readfds, NULL, NULL, NULL); // Error if (sel_resp <= 0) { @@ -276,22 +276,22 @@ bool CommsTestServer::receive_data( } // Received a stop event on the pipe so exit - if (FD_ISSET(pipefd, &read_fds)) + if (FD_ISSET(pipefd, &readfds)) { return false; } // Otherwise keep reading bytes until we've read them all - int read_bytes = read(sockfd, data, data_size); + int readBytes = read(sockfd, data, dataSize); // Has the client-side of the connection been closed? - if (read_bytes <= 0) + if (readBytes <= 0) { return false; } - data += read_bytes; - data_size -= read_bytes; + data += readBytes; + dataSize -= readBytes; } return true; @@ -301,21 +301,21 @@ bool CommsTestServer::receive_data( void CommsTestServer::send_data( int sockfd, uint8_t* data, - size_t data_size + size_t dataSize ) { - while(data_size) + while(dataSize) { - ssize_t sent_size = send(sockfd, data, data_size, 0); + ssize_t sentSize = send(sockfd, data, dataSize, 0); // An error occurred - if (sent_size < 0) + if (sentSize < 0) { std::cout << " - ERROR: Svr socket send failed" << std::endl; return; } // Update to indicate remaining data - data_size -= sent_size; - data += sent_size; + dataSize -= sentSize; + data += sentSize; } } diff --git a/source_common/comms/test/comms_test_server.hpp b/source_common/comms/test/comms_test_server.hpp index 205c1c5..4cc779d 100644 --- a/source_common/comms/test/comms_test_server.hpp +++ b/source_common/comms/test/comms_test_server.hpp @@ -48,27 +48,27 @@ class TestMessage /** * @brief Construct a new message. * - * @param endpoint_id The destination endpoint. - * @param message_type The type of the message. + * @param endpointID The destination endpoint. + * @param messageType The type of the message. * @param data The received data. */ TestMessage( - Comms::EndpointID endpoint_id, - Comms::MessageType message_type, + Comms::EndpointID endpointID, + Comms::MessageType messageType, std::unique_ptr data) : - endpoint_id(endpoint_id), - message_type(message_type), + endpointID(endpointID), + messageType(messageType), data(std::move(data)) { } /** * @brief The endpoint of the message. */ - Comms::EndpointID endpoint_id; + Comms::EndpointID endpointID; /** * @brief The type of the message. */ - Comms::MessageType message_type; + Comms::MessageType messageType; /** * @brief The received data. @@ -86,10 +86,10 @@ class CommsTestServer * Note that the UDS address given here must exclude the leading NUL, to * avoid it being seen as a zero-length string literal. * - * @param domain_address The unix domain address to use. + * @param domainAddress The unix domain address to use. */ CommsTestServer( - const std::string& domain_address); + const std::string& domainAddress); /** * @brief Construct a new server listening on TCP/IP socket. @@ -117,33 +117,33 @@ class CommsTestServer /** * @brief Entrypoint for the worker thread. */ - void run_server(); + void runServer(); /** * @brief Receive N bytes of data from the socket. * - * @param sockfd The client connection socket. - * @param data The data storage to write to. - * @param data_size The number of bytes expected in the message. + * @param sockfd The client connection socket. + * @param data The data storage to write to. + * @param dataSize The number of bytes expected in the message. * * @return @c true if we received a message, @c false otherwise. */ - bool receive_data( + bool receiveData( int sockfd, uint8_t* data, - size_t data_size); + size_t dataSize); /** * @brief Send N bytes of data to the socket. * - * @param sockfd The client connection socket. - * @param data The data to send. - * @param data_size The number of bytes in the data. + * @param sockfd The client connection socket. + * @param data The data to send. + * @param dataSize The number of bytes in the data. */ void send_data( int sockfd, uint8_t* data, - size_t data_size); + size_t dataSize); public: /** @@ -155,14 +155,14 @@ class CommsTestServer /** * @brief The socket for listening for connections. */ - int listen_sockfd { -1 }; + int listenSockfd { -1 }; /** * @brief Pipe used to unblock the read socket rather than use timeouts. * * Pipe fds are not duplex: [0] is read fd, [1] is write fd. */ - int stop_request_pipe[2] {-1, -1}; + int stopRequestPipe[2] {-1, -1}; /** * @brief The transmitter - runs with its own worker thread. @@ -172,7 +172,7 @@ class CommsTestServer /** * @brief Has the worker been asked to stop? */ - std::atomic stop_requested; + std::atomic stopRequested; }; } diff --git a/source_common/comms/test/unittest_comms.cpp b/source_common/comms/test/unittest_comms.cpp index eb1903c..a37ace7 100644 --- a/source_common/comms/test/unittest_comms.cpp +++ b/source_common/comms/test/unittest_comms.cpp @@ -40,21 +40,21 @@ using namespace CommsTest; -std::unique_ptr make_test_payload( +std::unique_ptr makeTestPayload( const std::string& str ) { auto data = std::make_unique(str.begin(), str.end()); return data; } -std::string decode_test_payload( +std::string decodeTestPayload( std::unique_ptr data ) { std::string str(data->begin(), data->end()); return str; } -std::string decode_test_payload( +std::string decodeTestPayload( TestMessage& msg ) { std::string str(msg.data->begin(), msg.data->end()); @@ -82,13 +82,13 @@ TEST(Comms, test_uds_tx_0b) client.tx(1, std::move(data)); // Ensure server processes the earlier message - data = make_test_payload(""); - client.tx_rx(2, std::move(data)); + data = makeTestPayload(""); + client.txRx(2, std::move(data)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 0); } @@ -99,19 +99,19 @@ TEST(Comms, test_uds_tx_nb) Comms::CommsModule client("commstest"); // Send a non-zero byte payload - auto data = make_test_payload("abcd"); + auto data = makeTestPayload("abcd"); client.tx(2, std::move(data)); // Ensure server processes the earlier message - data = make_test_payload(""); - client.tx_rx(2, std::move(data)); + data = makeTestPayload(""); + client.txRx(2, std::move(data)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 2); + EXPECT_EQ(server.received[0].endpointID, 2); EXPECT_EQ(server.received[0].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[0]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[0]),"abcd"); } /** @brief Test lifecycle with a TX_ASYNC sent message. */ @@ -122,21 +122,21 @@ TEST(Comms, test_uds_tx_async_0b) // Send a zero byte payload auto data = std::make_unique>(); - client.tx_async(1, std::move(data)); + client.txAsync(1, std::move(data)); // Ensure server processes the earlier message - data = make_test_payload("abcd"); - client.tx_rx(2, std::move(data)); + data = makeTestPayload("abcd"); + client.txRx(2, std::move(data)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 0); - EXPECT_EQ(server.received[1].endpoint_id, 2); + EXPECT_EQ(server.received[1].endpointID, 2); EXPECT_EQ(server.received[1].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[1]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[1]),"abcd"); } /** @brief Test lifecycle with a TX_ASYNC sent message. */ @@ -146,23 +146,23 @@ TEST(Comms, test_uds_tx_async_nb) Comms::CommsModule client("commstest"); // Send a non-zero byte payload - auto datab = make_test_payload("abcd"); - client.tx_async(1, std::move(datab)); + auto datab = makeTestPayload("abcd"); + client.txAsync(1, std::move(datab)); // Ensure server processes the earlier message - datab = make_test_payload("efg"); - client.tx_rx(2, std::move(datab)); + datab = makeTestPayload("efg"); + client.txRx(2, std::move(datab)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[0]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[0]),"abcd"); - EXPECT_EQ(server.received[1].endpoint_id, 2); + EXPECT_EQ(server.received[1].endpointID, 2); EXPECT_EQ(server.received[1].data->size(), 3); - EXPECT_EQ(decode_test_payload(server.received[1]),"efg"); + EXPECT_EQ(decodeTestPayload(server.received[1]),"efg"); } /** @brief Test lifecycle with a TX_RX sent message. */ @@ -173,13 +173,13 @@ TEST(Comms, test_uds_tx_rx_0b) // Send a zero byte payload auto data = std::make_unique>(); - auto resp = client.tx_rx(1, std::move(data)); - auto resps = decode_test_payload(std::move(resp)); + auto resp = client.txRx(1, std::move(data)); + auto resps = decodeTestPayload(std::move(resp)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 1); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 0); // Validate it was responded to correctly @@ -193,16 +193,16 @@ TEST(Comms, test_uds_tx_rx_nb) Comms::CommsModule client("commstest"); // Send a non-zero byte payload - auto datab = make_test_payload("abcd"); - auto resp = client.tx_rx(1, std::move(datab)); - auto resps = decode_test_payload(std::move(resp)); + auto datab = makeTestPayload("abcd"); + auto resp = client.txRx(1, std::move(datab)); + auto resps = decodeTestPayload(std::move(resp)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 1); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[0]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[0]),"abcd"); // Validate it was responded to correctly EXPECT_EQ(resps.size(), 4); @@ -229,13 +229,13 @@ TEST(Comms, test_tcp_tx_0b) client.tx(1, std::move(data)); // Ensure server processes the earlier message - data = make_test_payload(""); - client.tx_rx(2, std::move(data)); + data = makeTestPayload(""); + client.txRx(2, std::move(data)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 0); } @@ -246,19 +246,19 @@ TEST(Comms, test_tcp_tx_nb) Comms::CommsModule client("127.0.0.1", 63412); // Send a non-zero byte payload - auto data = make_test_payload("abcd"); + auto data = makeTestPayload("abcd"); client.tx(2, std::move(data)); // Ensure server processes the earlier message - data = make_test_payload(""); - client.tx_rx(2, std::move(data)); + data = makeTestPayload(""); + client.txRx(2, std::move(data)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 2); + EXPECT_EQ(server.received[0].endpointID, 2); EXPECT_EQ(server.received[0].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[0]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[0]),"abcd"); } /** @brief Test lifecycle with a TX_ASYNC sent message. */ @@ -269,21 +269,21 @@ TEST(Comms, test_tcp_tx_async_0b) // Send a zero byte payload auto data = std::make_unique>(); - client.tx_async(1, std::move(data)); + client.txAsync(1, std::move(data)); // Ensure server processes the earlier message - data = make_test_payload("abcd"); - client.tx_rx(2, std::move(data)); + data = makeTestPayload("abcd"); + client.txRx(2, std::move(data)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 0); - EXPECT_EQ(server.received[1].endpoint_id, 2); + EXPECT_EQ(server.received[1].endpointID, 2); EXPECT_EQ(server.received[1].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[1]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[1]),"abcd"); } /** @brief Test lifecycle with a TX_ASYNC sent message. */ @@ -293,23 +293,23 @@ TEST(Comms, test_tcp_tx_async_nb) Comms::CommsModule client("127.0.0.1", 63412); // Send a non-zero byte payload - auto datab = make_test_payload("abcd"); - client.tx_async(1, std::move(datab)); + auto datab = makeTestPayload("abcd"); + client.txAsync(1, std::move(datab)); // Ensure server processes the earlier message - datab = make_test_payload("efg"); - client.tx_rx(2, std::move(datab)); + datab = makeTestPayload("efg"); + client.txRx(2, std::move(datab)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 2); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[0]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[0]),"abcd"); - EXPECT_EQ(server.received[1].endpoint_id, 2); + EXPECT_EQ(server.received[1].endpointID, 2); EXPECT_EQ(server.received[1].data->size(), 3); - EXPECT_EQ(decode_test_payload(server.received[1]),"efg"); + EXPECT_EQ(decodeTestPayload(server.received[1]),"efg"); } /** @brief Test lifecycle with a TX_RX sent message. */ @@ -320,13 +320,13 @@ TEST(Comms, test_tcp_tx_rx_0b) // Send a zero byte payload auto data = std::make_unique>(); - auto resp = client.tx_rx(1, std::move(data)); - auto resps = decode_test_payload(std::move(resp)); + auto resp = client.txRx(1, std::move(data)); + auto resps = decodeTestPayload(std::move(resp)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 1); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 0); // Validate it was responded to correctly @@ -340,16 +340,16 @@ TEST(Comms, test_tcp_tx_rx_nb) Comms::CommsModule client("127.0.0.1", 63412); // Send a non-zero byte payload - auto datab = make_test_payload("abcd"); - auto resp = client.tx_rx(1, std::move(datab)); - auto resps = decode_test_payload(std::move(resp)); + auto datab = makeTestPayload("abcd"); + auto resp = client.txRx(1, std::move(datab)); + auto resps = decodeTestPayload(std::move(resp)); // Validate it was received correctly EXPECT_EQ(server.received.size(), 1); - EXPECT_EQ(server.received[0].endpoint_id, 1); + EXPECT_EQ(server.received[0].endpointID, 1); EXPECT_EQ(server.received[0].data->size(), 4); - EXPECT_EQ(decode_test_payload(server.received[0]),"abcd"); + EXPECT_EQ(decodeTestPayload(server.received[0]),"abcd"); // Validate it was responded to correctly EXPECT_EQ(resps.size(), 4); diff --git a/source_common/comms/test/unittest_comms_client.cpp b/source_common/comms/test/unittest_comms_client.cpp index 8966422..4675172 100644 --- a/source_common/comms/test/unittest_comms_client.cpp +++ b/source_common/comms/test/unittest_comms_client.cpp @@ -40,14 +40,14 @@ #include "comms/comms_interface.hpp" #include "comms/comms_module.hpp" -std::unique_ptr make_test_payload( +std::unique_ptr makeTestPayload( const std::string& str ) { auto data = std::make_unique(str.begin(), str.end()); return data; } -std::string decode_test_payload( +std::string decodeTestPayload( std::unique_ptr data ) { std::string str(data->begin(), data->end()); @@ -65,7 +65,7 @@ TEST(CommsClient, test_tcp_no_data) TEST(CommsClient, test_tcp_registry) { Comms::CommsModule client("127.0.0.1", 63412); - client.get_endpoint_id("dave"); + client.getEndpointID("dave"); } /** @brief Test lifecycle with a TX sent message. */ @@ -84,7 +84,7 @@ TEST(CommsClient, test_tcp_tx_nb) Comms::CommsModule client("127.0.0.1", 63412); // Send a 4 byte payload - auto data = make_test_payload("abcd"); + auto data = makeTestPayload("abcd"); client.tx(1, std::move(data)); } @@ -95,7 +95,7 @@ TEST(CommsClient, test_tcp_tx_async_0b) // Send a zero byte payload auto data = std::make_unique>(); - client.tx_async(1, std::move(data)); + client.txAsync(1, std::move(data)); } /** @brief Test lifecycle with a TX_ASYNC sent message. */ @@ -104,8 +104,8 @@ TEST(CommsClient, test_tcp_tx_async_nb) Comms::CommsModule client("127.0.0.1", 63412); // Send a 4 byte payload - auto data = make_test_payload("abcd"); - client.tx_async(1, std::move(data)); + auto data = makeTestPayload("abcd"); + client.txAsync(1, std::move(data)); } /** @brief Test lifecycle with a TX_RX sent message. */ @@ -115,12 +115,11 @@ TEST(CommsClient, test_tcp_tx_rx_0b) // Send a zero byte payload auto data = std::make_unique>(); - auto resp = client.tx_rx(1, std::move(data)); - auto resps = decode_test_payload(std::move(resp)); + auto resp = client.txRx(1, std::move(data)); + auto resps = decodeTestPayload(std::move(resp)); // Validate it was responded to correctly EXPECT_EQ(resps.size(), 0); - } /** @brief Test lifecycle with a TX_RX sent message. */ @@ -129,9 +128,9 @@ TEST(CommsClient, test_tcp_tx_rx_nb) Comms::CommsModule client("127.0.0.1", 63412); // Send a 4 byte payload - auto data = make_test_payload("abcd"); - auto resp = client.tx_rx(1, std::move(data)); - auto resps = decode_test_payload(std::move(resp)); + auto data = makeTestPayload("abcd"); + auto resp = client.txRx(1, std::move(data)); + auto resps = decodeTestPayload(std::move(resp)); // Validate it was responded to correctly EXPECT_EQ(resps.size(), 4);