using ADHOC

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

Moderators: cheriff, TyRaNiD

Post Reply
floorball92
Posts: 30
Joined: Sat Apr 05, 2008 5:53 am
Location: Germany -> Hessen -> Hanau
Contact:

using ADHOC

Post by floorball92 »

Hi guys,

I need your help. I' m planing a new projetc needing ADHOC, the problem is, that I don' t know, how to use ADHOC. Kann someone post me a link to a Tut?? I want to know, how to build the connection, how to use it, mainly all. I now something about the C Programming but I' m not a pro, so give me the longest one you know xD

Great Whiches, Floorball92
Image
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

--pspZorba--
NO to K1.5 !
floorball92
Posts: 30
Joined: Sat Apr 05, 2008 5:53 am
Location: Germany -> Hessen -> Hanau
Contact:

Post by floorball92 »

http://rafb.net/p/94oL8w72.html

This works not so really good
Image
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

main.cpp:20:23: error: pspkernel.h: No such file or directory
main.cpp:21:22: error: pspdebug.h: No such file or directory
main.cpp:22:21: error: pspctrl.h: No such file or directory
main.cpp:23:20: error: pspsdk.h: No such file or directory
main.cpp:24:24: error: pspdisplay.h: No such file or directory
it means you miss the basic PSP headers, that's why you can't compile.
pb of path or sdk installation.[/quote]
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I had the same problems when I tried your source and dont tell me I dont have the headers..

So I gave up and continued my 3.xx adhoc code instead of using yours
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

Pirata Nervo

if you read the whole post (2 lines without the quote) you will have seen that i wrote :
...pb of path ...
which is the case if floorball92's install is the same as mine, the headers or not under:

/cygwin/usr/local/pspdev/include
cf:
psp-g++ -I. -IE:/cygwin/usr/local/pspdev/include
but under:
/cygwin/usr/local/pspdev/psp/sdk/include

which is certainly comming from the PSPSDK environment variable in the makefile.

solution : modify your makefile

I am sorry you gave up for something probably that simple.



floorball92:
I don't know if you are familliar with make/makefile/psp-g++, if you are not, there is a command which is very usefull: man

in a shell do man psp-g++ or man gcc (should be the same options) and man make. You will have a better comprehension of these tools options, and the basics to be able to compile.
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

what does "pb" mean? lol
I already changed -L/usr/local/pspdev/lib
to -L/usr/local/pspdev/psp/sdk/lib
and still getting errors
I did modify the makefile.
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

pb means : problem

-L is the gcc option for setting the path to librairies when linking

and the problem is a problem of path to headers (as the log shows it) when gcc is compiling.

The gcc option for setting the path to headers is -I

so you should have something like -IthePathToYourHeaders in your compile options of your makefile. you can set the path you want, even several -I.

It's often in a variable called INCDIR.


you should do a "man gcc " everything is explained even if not always easy to read
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I got it to work before by removing a few lines and replacing some.
This is what I get:

Code: Select all

ZBadhoc.cpp: In member function ‘int ZBadhoc::requestConnection(ZBremotePsp*)’:
ZBadhoc.cpp:351: error: invalid conversion from ‘char*’ to ‘unsigned char*’
ZBadhoc.cpp:351: error:   initializing argument 2 of ‘int sceNetAdhocMatchingSelectTarget(int, unsigned char*, int, int)’
ZBadhoc.cpp: In member function ‘void ZBadhoc::createMatching()’:
ZBadhoc.cpp:699: error: invalid conversion from ‘void (*)(int, int, char*, int, char*)’ to ‘void (*)(int, int, unsigned char*, int, void*)’
ZBadhoc.cpp:699: error:   initializing argument 9 of ‘int sceNetAdhocMatchingCreate(int, int, int, int, int, int, int, int, void (*)(int, int, unsigned char*, int, void*))’
ZBadhoc.cpp: In member function ‘ZBremotePsp* ZBadhoc::waitForConnection()’:
ZBadhoc.cpp:1002: error: invalid conversion from ‘char*’ to ‘unsigned char*’
ZBadhoc.cpp:1002: error:   initializing argument 2 of ‘int sceNetAdhocMatchingCancelTarget(int, unsigned char*)’
ZBadhoc.cpp:1010: error: invalid conversion from ‘char*’ to ‘unsigned char*’
ZBadhoc.cpp:1010: error:   initializing argument 2 of ‘int sceNetAdhocMatchingSelectTarget(int, unsigned char*, int, int)’
make: *** [ZBadhoc.o] Error 1

the errors appear where you do something like (char *)variable

Edit:

I changed the char* to unsigned char* and the only errors I get now are:

Code: Select all

ZBadhoc.cpp: In member function ‘void ZBadhoc::createMatching()’:
ZBadhoc.cpp:699: error: invalid conversion from ‘void (*)(int, int, char*, int, char*)’ to ‘void (*)(int, int, unsigned char*, int, void*)’
ZBadhoc.cpp:699: error:   initializing argument 9 of ‘int sceNetAdhocMatchingCreate(int, int, int, int, int, int, int, int, void (*)(int, int, unsigned char*, int, void*))’
make: *** [ZBadhoc.o] Error 1
Edit2:

Changed this line:

void matchingCB(int unk1, int event, char *macSource, int size, char *data)
to:
void matchingCB(int unk1, int event, unsigned char *macSource, int size, void *data)

fixes the problem.
Now I got this error:
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/bin/ld: cannot find -lpspnet_adhocmatching

I edited the LIBS in the makefile and I was getting this error:
cp eboot.pbp F:/PSP/GAME/test
cp: cannot stat `eboot.pbp': No such file or directory

removed the copy file part and the debug and compiled everything right.
Tested and run fine although something are not working like when I press [], it crashes if I press /\ on my other psp
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

That's strange you had to change the char * to unsigned char *


could you have a look at pspnet_adhocmatching.h

about line 110 do you have for sceNetAdhocMatchingSelectTarget :

int sceNetAdhocMatchingSelectTarget(int matchingId, char *mac, int unk3, int unk4);


and line 47 for MatchingCallback :

typedef void (*MatchingCallback)(int unk1, int event, char *mac2, int optLen, char *optData);


It looks like we don't have the same header may be one of us has a more recent version.


concerning the crash, I ve just re-run the sample, I ve no problem. could you see where it crashs?
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I updated the sdk 3 or 4 weeks ago.
pspnet_adhocmatching.h
$Id: pspnet_adhocmatching.h 2356 2008-01-15 23:50:17Z iwn $

int sceNetAdhocMatchingSelectTarget(int matchingId, unsigned char *mac, int unk3, int unk4);

MatchingCallBack:
typedef void (*MatchingCallback)(int unk1, int event, unsigned char *mac2, int optLen, void *optData);

What's your revicion number?

Edit: Im updating the sdk in case you have a more recent version

Edit 2: The functions are the same as the ones I said above so you need to rewrite your source (because it is crashing) or I need to edit my file lol.

Edit 3 (wow): I edited my pspnet_adhocmatching.h so it is the same as yours but still shuts down when sending/receiving..
Last edited by Pirata Nervo on Mon Apr 21, 2008 8:55 am, edited 1 time in total.
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

Mine is older than yours that's why you had to change the char * to unsigned char *.

I think I'll have to update mine.

Concerning the crash did you see where it happens ?
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Example:
First PSP -> Press [] or /\
Second PSP -> Press [] or /\
one of them crashes and shuts down
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

I update my sdk, and I'll check.
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

OK, thanks, post a working sample when you are done please.
Image
Upgrade your PSP
floorball92
Posts: 30
Joined: Sat Apr 05, 2008 5:53 am
Location: Germany -> Hessen -> Hanau
Contact:

Post by floorball92 »

I changed the path and get this:

Code: Select all

**** Build of configuration Default for project adhoc ****

make all 
make: *** No rule to make target `all'.  Stop.
Image
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

floorball92

just do "make" not "make all"
or add the target "all" in the makefile.

---------------------
Pirata Nervo,

I updated my sdk. the signature of some functions have changed from char * to unsigned char *. But nothing very important.

You just have to remove the casts (as the macAdresse is already an u8).
And adapt the signature of the matching callback.

You recompile and it works : if it still doesn't work, try the this eboot

if this eboot is working => you may have changed too many thing in the sample

if not ....what is your firmware? can you do game sharing with games such lumines ?
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

What do you mean by casts?
the (u8*) and (unsigned char*) or only the (u8*) ?
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

a cast is an explicit transformation of a type A in type B.

eg:

the old signatures of sceNetAdhocMatchingSelectTarget is:

int sceNetAdhocMatchingSelectTarget(int, char*, int, int) (<= see the 2nd arg)

But as my variable was an (u8 * ) which is the same as (unsigned char *). I had to cast it in (char *).

so the code is something like:

sceNetAdhocMatchingSelectTarget( .., (char*) myVariable , .., ..)


But you have the newer header, where the signature is

int sceNetAdhocMatchingSelectTarget(int, unsigned char*, int, int) (<= see the 2nd arg)

And the code is still :
sceNetAdhocMatchingSelectTarget( .., (char*) myVariable , .., ..)

so now you just have to remove the cast (char*) and it will compile like a charm.

that was the error line 351,1002,1010.

for the error line 699 it's similar and simpler, it's only the signature of the matching callback that has changed, so just change the signature of the function matchingCB, the second function in the source if I remember well.


If you want to use the code and adapt it to your own homebrew, you really have to read some books like thinking in C++ it's free and very good.
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

>.< I know what a cast is, I think I did not explain it right, sorry.
I just wanted to know what to change, if the char * only or the u8 * too.

I have got 3 C++ books and 2 C books ;)
I know how C++ works although I have not learned a lot of it as I don't have enough time to continue learning one of the books (I started learning one of the books but did not end it)

Edit:
Removed the (char *) from those lines
and changed in the callbacks function I changed the 1st char* to unsigned char* and the 2nd char* to void*

still crashes.
the eboot you give in your post works but not mine.
damn, lol
Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

ok your question made me think you had problems with casts.

So if the eboot I sent you is working and the one you compile doesn't, it means :
It's not a problem of context on you PSP, so nothing block the homebrew such as a pluggin or I don't not what, it means that all the prx etc are started correctly.

If you don't have even a warning during the compile phase (which should be the case).

There is only one possibility : the link.

could you show the compile option and libs you used ?
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

No warnings, no nothing lool.

Here's my makefile:

Code: Select all

##########################################################################

# This file is part of pspZorba samples.

#

#   pspZorba samples are free softwares&#58; you can redistribute it and/or modify

#   it under the terms of the GNU General Public License as published by

#   the Free Software Foundation, either version 3 of the License, or

#   &#40;at your option&#41; any later version.

#

#   pspZorba samples is distributed in the hope that it will be useful,

#   but WITHOUT ANY WARRANTY; without even the implied warranty of

#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

#   GNU General Public License for more details.

#

#   You should have received a copy of the GNU General Public License

#   along with pspZorba samples.  If not, see <http&#58;//www.gnu.org/licenses/>.

#

#########################################################################



#########################################################

#

#              pspZorba &#58; PSPlorer

#				www.pspzorba.com

#########################################################



# name displayed by the XMB

PSP_EBOOT_TITLE = pspZorba-ex028



# fisrt icon displayed &#40;*.PNG&#41;  by the XMB

PSP_EBOOT_ICON = NULL



# animation &#40;*.PMF&#41; displayed by the XMB

PSP_EBOOT_ANIM = NULL



# it's a picture &#40;*.PNG&#41;displayed after some seconds rather  with transparency to allow us to see the first icon and the anim.

PSP_EBOOT_FOREGROUND = NULL



# background image &#40;*.PNG&#41; displayed

PSP_EBOOT_BACKGROUND = NULL



# music &#40;*.AT3&#41; rather a loop but not mandatory

PSP_EBOOT_SND0 = NULL



CXXFLAGS = -g -G0 -Wall -O3 -D_PSP_FW_VERSION=380 -fno-rtti -fno-exceptions

INCDIR = -I. -I/home/piratanervo/meus/380Projects/_380SDK/include -I/usr/local/pspdev/psp/sdk/include

LIBDIR = -L. -L/usr/local/pspdev/psp/sdk/lib -L/home/piratanervo/meus/380Projects/_380SDK/lib -specs=/usr/local/pspdev/psp/sdk/lib/prxspecs -Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx

LIBS =  /usr/local/pspdev/psp/sdk/lib/prxexports.o -lstdc++ -lpspnet_adhocmatching -lpspnet_adhoc -lpspnet_adhocctl -lpspwlan -lpspnet -lpspusb -lpspusbstor -lpsppower -lpspgum -lpspgu -lm  -lpspumd -lpspctrl -lpspdebug -lpspge -lpspdisplay -lpspsdk -lc -lpspuser -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpspnet_inet -lpsputility



OBJECTS = main.o ZBadhoc.o

#########################################################



EBOOT.PBP&#58; PARAM.SFO a.prx $&#40;PSP_EBOOT_ICON&#41;  $&#40;PSP_EBOOT_FOREGROUND&#41; $&#40;PSP_EBOOT_BACKGROUND&#41; $&#40;PSP_EBOOT_ANIM&#41; $&#40;PSP_EBOOT_SND0&#41;

	pack-pbp $@ PARAM.SFO $&#40;PSP_EBOOT_ICON&#41; $&#40;PSP_EBOOT_ANIM&#41; $&#40;PSP_EBOOT_FOREGROUND&#41; $&#40;PSP_EBOOT_BACKGROUND&#41; $&#40;PSP_EBOOT_SND0&#41; a.prx NULL



PARAM.SFO&#58; a.prx

	mksfo $&#40;PSP_EBOOT_TITLE&#41; $@



a.prx&#58; a.elf

	psp-prxgen $< $@





a.elf&#58; $&#40;OBJECTS&#41; Makefile

	psp-gcc $&#40;CXXFLAGS&#41; $&#40;LIBDIR&#41; $&#40;OBJECTS&#41; $&#40;LIBS&#41; -o $@

	psp-fixup-imports  $@







main.o&#58; main.cpp ZBadhoc.h

	psp-g++ $&#40;INCDIR&#41;  $&#40;CXXFLAGS&#41; -c -o $@ $<





ZBadhoc.o&#58; ZBadhoc.cpp ZBadhoc.h

	psp-g++ $&#40;INCDIR&#41;  $&#40;CXXFLAGS&#41; -c -o $@ $<







NULL&#58;



cleanall&#58; clean



clean&#58;

	rm -f $&#40;OBJECTS&#41; a.elf a_strip.elf PARAM.SFO EBOOT.PBP




Image
Upgrade your PSP
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

I don't see anything wrong ...

last hypothesis :
- you may have remove/modify something in the code (not on purpose I mean)
or .... I don't know


so re-upload the sources here , use the makefile above, and recompile them (without any change at first), they are exactly the sources of the Eboot I sent you.

If it crashes ...then I am running out of idea
--pspZorba--
NO to K1.5 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I was using your released source code :|
I used your new code and it still crashes..damn
I will try to figure out the problem, I changed the makefile again to test if it was working or not but no luck
Image
Upgrade your PSP
Post Reply