How to callback C functions in the binary main program from a Ch script?
Please read chapter 5 section “Calling Back C Functions in the Main Program from Ch Space” in Embedded Ch User’s Guide located at CHHOME/docs/embedch.pdf. We provide many examples for different situations for handling callback C functions in the main program from Ch scripts. It includes an example to pass a function from C to Ch, and then pass it back from Ch to C, and callback in C. Below is a sample C code embedch3.c with a C function func() called from a Ch script embedch3.ch. The API Ch_DelcareFunc() makes the function func() available in the script space. The aruments from the script space are passed to the interface function func_chdl() first in the binary space, which in turn calls the binary function func(). The interface function func_chdl() can be automatically generated using the utilities provided in the Embedded Ch SDK.