forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adhoc questiion

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Thu Nov 13, 2008 10:19 pm    Post subject: Adhoc questiion Reply with quote

Hi Guys,
I just started playing with Adhoc between two PSPs,
and got streaming data working in both 1.50 and 3.xx,
but all sample code seems to send data in only one direction from the Server to the Client.

Clearly for a game to work, the Server PSP would need to know what's going on
with the Client PSP as well.

Is there any sample code to show data flow in both directions?
Cheers, Art.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu Nov 13, 2008 11:55 pm    Post subject: Reply with quote

That depends on what protocol you're using.

Are you using PDP, PTP or GameMode?
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Fri Nov 14, 2008 12:45 am    Post subject: Reply with quote

No idea,
The only samples I have are all similar to this loop
Code:

int user_main(SceSize args, void *argp){

   SetupCallbacks();

   static char buffer[0x8000];
   unsigned int length;
   int err, bD = 0;
   int i, done, mainDone, server=0;
   
   char *data;
   int size = 0;
   
   SceCtrlData pad;
   
   pspDebugScreenInit();
   
   do {
   
      if((adhocInit("") >= 0) && ((server = adhocSelect()) >=0)){
         
         pspDebugScreenPrintf("\n\n## AdHoc INITALISED ##\n\n");
         
         sceKernelDelayThread(1000000);
         
         if(server)
            pspDebugScreenPrintf("Server Assigned\n\n");
         else
            pspDebugScreenPrintf("Client Assigned\n\n");

         if(server){
            sceKernelDelayThread(5000000);
            done = 0;
            do {
               sceCtrlReadBufferPositive(&pad, 1);
               if(pad.Buttons != 0)
                  if(pad.Buttons & PSP_CTRL_CROSS)
                     done = 1;
               
               if((i % 2) == 0){
                  data = ".";
                  i = 0;
               } else
                  data = "|";
               i++;
               
               if(done == 1)
                  data = "x";
               size = sizeof(data);
               
               err = adhocSendRecvAck(&size, 4);
               err = adhocSendRecvAck(&data, 4);  //# send data
               
               pspDebugScreenPrintf("%s", data);
            } while(done==0);
            
         } else {
            done = 0;
            do {
               //sceCtrlReadBufferPositive(&pad, 1);
               //if(pad.Buttons != 0)
               //   if(pad.Buttons & PSP_CTRL_CROSS)
               //      done = 1;
               
               size = 0;
               length = 4;
               err = adhocRecvSendAck(&size, &length);
               
               length = size;
               err = adhocRecvSendAck(&data, &length);
               data = (char *)data;
               
               if(data == "x")
                  done = 1;
               
               pspDebugScreenPrintf("%s", data);
            } while(done==0);
            
         }
      
      }
      
      pspDebugScreenPrintf("\n\n");
      
      adhocTerm();
      
      done = 0;
      pspDebugScreenInit();
      pspDebugScreenPrintf("\n\nPress START to Exit, X to Continue\n\n");
      do {
         sceCtrlReadBufferPositive(&pad, 1);
         if(pad.Buttons != 0){
            if(pad.Buttons & PSP_CTRL_START){
               done = 1; mainDone=1;
               sceKernelExitGame();
            }
            if(pad.Buttons & PSP_CTRL_CROSS)
               done = 1; mainDone=0;
         }
      } while(!done);
      
   } while(!mainDone);
   
   //pspDebugScreenPrintf("Press any key to exit..\n");
   //done = 0;
   //do {
   //   sceCtrlReadBufferPositive(&pad, 1);
   //   if(pad.Buttons != 0)
   //      done = 1;
   //} while(!done);
   
   sceKernelExitGame();
}


If there is a more efficient (faster way, I'd love to see a sample).
Maybe the updated sdk has some, but I'll never get to see those by updating. It's only ever worked the once.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Fri Nov 14, 2008 1:04 am    Post subject: Reply with quote

I think those functions are from PSPPet's original adhoc sample code, which is almost 3 years old.

You would be better to update your SDK, I've added lots of adhoc goodies over the past months.

The code from PSPPet's sample uses PDP (similar to UDP) and it is possible to send in both directions.

If I recall correctly the adhoc adhocSendRecvAck() function sends some data, then waits for a response from the receiver to acknowledge.

You also have the option of PTP, which is peer-to-peer and is perfect for two way transmission between two PSPs.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Fri Nov 14, 2008 7:37 am    Post subject: Reply with quote

The SDK I use is about as old as it gets, but there are some extra libs I've collected.
If I update a lot of my stuff stops working, and I only know that from a precompiled toolchain I've tried on another op system
I can't (in practice) upgrade the normal way if I wanted to (ie. sh /toolchain.sh 6 doesn't do anything).

Quote:
f I recall correctly the adhoc adhocSendRecvAck() function sends some data, then waits for a response from the receiver to acknowledge.


The adhocSendRecvAck() is being used to both send and receive in this code,
but depending only on whether the PSP is the client or server.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
pspjoke



Joined: 23 Jun 2008
Posts: 14

PostPosted: Fri Nov 14, 2008 8:37 pm    Post subject: Reply with quote

Art wrote:
The adhocSendRecvAck() is being used to both send and receive in this code,
but depending only on whether the PSP is the client or server.


nope..

notice to send the function is
Code:
adhocSendRecvAck


and to receive is

Code:
adhocRecvSendAck


im using this same code, just starting on ad-hoc as well.

and i also ported zorbas adhoc sample to the new sdk..
but ... you only need the old one so.. pointless to mention, w/e
take a look at zorbas sample as well, theres much to learn if you look at both.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Fri Nov 14, 2008 9:55 pm    Post subject: Reply with quote

I did just notie that today ;) I was seeing the same command.

Now I suppose I need to figure out how to send other types of variables.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
pspjoke



Joined: 23 Jun 2008
Posts: 14

PostPosted: Sat Nov 15, 2008 9:17 am    Post subject: Reply with quote

Art wrote:
I did just notie that today ;) I was seeing the same command.

Now I suppose I need to figure out how to send other types of variables.


lol, i don't think thats to hard.

what im trying to do is find the perfect delay between sending two things.

you can either have lag and no loss sync, or you can have near perfect response but you can bet at some point you will loose sync.
_________________
The people here make me feel like shit :/
Way to advanced... (hate being a programming noob.)
Back to top
View user's profile Send private message
phobox



Joined: 24 Mar 2008
Posts: 140

PostPosted: Sat Nov 15, 2008 10:51 pm    Post subject: Reply with quote

pspjokeand wrote:
i also ported zorbas adhoc sample to the new sdk..


please, can you post it?
_________________
Ciao! from Italy
Back to top
View user's profile Send private message
pspjoke



Joined: 23 Jun 2008
Posts: 14

PostPosted: Sat Nov 15, 2008 11:54 pm    Post subject: Reply with quote

phobox wrote:
pspjokeand wrote:
i also ported zorbas adhoc sample to the new sdk..


please, can you post it?


sure http://www.mediafire.com/?2mzxd5mgnnu
_________________
The people here make me feel like shit :/
Way to advanced... (hate being a programming noob.)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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