ACIEngine and synchronizing
Let us first add some code to the mainloop. Open sdk.c and modify the void SDK_mainloop(void):
ACI sends all data, which is written in a buffer over the serial to the device. The functions aciSyncVar(), aciSyncCmd() and aciSyncPar() writes all variables into the buffer for sending and all incoming commands and parameter are written from the buffer to the defined commands and parameters. aciEngine() checks for receiving the heartbeat, sends the variables to the PC and (if it is set) saves all parameters on the device.
We have to publish now all variables, commands and parameters. For that, open the main.c and add some code in void ACISDK( void ) after setting the callbacks:
These variables, commands and parameters are nearly the same which are defined in the List of all predefined variables, commands and parameters. Some of them are missing, because they were introduced in AscTec SDK 3.0. Every publish command starts with aciPublish and then add the type you want to publish. The parameters are very simple. First, set the reference of the publishing variable, then define the type and the ID. After that, three strings follow (Name, Description and Unit). All the strings you will see on the remote site. Only use variables, which are defined global in the program.
That is all. You can now try with the ACI Tool to send some commands or to read variables. For setting variables, use the AscTec SDK 3.0 binary. You can download it on the ACI Downloads page.
You have now the possibility to write your own code and to publish your own variables, commands and parameters.