How do callbacks work with Python?
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.
Hi, i am sorry but this functionality was never tested on python. Unfortunatelly python support for newest features was poor.
I understand. Thank you for letting me know.