Closed luukWeFab closed 11 months ago
Serial and Networked transport are not handled in the same way by the library, check serial framing here: https://micro-xrce-dds.docs.eprosima.com/en/latest/transport.html#stream-framing-protocol
Are you taking into account that framing protocol shall be disabled when using UDP by means of this flag: https://github.com/micro-ROS/micro_ros_stm32cubemx_utils/blob/3819f6819cee1ff01c3da58ecbc8bfcbf4b0a2a5/sample_main.c#L382
I did not accounting that the framing protocol needed to be disabled thank you. Changing to indeed made the udp agent respond to the request. Thank you.
A second quick question I have is whether TCP is supported or not? Because that would then also work without framing enabled right? I ask this because I read in the main readme of this repository that it is, however in the readme of the micro_ros_agent sub folder it is stated that only UDP, and serial are supported.
And thank you again for the help!
Nice to hear that @luukWeFab, I'm closing as solved.
TCP is supported at XRCE-DDS level but it not very well integrated in micro-ROS.
Take a look here to a sample implementation: https://github.com/eProsima/Micro-XRCE-DDS-Client/blob/master/src/c/profile/transport/ip/tcp/tcp_transport_posix.c
As you can see, there is another "framing" for TCP, it is handled at XRCE Client level here: https://github.com/eProsima/Micro-XRCE-DDS-Client/blob/97175304425c5bee87c6fddd99de1ef8d0c394dc/src/c/profile/transport/ip/tcp/tcp_transport.c#L33
Issue template
Steps to reproduce the issue
include <uxr/client/transport.h>
include "socket.h"
include "dhcp.h"
include "dns.h"
include "spi.h"
include "rcl_error_handler.hpp"
include "pinout.hpp"
include "cmsis_os.h"
define DHCP_SOCKET 0
define DNS_SOCKET 1
define HTTP_SOCKET 2
define MICRO_ROS_SOCKET 3
/**
*/ extern uint8_t microROS_agent_socket;
extern uint8_t rx_buffer[cnst::RX_SOCKET_BUFFER]; extern uint32_t curr_head; extern uint32_t curr_tail; extern volatile uint32_t curr_length;
template
struct dma_tx_buffer_t {
uint8_t buffer[Size];
bool transmission_started;
};
/**
/**
/**
/**
/**
/**
/**
/**
bool w5500_transport_open(struct uxrCustomTransport transport); bool w5500_transport_close(struct uxrCustomTransport transport); size_t w5500_transport_write(struct uxrCustomTransport transport, const uint8_t buf, size_t len, uint8_t err); size_t w5500_transport_read(struct uxrCustomTransport transport, uint8_t buf, size_t len, int timeout, uint8_t err);
endif //__W5500_TRANSPORT_LAYER_HPP
include "w5500_transport_layer.hpp"
uint8_t microROS_agent_socket = MICRO_ROS_SOCKET;
// #define TCP
define UDP
void W5500_Select(void) { pins::ETH_SCS.clear(); }
void W5500_Unselect(void) { pins::ETH_SCS.set(); }
void W5500_ReadBuff(uint8_t* buff, uint16_t len) { HAL_SPI_Receive(pins::w5500_spi, buff, len, HAL_MAX_DELAY); }
void W5500_WriteBuff(uint8_t* buff, uint16_t len) { HAL_SPI_Transmit(pins::w5500_spi, buff, len, HAL_MAX_DELAY); }
uint8_t W5500_ReadByte(void) { uint8_t byte; W5500_ReadBuff(&byte, sizeof(byte)); return byte; }
void W5500_WriteByte(uint8_t byte) { W5500_WriteBuff(&byte, sizeof(byte)); }
void init_w5500() { print_debug_uart("Initializing w5500", "");
}
bool w5500_transport_open(struct uxrCustomTransport * transport) {
ifdef UDP
}
bool w5500_transport_close(struct uxrCustomTransport * transport) { close(microROS_agent_socket); print_debug_uart("Socket", "closed"); return true; }
size_t w5500_transport_write(struct uxrCustomTransport transport, const uint8_t buf, size_t len, uint8_t err) { // TODO: remove this later static uint32_t write_counter = 0; write_counter++; print_uint("Write counter", write_counter); // END TODO print_debug_uart("Socket", "Trying to send data"); print_uint("Data length", len); print_array("Write array", (uint8_t ) buf, len, true);
ifdef UDP
}
size_t w5500_transport_read(struct uxrCustomTransport transport, uint8_t buf, size_t len, int timeout, uint8_t * err) { // print_debug_uart("Socket", "Trying to receive data"); // print_uint("Data length", len);
ifdef UDP
}
void print_socket_error(int8_t socket_error_code) { switch(socket_error_code) { case SOCK_OK: print_debug_uart("Socket ok", ""); break; case SOCK_BUSY: print_debug_uart("Socket error", "Port busy"); break; case SOCKERR_SOCKNUM: print_debug_uart("Socker error", "Socket num invalid"); break; case SOCKERR_SOCKOPT: print_debug_uart("Socket error", "Invalid socket option"); break; case SOCKERR_SOCKINIT: print_debug_uart("Socket error", "Socket init error"); break; case SOCKERR_SOCKCLOSED: print_debug_uart("Socket error", "Socket was closed"); break; case SOCKERR_SOCKMODE: print_debug_uart("Socket error", "Invalid socket mode"); break; case SOCKERR_SOCKFLAG: print_debug_uart("Socket error", "Invalid socket flag"); break; case SOCKERR_SOCKSTATUS: print_debug_uart("Socket error", "Socket status"); break; case SOCKERR_ARG: print_debug_uart("Socket error", "Invalid socket arguemnt"); break; case SOCKERR_PORTZERO: print_debug_uart("Socket error", "Port zero"); break; case SOCKERR_IPINVALID: print_debug_uart("Socket error", "IP invalid"); break; case SOCKERR_TIMEOUT: print_debug_uart("Socket error", "Timout connecting to socket"); break; case SOCKERR_DATALEN: print_debug_uart("Socket error", "Data length is incorrect"); break; case SOCKERR_BUFFER: print_debug_uart("Socket error", "Buffer size is not enough"); break; default: print_debug_uart("Socket error", "Error code not supported"); break; } }