Read geo-fence status

Hello, i am trying to read the geo-fence status, i have already enabled the geo-fence from the parameters.
I try the function “gcs_mavlink:send_fence_status()” that i found here: ardupilot/GCS_Fence.cpp at master · ArduPilot/ardupilot · GitHub
but i have the following error " attempt to index a nil value (global ‘gcs_mavlink’)"

Also in documentation on ardupilot doesn’t write anything.(here:Lua Scripts — Copter documentation)

Thank’s in advanse.

@Yuri_Rage do you know how i possible read the geo-fence status, from quick tab it’s called “fenceb_status”.

Thank’s in advanse

Probably there are no LUA bindings for that function.

Fences are not made available to Lua. It’s been a little bit of a point of contention for several years now, and there is a rather stale PR for them that has not yet been approved.

Going to post this exchange publicly rather than leaving it as a private message:

Creating a binding for fence breach status shouldn’t be too hard to do, but you will need to configure a build environment and use a custom firmware version.

You should be looking in the vehicle specific fence implementations rather than in the GCS messaging for the method you’d like to bind.

Yes @Yuri_Rage, @Mustafa_Gokce you are right, after studing i little more for scripting i undertanded.

Finally i found the functions of geo-fence from github (here : ardupilot/AC_Fence.h at master · ArduPilot/ardupilot · GitHub)

I made a new bind from the instuctions (here : Lua Scripts — Copter documentation)

I use the function “get_breaches()” and it works!
Thank you for your fast ryplies!
An example of the code is below:

function update()

fence_action = param:get(‘FENCE_ACTION’)
gcs:send_text(7, "Fence action = " … fence_action)

if (fence_action == 8) then
t_get_breaches = ac_fence:get_breaches()
gcs:send_text(7, "t_get_breaches = " … t_get_breaches)

if (t_get_breaches ~= 0) then
  SRV_Channels:set_output_pwm(27, 1095)
  gcs:send_text(0, "Parachute Released")


return update, 1000–1sec

return update()