Problem compiling a serial communication between Jetson AGX Orin 64 GB and a serial device.

19 views (last 30 days)
Hello,
I am trying to compile a Matlab script using Matlab and GPU's coders on a personal PC with Matlab R2024a installed in Ubuntu 20.04.6 LTS.
The problem is that I need the "serialport" function, when I try to compile my code I receive the error:
"Error using codegen". The function 'serialport' is not supported for code generation.
The purpose of this build is to create an executable file for the NVIDIA Jetson AGX Orin module that communicates an Arduino with the Jetson module.
Alternatively, I used the "arduino" and "serial" functions but got the same error, even with the matlab's "write" funciton. In addition to this, I try to handle the function as coder.extrinsic('readSerialPort'), where "readSerialPort" is a function that calls the Matlab "serialport" function. This fixes my compilation problem but it does not communicate with the Arduino connected to the Jetson module.
Is there an alternative function to connect a serial device? I know the "serialdev" function that, as far as I understand, there is a function to connect serial devices to Raspberry hardware. Is there an equivalent function for the Jetson module?
Thanks for your response in anticipation.
  2 Comments
Denis Gurchenkov
Denis Gurchenkov on 15 Oct 2024
Hi Gibran, if I understand you correctly, the C/Cuda code you generate is going to run on the Jetson? And the "serialport" function is for the purposes of talking to an Arduino. Is this correct?
If yes, one workaround would be to write a tiny bit of C code that opens the serial connection and sends/receives the data, and make that C function callable from MATLAB using coder.ceval. Essentially, what I am suggesting is that instead of generating C code for the serialport function and your business logic that uses it, you hand-write that small piece of C code.
For coder.extrinsic, because you are generating C code to run on a target that does not have MATLAB process, extrinsic calls can't work. They only work if the C code is compiled into a mex file and run inside MATLAB itself.
Gibran
Gibran on 15 Oct 2024
Hi @Denis Gurchenkov, you are right. I need the "serialport" function to talk with an Arduino from an executable running on the Jetson board.
I will follow your suggestion and write this piece of C code to incorporate it into the main code.
Thank you for your quick response and the detailed explanation, I did not know about the coder.extrinsic's limitation.
Greetings.

Sign in to comment.

Answers (0)

Categories

Find more on Deployment in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!