Pymavlink script not getting heartbeat from pixhawk 6c (sometimes)

I have a jetson nano that object-recognizes a person (me) and then tries to put my pixhawk 6c px4 x-500 into land mode (testing at home). Having trouble … not getting the heartbeat often when I run the pymavlink program.

To “coax” the 6c to respond with a heartbeat, it seems I can use QGC. QGC is doing soemthing to get the heartbeat… but what?

Any ideas? DO I HAVE TO INITIATE SOMEHOW THE HEARTBEAT, IF SO THEN HOW??? I am trying to send mavlink commands to 6c in response to Jnano object recognizing a person. Everything works, except this (should be simple) heartbeat issue.

follwoing is setup.

Word file for what I am trying to do (with screenshots; see the two chapters “0615 …” for details of pixhawk 6c <> jnano object recognition tests)
E3-7.2.1b_jnano_pix6c_pymavlink_tests_v04_24.0609_0615
@ E3-7 AI basic examples (2c) - Google Drive

wiki page

This is typical way i have been running into this problem… Running a py script (first few lines below) on Jnano first time and works. Then I try to run again, and Jnano never gets a heartbeat.

connection = mavutil.mavlink_connection(‘/dev/ttyACM0’)
print("2 the connection = " + str(connection))
connection.wait_heartbeat()
print(“Heartbeat from system (system %u component %u)” % (connection.target_system, connection.target_component))

my actions in detail:
1 not power on RC (tx-12).
2 connect windows11 holybro telem (connects to 6c telem).
2b start qgc
3 start jnano
4 connect 6c usb-ttl to nano usb. 6c powers on. then goes off after a few secs.
5 disconnect usb.
6 battery connect
7 connect usb again.
7b use qgc to set to stabilized.
8 run 24.0609_2_land.py. fails. “device or resourse busy: ‘/dev/ttyACM0’.
9 shutdown qgc on Jnano (it was on).
10 run .py again. BINGO. 6c switches to land mode.
11 10 mins after battery connect, 1-2-3-4 beep starts continuously.
12 disconnect battery. 6c (and other stuff) still powered on.
13 after ~1 min powers down “communication lost”

14 I try again… connect battery to 6c, connect Jnano to 6c, run script… jnano never gets heartbeat.
15 I power off, on, try again, and again, still same problem.

16 I have a terminal with the hungup script waiting for heartbeat.
17 I start qgc (on Jnano). connects. The py script gets the heartbeat.

PS: The details of my experimentation with this are in the docx. The following screenshots show my goal, how the nano recognizes me, then switches the copter to land mode.

image

Solution was to send a heartbeat first to the pixhawk. I thougth this might be it, but needed sometime to track down the pymavlink command to do it. (the examples and doc pages i read before did not have this step).

my-land111_bbb.py @
https://drive.google.com/drive/folders/1eVXk6uqvKbY8qdOTGVSPfAdQDtaJMwVY