I have a special controller (for wheel), that works on UART. I need to translate values from PWM outputs to UART. This example is used to write to UART:
int uart_usb = open("/dev/ttyS6", O_WRONLY | O_NOCTTY);
if (uart_usb < 0) {
printf("ERROR opening /dev/ttyS6\n");
return uart_usb;
}
uint8_t sample_uart_usb[] = {'S', 'A', 'M', 'P', 'L', 'E', ' ', '\n'};
for (int i = 0; i < 30; i++) {
write(uart_usb, sample_uart_usb, sizeof(sample_uart_usb));
printf(".");
fflush(stdout);
sleep(1);
}
The ideal solution is to implement a new driver for this device that subscribes to actuator_control messages, does the mixing, then writes the output. If you’re looking for a much quicker temporary solution I can show you where to hack it into an existing driver.