ng_net: changed semantic of get and set command slightly#2598
ng_net: changed semantic of get and set command slightly#2598haukepetersen merged 3 commits intoRIOT-OS:masterfrom
Conversation
sys/shell/commands/sc_netif.c
Outdated
There was a problem hiding this comment.
Where does the user get this information? Why do we need it in addition to MAX_ADDR_LEN?
There was a problem hiding this comment.
This parameter is basically used to distinguish between different address types (short/long). If the user does not specify any length, there would be no way in knowing which address the user wants to know...
|
We also should note, that most drivers will error if |
|
Apart from the split of the shell command, which seems a bit nonsensical to me 👍 |
|
(it also would collide with #2581 ;-P) |
I don't get why you need 3 parameters for |
sys/shell/commands/sc_netif.c
Outdated
There was a problem hiding this comment.
So is addr_len the maximum length now or the exact length? I think your change to set(), though understandable to keep it same to get(), is unclear here.
There was a problem hiding this comment.
Okay… I guess I have to be clearer here: What I normally do with array-like values like addresses: I call ng_netapi_set(dev, NETCONF_OPT_ADDRSS, 0, addr, sizeof(addr)), where addr is an array of arbitrary length. Would this be an error case? If yes, why?
There was a problem hiding this comment.
The meaning of the len parameter is quite straight forward in my opinion. When calling set, you specify the length of the given address (as you state in your example above). For interfaces, that support addresses of different length, this parameter can be used to detect which address should be set (short vs. long address). So it is possible to set both addresses with the same function.
When calling get, the max_len parameter is used in the same way. If I would just give the MAX_ADDR_LEN, the driver would have no means of finding out, which address is actually requested. By setting max_len to say 2 or 8, the driver can read from this context, which address the user wants to read.
So for set, the len parameter defines the exact length of the data to be written to the device. For get, the max_len parameter defines for one the maximum number of bytes that can be written to the data buffer, but gives also a context for the amount of data that is expected.
Clearer now?
|
The third parameter for The |
0a250ac to
67b1237
Compare
|
After re-consideration, it was decided that the idea of a unified shell command might not be as good as I thought. So I took the changes to the netif shell commands out of this PR... |
|
The reason is that is a times difficult to know the exact addr length, when using the get command in an automated environment (as for example the |
|
ACK. Waiting for travis to be happy :-) |
|
Travis is happy. And go. |
ng_net: changed semantic of get and set command slightly
When working with netdev/netapi, I found the get function over complicated. This PR simplifies the semantics a little by making use of the
netdev->get()functions return value (like every Linux programmer would expect)...So when reading for example a network address from a device, the max_length parameter can be used to specify how many bytes should be read. The device driver can then take from this number which address it should read, e.g. a 802.15.4 device returns the short address if 2 byte are asked for and the long address if 8 byte are asked for...