defining interfaces outside of main.xc

If you have a simple question and just want an answer.
Posts: 27
Joined: Wed Jul 04, 2018 4:06 pm

defining interfaces outside of main.xc

Postby jsaksris » Mon Dec 03, 2018 4:36 pm

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
You do not have the required permissions to view the files attached to this post.
XCore Addict
Posts: 128
Joined: Wed May 11, 2016 3:50 pm

Postby Gothmag » Mon Dec 03, 2018 5:55 pm

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

Code: Select all

typedef struct name {} name;
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.
Junior Member
Posts: 5
Joined: Mon Sep 10, 2018 4:23 pm

Postby Yanava » Wed Dec 26, 2018 2:39 pm

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.

Who is online

Users browsing this forum: No registered users and 0 guests