A flexible C++ library for managing and communicating with the NXP eIQ GenAI Flow Demonstrator(EGF) Python process through POSIX message queues.
The EGF API provides a robust interface for C++ applications to control and interact with NXP eIQ GenAI Flow Demonstrator. It enables seamless bidirectional communication between C++ GUI applications and the Python-based eIQ GenAI Flow process.
- Process Management: EGF process life cycle management
- Message Queue Communication: Asynchronous bidirectional IPC using POSIX message queues
- Event-Driven Callbacks: Register handlers for specific message types
- Lock File Protection: Prevents multiple process instances
- Thread-Safe Design: Built for multi-threaded applications
- Flexible Configuration: Easy setup through configuration structures
┌─────────────────────────────────────────────────────────────────┐
│ Your C++ Application │
│ (GUI, CLI, Service, etc.) │
└────────────────────────────────┬────────────────────────────────┘
│
│ #include "egf_api.h"
│
▼
┌────────────────────────────────────────────────┐
│ EGF::EgfApi │
│ ┌──────────────────────────────────────────┐ │
│ │ - EgfProcess process │ │
│ │ - EgfConnector connector │ │
│ └──────────────────────────────────────────┘ │
└───────────────────┬────────┬───────────────────┘
│ │
┌───────────┘ └──────────┐
│ │
▼ ▼
┌───────────────────────┐ ┌──────────────────────┐
│ EgfProcess │ │ EgfConnector │
│ │ │ │
│ Methods: │ │ Methods: │
│ • start() │ │ • connect() │
│ • stop() │ │ • disconnect() │
│ • getPid() │ │ • handler() │
│ • isStarted() │ │ • sendCommand() │
│ │ │ • registerCallback()│
│ Features: │ │ • subscribeHeader() │
│ • Lockfile PID track │ │ │
│ • Process lifecycle │ │ Features: │
│ • Boost.Process │ │ • Message queuing │
│ • Auto-restart check │ │ • Header filtering │
└──────────┬────────────┘ │ • Callbacks │
│ │ • Timeouts │
│ └──────────┬───────────┘
│ │
│ Process Control │ IPC via MQ
│ (fork/exec) │
│ │
▼ ▼
┌─────────────────────┐ ┌────────────────────┐
│ │ │ POSIX Message │
│ Python EGF Process │◄───────►│ Queues │
│ │ │ │
│ eiq_genai_flow.py │ │ /gui_to_egf ──► │
│ -i chat_interface │ │ /egf_to_gui ◄── │
│ │ │ │
│ Features: │ │ Config: │
│ • GenAI chatbot │ │ • Max: 10 msg │
│ • Voice interface │ │ • Size: 8192 B │
│ • TTS/STT │ │ • Timeout: 10ms │
│ • Wake word detect │ │ │
└─────────────────────┘ └────────────────────┘
│
│ Lockfile
▼
┌─────────────────────┐
│ /tmp/egf_process. │
│ lock │
│ │
│ Contains: PID │
└─────────────────────┘
GUI → EGF:
┌─────────┐ sendCommand() ┌──────────┐ mq_send() ┌─────────┐
│Your App │ ─────────────────►│Connector │──────────────►│Queue │
└─────────┘ └──────────┘ │/gui_to │
│ _egf │
└────┬────┘
│
▼
┌─────────┐
│Python │
│EGF │
└─────────┘
EGF → GUI:
┌─────────┐ ┌──────────┐ ┌─────────┐
│Python │ │Queue │ mq_receive() │Connector│
│EGF │──────────────────►│/egf_to │──────────────►│ │
└─────────┘ │ _gui │ └────┬────┘
└──────────┘ │
│ callback()
▼
┌─────────┐
│Your App │
└─────────┘
- C++ Compiler: GCC/Clang with C++17 support
- CMake: 3.14 or later
- Boost Libraries (1.65+):
boost_systemboost_filesystemboost_process
- POSIX Libraries:
rt(Real-time extensions)pthread
- POSIX-compliant operating system (Linux)
- Python 3 with eIQ GenAI Flow installed
- Sufficient message queue resources (
/proc/sys/fs/mqueue/)
sudo apt-get updatesudo apt-get install build-essential cmakesudo apt-get install libboost-all-dev