SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (MTB & µPython)
Loading...
Searching...
No Matches

จุดเข้าสำหรับ query ของ backend "ipc" ถูก export ออกมาจาก archive แต่ ไม่มี header ที่ส่งมอบมาตัวใดประกาศมันไว้ (bento_secure_undeclared.h บันทึกเรื่องนี้ไว้) จึงไม่มีสิ่งใดให้เอกสาร \fn ผูกเข้าด้วย — จึงบันทึกไว้ที่นี่ในรูปหมายเหตุ

variant ที่ใช้ได้
mtb-mpy เท่านั้น (ไม่มีการลิงก์ libbento_mpy.a เมื่อ BENTO_HAS_MPY=0)

bento_link_ipc_query

/* No shipped header declares this symbol (bento_secure_undeclared.h).
* The consumer writes the extern; signature as the archive defines it: */
extern bool bento_link_ipc_query(uint8_t sub, uint32_t value,
ipc_model_link_resp_t *resp);

ข้อกำหนดการเรียกใช้ การ query แบบซิงโครนัสไปยัง registry ของโมเดลบน CM55 ผ่าน backend "ipc" (sub-code MODEL_LINK_Q_* มาจาก header ร่วมที่ส่งมอบมา คือ ipc_model_link_defs.h) ผู้ใช้ไลบรารีต้องเขียนคำประกาศขึ้นเอง — ไม่มีใครส่งมอบมาให้ ลำดับ: bento_link_ipc_init() → bento_link_get("ipc") ตรวจ NULL → query คืนค่า false เมื่อ transport หมดเวลา และ เมื่อ link ไม่ว่าง (ส่งคำสั่งควบคุมค้างอยู่ได้ครั้งละหนึ่งรายการเท่านั้น): ให้ถือทั้งสองกรณีว่า "ไม่มีคำตอบ" ห้ามถือว่าเป็นผลลัพธ์ที่มีค่าเป็นศูนย์ resp ต้องอยู่ในหน่วยความจำร่วมของ CM33 (CY_SECTION_SHAREDMEM) — มีเพียงพอยน์เตอร์เท่านั้นที่ข้าม pipe ไป และ CM55 เขียนผ่านพอยน์เตอร์นั้น ให้ตรวจ resp->status ก่อนจะเชื่อ payload บล็อกได้นานราว 500 ms; ทำงานใน MicroPython task context ไม่มี call site ในเทมเพลตเลย; ผู้เรียก 12 แห่งอยู่ใน modedgeai.c ที่เก็บไว้ใน archive ซึ่งไม่ได้ส่งมอบมาเป็นซอร์ส

ตัวอย่าง (เขียนขึ้นเอง — ไม่มี call site ในของที่ส่งมอบจริง)
/* Hand-written extern — no shipped header declares this symbol.
* Signature copied from the defining file, bento_link_ipc.c:117. */
extern bool bento_link_ipc_query(uint8_t sub, uint32_t value,
ipc_model_link_resp_t *resp);
/* Response lives in shared memory: CM55 fills it by pointer. In firmware
* the CY_SECTION_SHAREDMEM attribute (cy_utils.h, always in the firmware
* include chain) is mandatory — a stack or ordinary-RAM struct is not
* visible to CM55. */
#if defined(CY_SECTION_SHAREDMEM)
CY_SECTION_SHAREDMEM
#endif
static ipc_model_link_resp_t s_query_resp;
static void bento_ex_bento_link_ipc_query(void)
{
/* 1. Bring the IPC backend up (idempotent) and confirm it registered. */
return; /* pipe endpoint not up — fail fast */
}
if (bento_link_get("ipc") == NULL) {
return; /* backend not compiled in */
}
/* 2. Pull the registry model count. rc=false covers transport timeout
* AND a busy link (one control send in flight at a time) — treat
* both as "no answer", never as "count is zero". */
if (!bento_link_ipc_query(MODEL_LINK_Q_COUNT, 0u, &s_query_resp)) {
return; /* model link timeout / link busy */
}
/* 3. Check the response status before trusting the payload — the
* archived MicroPython binding raises OSError on ENGINE_DEAD. */
if (s_query_resp.status != MODEL_LINK_RESP_OK) {
return; /* e.g. MODEL_LINK_RESP_ENGINE_DEAD */
}
int32_t model_count = s_query_resp.u.count;
(void)model_count;
}