Which module sets the PWM (PX4 Firmware)

Good morning!

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);
}

Which module should I to modify?

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.

https://dev.px4.io/en/concept/mixing.html

1 Like

if you help me I will be thankful to you.

I find only https://github.com/PX4/Firmware/blob/master/src/drivers/pwm_out_sim/pwm_out_sim.cpp. But

This virtual driver emulates PWM / servo outputs for setups where
the connected hardware does not provide enough or no PWM outputs.

What should be the algorithm for creating the ideal solution? Is it just to create a driver in https://github.com/PX4/Firmware/blob/master/src/drivers, and subscribe it to actuator_control messages?

Yes I just meant to create a new driver in src/drivers rather than hack support into an existing driver.