Raspberry Pi Camera V2 and Serial seem to bother each other

Language: C++
Relevant Libraries: SDL2, OpenCV4, Serial

Application Objective: I’m putting together an application where I move a cursor with a game controller and overlay it onto the camera stream and show it, aditionally I want to receive some data from an Arduino Mega. The arduino just sends a value from -1000 to 1000 and I want to show it in the screen too.

What does work: I made work the first part, Talking with the remote controller via USB or Bluetooth and showing that info onto the screen over the camera stream using gstreamer.

The code:

program_test_WORKING.cpp (5.4 KB)

I installed the Arduino IDE into my Nano to check the serial port was working and indeed, the Nano was receiving the expected data from the Arduino.

I found an example using this library here . And it works fine.

I ran both working applications in parallel and they work fine separately.

What does NOT work: Now If I put part of the Serial code into the Camera and Controller program, the program just crashes without showing anything

The code:

program_test_NOT_WORKING.cpp (5.4 KB)

I’m not an expert programmer, so I thought you might have an idea of what is happening here.

These are the Console Outputs of both programs

failed_execution_RPICAM_SDL2_Serial_out.txt (5.5 KB)
successful_RPICAM_SDL2_out.txt (3.4 KB)

hello mrwilliam932,

you may narrow down the issue to check the serial port connections.
also, the baudrate settings is 115200/8n1 by default.

Hello, thank you for answering, the baudrate is correct 230400/8n1, the output error refers to the camera, which is weird because without activating the serial port the camera just works.

hello mrwilliam932,

how did you send out the data via serial port, did you determine that and issue data output for each captured frame?
please also look into kernel messages, (i.e. $ dmesg ) to check if there’re overrun failures.
thanks

nothing on the dmesg, The Arduino talks to port /dev/ttyACM0 as fast as it can, then on the receiving side I will read once every frame, later I may ask to the arduino for that info once per frame so it gives me the info. But the thing is that I have problems only opening the port, not even sending or receiving

hello mrwilliam932,

Jetson platforms were using /dev/ttyTHS* for serial data communication.
you may refer to Topic 82037 for an instruction of using UART on ttyTHS1.
there’s also a discussion thread, Topic 153941, which demonstrate the mappings for serial ports of ttyTHS*, and UART*.
thanks