 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
liquid8d
Joined: 30 Jun 2005 Posts: 66
|
Posted: Mon Sep 19, 2005 10:44 am Post subject: sceWlanGetEtherAddr error? |
|
|
Using sceWlanGetEtherAddr the call worked for me the first time, however, subsequent calls now yield the following:
00:00:00:00:FFFFFF00:00
instead of
00:00:00:00:00:00
didn't use actual mac but I think you see what I mean. I did this also with the wlan sample and returns the same thing now.
LiQuiD8d |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Wed Sep 21, 2005 5:14 pm Post subject: |
|
|
This is because you are outputing the string incorrectly... sceWlanGetEtherAddr fills in a 12-byte unsigned char array. To output it, doing:
| Code: |
char addr[12];
unsigned short* saddr = (unsigned short*)addr;
sceWlanGetEtherAddr(&addr);
sprintf(buffer, "%2X:%2X:%2X:%2X:%2X:%2X", saddr[0], saddr[1], saddr[2], saddr[3], saddr[4], saddr[5] );
|
should work.. if there are typos I'm sorry.
The problem is that you are inherintly converting one of the numbers into an int, and since the int isnt initialized except for the lowest two bytes, it contains garbage... sometimes 0xFFFFFFF, sometimes 0x00000... maybe sometimes 0xDEADBEEF... who knows. If you want to continue to treat them as ints, you can also do: (intvalue & 0xFF) |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Thu Sep 22, 2005 8:22 am Post subject: |
|
|
| Actually, it just looks like sign-extension, rather than uninitialized stuff. The original poster's example is misleading, because they replaced the MAC address with all 0s; the example should read ffffff80 (or something). If you use an unsigned char [] for the mac address, it should be OK. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|