Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

EGF API Library

A flexible C++ library for managing and communicating with the NXP eIQ GenAI Flow Demonstrator(EGF) Python process through POSIX message queues.

Overview

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.

Key Capabilities

  • 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

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                       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      │
    └─────────────────────┘

Message Flow

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 │
                                                         └─────────┘

Requirements

Build Dependencies

  • C++ Compiler: GCC/Clang with C++17 support
  • CMake: 3.14 or later
  • Boost Libraries (1.65+):
    • boost_system
    • boost_filesystem
    • boost_process
  • POSIX Libraries:
    • rt (Real-time extensions)
    • pthread

Runtime Dependencies

  • POSIX-compliant operating system (Linux)
  • Python 3 with eIQ GenAI Flow installed
  • Sufficient message queue resources (/proc/sys/fs/mqueue/)

Installation (Ubuntu/Debian)

sudo apt-get update
sudo apt-get install build-essential cmake
sudo apt-get install libboost-all-dev

Related Resources

About

lib-egf-api is an IPC communication interface layer encapsulated by Qt.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages