hello all,
for the reason of code organisation, I would like to define my interfaces and function outside of main.xc
can I get help with the syntax?
I have written the interface in Tasks.xc
and have Tasks.h file so that other files would be able to access the interface and value.
but there is a syntax error for client, server, and interface
defining interfaces outside of main.xc
defining interfaces outside of main.xc
- Attachments
-
- Capture.PNG (13.26 KiB) Viewed 35233 times
- Capture.PNG (13.26 KiB) Viewed 35233 times
One server and multiple clients requires an array of them. One per client. Also your interface can't be of type interface, needs to be led_if or some other type. Use a syntax for it. Then you declare it as name myled_if[3]. myled_if goes to server, individuals go to clients as server/client interface name.
Code: Select all
typedef struct name {} name;
You have a couple improvements you can make:
1) As mentioned, you can typedef interface LEDs_interface into LEDs_interface, then use:
void LEDControl(server LEDs_interface);
2) If you are going to handle your interface to multiple clients, you have to allow your server to handle multiple instances. Check the lib_i2c implementation which shows how to do this, you will have to include a counting mechanism on each interface event that will handle events coming from all instances. Also, if you anticipate that there might be racing conditions, like all of the instances will be handling pins, consider including a locking mechanism, so each access can only be performed when the last one was finished. Again, lib_i2c's implementation provides good pointers for that.
1) As mentioned, you can typedef interface LEDs_interface into LEDs_interface, then use:
void LEDControl(server LEDs_interface);
2) If you are going to handle your interface to multiple clients, you have to allow your server to handle multiple instances. Check the lib_i2c implementation which shows how to do this, you will have to include a counting mechanism on each interface event that will handle events coming from all instances. Also, if you anticipate that there might be racing conditions, like all of the instances will be handling pins, consider including a locking mechanism, so each access can only be performed when the last one was finished. Again, lib_i2c's implementation provides good pointers for that.