diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 1e0b3ddb3e..f2dcd33d79 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1789,6 +1789,12 @@ Mavlink::start(int argc, char *argv[]) // before returning to the shell int ic = Mavlink::instance_count(); + if (ic == MAVLINK_COMM_NUM_BUFFERS) { + warnx("Maximum MAVLink instance count of %d reached.", + (int)MAVLINK_COMM_NUM_BUFFERS); + return 1; + } + // Instantiate thread char buf[24]; sprintf(buf, "mavlink_if%d", ic); diff --git a/src/modules/mavlink/module.mk b/src/modules/mavlink/module.mk index e82b8bd935..509fd9e495 100644 --- a/src/modules/mavlink/module.mk +++ b/src/modules/mavlink/module.mk @@ -53,6 +53,6 @@ MAXOPTIMIZATION = -Os MODULE_STACKSIZE = 1200 -EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed +EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 -EXTRACFLAGS = -Wno-packed +EXTRACFLAGS = -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3