How to send serial message to start a script on Jetson Orin NX

Hi, I am new to Jetson hardware. I have a carrier board of jetson orin nx. I have scripts that run in boot. I am also able to communicate with the board from my windows laptop by serial messages. I use hterm to recieve messages. Now I am wondering can i send serial message to start a script and to stop a script instead of doing it on boot. Not sure if I am clear but I am very new to this. My goal is to start and stop a script on the device and everytime i dont to take the power off and on again for it to boot. Looking for effiecient ways to do so.

Hi sadiac,

What’s your Jetpack version in use?

Are you using our devkit board or custom carrier board for Orin NX?

Do you mean the serial console (/dev/ttyTCU0)?

It seems you want to run/stop the specific script manually.
You can either using serial console or connect your device through SSH and you can run the command for them.
May I also know what’s your script for? Is it created by you?

Hi I am using custom carrier board for Orin NX. The jetpack version is 5.1.1. I want to basically prompt the script to run and stop when instructed. I have few cameras connected to the carrier board and the script basically records and saves a video. Hence, I am looking for an efficient way to start and stop a script on the board. I was thinking that sending a serial message to start a script and then again another one to stop a script should be the way to go? If you have any suggestions please let me know. Eventually i want to deploy these boards in a real world scenario where i can just place it anywhere record some videos and bring them back later on to inspect. Thanks!

If you have the requirement for remote access, I suggest you can just use SSH to login the device.

For this use case, you can just create a custom service to start/stop the recording or other operations automatically.

I dont have the requirement for remote access. Let me explain, I hope my make sense. So I want to be able to deploy the jetson device in real life. I want to send a serial message to the device to start a script once i do that i will disconnect it from a host computer and take it outside and use it to capture and save videos. At the end i will bring it back inside connect again, send a serial message or signal to stop the script.

I have not been following this, but understand that you can open a serial port for read or write like a regular file. You can also “cat” the device special file, and then pipe it to stdin of your program. You’re just reading text in your program. If you’ve programmed something on command line to listen to commands like “help” or “exit”, then this is no different when using a serial port versus stdin. You would start your program each boot and tell it to read from the serial UART device special file (you don’t seem to need to reply, so you wouldn’t have to open for write; you could though to verify the program status, e.g., open read/write).

Are you trying to get the program to run each boot, or are you trying to take a program which is running and read from the serial UART?

Hi, I am trying to run the program at each boot. Previously, I was doing this by opening a service file and everytime I power it on the program would run. But in that case when I want to restart the program I would have to take the power off again and then again give back the power to restart another script on boot. Now, I want to take more control over the process, so i want to send a serial message which will indicate the jetson device to start a script and another message to stop a script. I hope i am being clear!

What language is your program using? Basically, you need to either have a thread that waits for serial console messages (it is just a file read that blocks until content is available), or polls for content from the serial console. The same thread could also write to the device special file as if it is a plain file. I am assuming this is plain text, some other details might need to be managed for binary data.

FYI, a second program which manages stop and start of the program is optional; the program itself could always listen (file read; if threaded, then blocking, if non-threaded, then polling) and might be simpler.