C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von slicer4ever char mac_address[7] //7 because thats what the function says to have If it is 7 maybe it ...
-
05-17-2007, 03:55 PM #4501QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- France
- Beiträge
- 753
- Points
- 5.784
- Level
- 49
- Downloads
- 0
- Uploads
- 0
If it is 7 maybe it is in hexadecimal format ? What is retrieved in your char?
Zitat von slicer4ever
++ B.
-
05-17-2007, 03:58 PM #4502QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
nothing thats the prob
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-17-2007, 04:00 PM #4503words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
slicer -
Try that maybe?Code:char *mac_address; sceWlanGetEtherAddr(mac_address); if(mac_address < 0) //zomg ERROR!
If not, change the mac_address[7] to [8] ;) you didnt count the '\0'
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
05-17-2007, 04:13 PM #4504QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- France
- Beiträge
- 753
- Points
- 5.784
- Level
- 49
- Downloads
- 0
- Uploads
- 0
WHat do you mean by "nothing" ??
random code or nothing like "00" ?
++ B.
-
05-17-2007, 04:24 PM #4505QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
@sg57
when i used *mac_address it just crashed my program;
@maxi when i say nothing i mean i do: osl_Printf_xy(400,40,"%s" ,mac_address);
and i have the color set to red yet nothing appears
however the command says it returns a 0 if it works and it currently is showing a 0 it's just not saveing the mac address into my sting1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-17-2007, 04:29 PM #4506QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Code:char *mac_address = (char *) malloc(sizeof(char) * 8);
-
05-17-2007, 04:31 PM #4507
- Registriert seit
- May 2007
- Beiträge
- 6
- Points
- 3.266
- Level
- 35
- Downloads
- 0
- Uploads
- 0
Maybe try:
Code:char macaddr[20]; int test = sceWlanGetEtherAddr(macaddr); if (test < 0) { printf("Error"); } else { printf("%s",macaddr); }
-
05-17-2007, 04:32 PM #4508Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Update your SDK, that function prototype was changed when I submitted a bug report.
The mac info is actually stored in an array of unsigned char[7].
Actually from what I've seen it looks like a union of unsigned char mac (6 bytes) and unsigned char reserved? (2 bytes), but it matters not.
Code:unsigned char macAddr[7]; memset(macAddr, 0, 7); sceWlanGetEtherAddr(macAddr); pspDebugScreenPrintf("%02X:%02X:%02X:%02X:%02X:%02X", macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
05-17-2007, 04:37 PM #4509QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
o thanks for the telling me i would have never figured that out insert
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-17-2007, 04:42 PM #4510QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- France
- Beiträge
- 753
- Points
- 5.784
- Level
- 49
- Downloads
- 0
- Uploads
- 0
I told you it was in hexa ;)
%x is used to print hexadecimal values.
++ B.
-
05-17-2007, 04:46 PM #4511Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Actually, I'm surprised no-one picked up on it earlier.
Each value in a mac address ranges from 00 to FF (hex), which is 0 - 255 in decimal form.
A char only accepts values from -128 to 127, whereas an unsigned char takes 0 to 255.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
05-17-2007, 04:51 PM #4512It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yeah but, say I did this:
char signed_byte = 255 //signed_byte now equals -127
It accepts it, it just wraps it around. In C at least, I dunno about in C++.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-17-2007, 04:54 PM #4513QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Thank you dude.
Zitat von hallo007
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
05-17-2007, 04:59 PM #4514Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
As an unsigned char, a mac might look like this:
As a char, it would look like:Code:00:01:4A:81:5D:A7
Code:00:01:4A:FFFFFF81:5D:FFFFFFA7

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
05-17-2007, 05:16 PM #4515It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yeah, if you converted it to int and then to unsigned int.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-17-2007, 05:23 PM #4516Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Try it, I assure you char or unsigned char will print exactly as I've shown.

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
05-17-2007, 05:34 PM #4517It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I've never tried printf("%u",(char)foo); before, so I wouldn't really know. printf probably converts it internally if that's the case.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-17-2007, 08:08 PM #4518QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
arg can some1 help me some more i hate asking questions but i've never worked with these functions so i need some help
Spoiler for code form pspnet_adhoc.h:
can someone give me an example of how that is surpose to work when properly called this is as far as i've goten:
sprintf(mac_address_true, "%02X%02X%02X%02X%02X%02X ", mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5]);
int pdp = sceNetAdhocPdpCreate(mac_ address_true,0x309,0x400, 0);
it keeps returning a negative number and as far as i can see that the mac should look like:
05d4c3b21a
however i'm not 100 % sure1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-18-2007, 03:36 AM #4519QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Right i've searched around a bit but now gave up:
How do you use C++ for the PSP, and can you therefore use libraries such as the string, and sstream libraries ?
Thanks,
MiG
-
05-18-2007, 03:38 AM #4520QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
*Smacks head against another wall*
Add '-lstdc++' to you libs line of your makefile.
-
05-18-2007, 03:44 AM #4521QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Thanks.
Zitat von PSPJunkie_
No need to be an ass about it tho.. Searching C++ just retrieves blank results on the forum.
I tried to search, and gave up..
Jeez.
-= Double Post =-
Right, just tried this, and i've tried
#include <string>
but it still doesn't like me declaring strings with the usual "string x" or watever.Geändert von MiG (05-18-2007 um 03:47 AM Uhr) Grund: Automerged Doublepost
-
05-18-2007, 03:51 AM #4522QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Dude, I don't care what you say. This topic has come up several times, both here and on PSP-Programming.
Geändert von PSPJunkie_ (05-18-2007 um 04:01 AM Uhr)
-
05-18-2007, 03:56 AM #4523QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Well some links would be nice.
Zitat von PSPJunkie_
I'd love a comprehensive set of instructions to using c++ on the PSP.
-
05-18-2007, 04:53 AM #4524QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
The order of libs matters for some reason when linking to the C++ STL libraries. I don't have it with me but I post it up later.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-18-2007, 05:14 AM #4525QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
thanks.
Zitat von yaustar
-
05-18-2007, 10:23 AM #4526QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
any1?
Zitat von slicer4ever
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-18-2007, 10:27 AM #4527Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
you are trying to make an adhoc connection?
-
05-18-2007, 10:29 AM #4528QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
yes
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-18-2007, 11:22 AM #4529Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
http://www.psp-programming.com/forum...hp?topic=473.0
A example , it's a bit more then just a function
-
05-18-2007, 11:24 AM #4530QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
thanks
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum