Dynamixel Servo on PX4

Hi,

I’m porting the robotis dynamixel servo to PX4 from Ardupilot. After looking at how it was setup (very similar to frsky smart port telemetry), i did most of the setup in my module, but then i noticed that the uart signal should be inverted (0v = High, 3.3V = low).

I implemented the inversion the same way it was done on frsky telem
ioctl(uart, TIOCSINVERT, invert ? (SER_INVERT_ENABLED_RX | SER_INVERT_ENABLED_TX) : 0)

but when looking at the uart signal from the oscilloscope it s not inverted at all.
Can you help me figure out why it s not inverted ?

here is the full setup of the uart on /dev/ttyS2

 /* Open UART */
const int uart = open(uart_name, O_RDWR | O_NOCTTY | O_NONBLOCK);

if (uart < 0) {
    PX4_ERR("Error opening port: %s (%i)", uart_name, errno);
    PX4_INFO("UART port error");
    return -1;
}

PX4_INFO("UART open success");

/* Back up the original UART configuration to restore it after exit */

int termios_state;

if ((termios_state = tcgetattr(uart, uart_config_original)) < 0) {
    PX4_ERR("tcgetattr %s: %d\n", uart_name, termios_state);
    close(uart);
    return -1;
}

/* Fill the struct for the new configuration */
tcgetattr(uart, uart_config);

/* Disable output post-processing */
uart_config->c_oflag &= ~OPOST;
uart_config->c_cflag |= (CLOCAL | CREAD);    /* ignore modem controls */
uart_config->c_cflag &= ~CSIZE;
uart_config->c_cflag |= CS8;         /* 8-bit characters */
uart_config->c_cflag &= ~PARENB;     /* no parity bit */
uart_config->c_cflag &= ~CSTOPB;     /* only need 1 stop bit */
uart_config->c_cflag &= ~CRTSCTS;    /* no hardware flowcontrol */

/* setup for non-canonical mode */
uart_config->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
uart_config->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);

/* Set baud rate */
// todo : dynamixel works on 9600 57600(default) 115200 1M 2M 3M 4M 4.5M

const speed_t uart_speed = B57600;
if (cfsetispeed(uart_config, uart_speed) < 0 || cfsetospeed(uart_config, uart_speed) < 0) {
    PX4_ERR("%s: %d (cfsetispeed, cfsetospeed)\n", uart_name, termios_state);
    close(uart);
    return -1;
}

if ((termios_state = tcsetattr(uart, TCSANOW, uart_config)) < 0) {
    PX4_ERR("%s (tcsetattr)\n", uart_name);
    close(uart);
    return -1;
}

set_uart_single_wire(uart, true); // ioctl(uart, TIOCSSINGLEWIRE, single_wire ? (SER_SINGLEWIRE_ENABLED | SER_SINGLEWIRE_PUSHPULL | SER_SINGLEWIRE_PULLDOWN) : 0)

set_uart_invert(uart, true); // ioctl(uart, TIOCSINVERT, invert ? (SER_INVERT_ENABLED_RX | SER_INVERT_ENABLED_TX) : 0)

return uart;