-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a reason for so many MAC formats? #20
Comments
The 2 int version is the internal storage which is done so that we can be sure of the alignment of the address. The 6 char is the external representation which sort of is how you would think of a mac address as a general user, i think. i'm not sure what the 6 int is about - maybe an error |
There's probably a few reasons for the disparities between formats. One format might be suitable for reading from OTP, another might be more suitable for sending down a channel end (it's more efficient to send 2 ints than 6 chars or ints). Another might need to be endian reversed in a char buffer for sending over the network. I agree it can be confusing and we should probably try to provide some sort of wrapper that uses a common format that maps to the function-specific format. |
Yes, I am with ajwlucas theory. It seems the same to me. for passing the MAC in function references often 6 ints are used. It is often packed into 2 ints. In reality it is 6 chars. I suggest for future version to simlpy stick to the 2 (unsigned) int and streamline all function calls to this. It is short, easy to store and simple. Perhaps in a format that it can be easily transformed into a 6 (theoretically 8) byte array. Just a feature request to make the source more easily accessible |
Suggestion: And while we are at it I managed to confuse how the server handles the mac address. It expects a two integer array, build by mapping the 6 chars into it. And it even provides a function to retrieve the mac via it's communication channel. I think those aspects could be better documented since I assumed that I have to read the mac adress from the OTP several times or copy it into different arrays - even though it can be easily obtined from the ethernet server, which seems to be the proper way. |
You are correct. The way to get at the MAC address post initialization is to use the tx_server channel and the get function. It only needs to be retreived from the OTP once at initialization time. I think that having an 8 byte MAC address would be confusing, since it is really only 6 bytes long, and it wouldn't be immediately clear what the endianness or alignment is. |
Yes, but having several different formats depending on the function is not helping either ;) typedef struct { or something similar. |
While browsing through the source and the demo source I have encountere three different formats for MAC addresses in the source code:
6 characters
6 int
2 int
Is it useful? It always puzzles me which format to use and how to reformat the mac address.
Or am I missing something completely.
The text was updated successfully, but these errors were encountered: