sceWlanGetEtherAddr error?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

sceWlanGetEtherAddr error?

Post by liquid8d »

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
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

This is because you are outputing the string incorrectly... sceWlanGetEtherAddr fills in a 12-byte unsigned char array. To output it, doing:

Code: Select all

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)
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Post by jsgf »

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.
Post Reply