How to communicate throught UART?

Hi,

I want to implement a custom process in order to allow the pixhawk (cube black) to a custom device.
I need to read/write on a serial port. I do not use GPS2 port, thus I chose this one to communicate.
Here is the very simple code (that does not work) :

AP_HAL::UARTDriver* uart;
uart = hal.uartE;
if(uart == nullptr){
return;
}
uart->begin(9600);
uart->configure_parity(0);
uart->set_stop_bits(1);

The thing is, it does not work as the autopilot does not boot. After flashing the firmware, i cannot connect to the autopilot, as there is no usb port to connect to.

If I’m replacing hal.uartE by hal.uartH, it works properly ( ls -l /dev/tty* shows me a /dev/ttyACM0, and I can connect to my autopilot with MissionPlanner).

Why doesn’t it work with uartE ? How should I do to use GPS2 port ?

I’m using latest firmware, latest MissionPlanner, and Cube Black as an autopilot

If you are not familiar with the ardupilot code base, I recommend you to work on lua scripting.


I don’t know whether this is suitable or not for your case since I don’t know what your are trying to do but I just wanted to share this feature =)