erpc icon indicating copy to clipboard operation
erpc copied to clipboard

How do callbacks work with Python?

Open chenlijun99 opened this issue 4 years ago • 2 comments

Hi!

I'm trying to make a C program communicate with a python program, where the C program is the "target" and the Python program is the "host". The IDL file looks like this.

program callback

on_message(string message) -> void

@group(target)
@include("callback_host.h")
interface target {
    target_register_callback(on_message on_message_handler) -> void
    on_message target_on_message_handler;
}

@group(host)
@include("callback_target.h")
interface host {
    host_register_callback(on_message on_message_handler) -> void
    on_message host_on_message_handler;
}

The problem is that the generated python code does not correctly import the callbacks declarations, which leads to "function not defined" error in the callback table.

#
# Generated by erpcgen 1.8.1 on Sun Oct 24 10:33:19 2021.
#
# AUTOGENERATED - DO NOT EDIT
#

import erpc
from . import common, interface
# import callbacks declaration from other groups
from ..callback_target import interface as interface_target

_on_message = [ target_on_message_handler, host_on_message_handler ] # <-- these functions are not defined

I think the problem is that in Python the implementations of the functions defined in the IDL file are provided via classes, rather than free functions.

chenlijun99 avatar Oct 24 '21 08:10 chenlijun99

Hi, i am sorry but this functionality was never tested on python. Unfortunatelly python support for newest features was poor.

Hadatko avatar Nov 08 '21 09:11 Hadatko

I understand. Thank you for letting me know.

chenlijun99 avatar Nov 08 '21 10:11 chenlijun99