I am just starting to program xmos. The programming guide is good as a general overview but I would like to see a complete syntax reference.
For example, I am starting with the low level ethernet demo.
In the programming guide the chan statement is used as such:
chan c ;
In the demo code it is used like this:
chan rx[1], tx[1];
What does the parameter inside the brackets refer to?
New Programming Guide
-
- XCore Addict
- Posts: 204
- Joined: Sun Jun 01, 2014 10:25 pm
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
Please ignore this response it's a mistake, kept here purely to keep the thread flow
This declares 5 channels c,rx[0],rx[1],tx[0],tx[1]
Code: Select all
chan c ; // A single channel
chan rx[1], tx[1]; // two arrays of 2 channels each
-
- Respected Member
- Posts: 318
- Joined: Tue Dec 15, 2009 12:46 am
chan rx[1] declares an array of 1 channel, in the same way int a[1] declares an array of 1 int in C.
I think you mean this declares 3 channels, c,rx[0],tx[0]. The number in brackets is the number of elements, not the index of the last element. If you try to access rx[1] it will error as the array only has one element.This declares 5 channels c,rx[0],rx[1],tx[0],tx[1]
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
Oops my bad, I presume it's so you can pass the channel into the task rather than have it's ends auto allocated?
-
- XCore Addict
- Posts: 204
- Joined: Sun Jun 01, 2014 10:25 pm
Exactly my point, I cannot find information about this in the documentation.
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
Or allow for more than one Ethernet I guess
BTW which Ethernet demo are you referring to?
BTW which Ethernet demo are you referring to?
-
- XCore Addict
- Posts: 204
- Joined: Sun Jun 01, 2014 10:25 pm
It is the one referred to in the attached document.
You do not have the required permissions to view the files attached to this post.
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
OK looking at the code it is supporting multiple receiver and transmitter clients, hence the use of chan arrays rather than single channels. The full implementation is capable of using multiple TX/RX clients but the Light version uses single Rx,Tx not quite sure why it's organised this way, perhaps a common setup interface was desired.
You can take a look at the code underneath on github to see the differences between them (although there isn't a 'full' demo you can peruse the full implementation)
P.S. the AVB demo uses full implementation and multiple tx/rx clients although this is likely to add complexity (AVB) in understanding the ethernet stack.
regards
Al
You can take a look at the code underneath on github to see the differences between them (although there isn't a 'full' demo you can peruse the full implementation)
P.S. the AVB demo uses full implementation and multiple tx/rx clients although this is likely to add complexity (AVB) in understanding the ethernet stack.
regards
Al
-
- XCore Expert
- Posts: 968
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
Its the same as C, int x[1] declares an array of integers, length 1. Nothing whacky about channel-ends etc. Its just an array.gerrykurz wrote:Exactly my point, I cannot find information about this in the documentation.
They code probably uses an array (over a singular chan var) as some API it uses is expecting an array.
-
- XCore Expert
- Posts: 968
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
The comment in the code (wherever it came from) is wrong.Folknology wrote:Code: Select all
chan rx[1], tx[1]; // two arrays of 2 channels each