QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

WLAN in user mode

This is a discussion on WLAN in user mode within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hi there, I'm developing a game that uses WLAN and a GFX-Lib(I want to use OSLib). The problem is: WLAN ...

Reply
 
LinkBack Thread Tools
Old 03-25-2008, 04:31 PM   #1
 
Join Date: Oct 2007
Posts: 15
Trader Feedback: 0
Default WLAN in user mode

Hi there,
I'm developing a game that uses WLAN and a GFX-Lib(I want to use OSLib). The problem is: WLAN has to be initialized in kernel mode, and the gfx-libs don't want to work in kernel mode. I heard that you can use WLAN in user mode, but I didn't find a real example about this. Could someone _please_ post a complete example on how to use WLAN in user mode (source+makefile)? If it's possible, without threading. I have read some other threads about this, but the examples were not complete or didn't work. This makes me really crazy, because I spent a lot of time in trying many things before I noticed that my gfx-libs don't work in kernel mode...
Cya, Zwergengraf
Zwergengraf is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-25-2008, 04:34 PM   #2

OMFG
 
Slasher's Avatar
 
Join Date: Jul 2005
Location: Toronto
Posts: 2,816
Trader Feedback: 0
Default

Use
Code:
sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
to load the modules in usermode rather than having to in kernel.
Slasher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-27-2008, 01:52 PM   #3
 
Join Date: Oct 2007
Posts: 15
Trader Feedback: 0
Default

Hi,
could you please post a complete example? I tried the source from HERE, but it doesn't work. I get one of these errors: 00000017 when it should initialize the PSP_NET_MODULE_COMMON, or the game starts but returns to XMB and sayes 8002013A.
Zwergengraf
Zwergengraf is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-29-2008, 07:04 AM   #4

OMFG
 
Slasher's Avatar
 
Join Date: Jul 2005
Location: Toronto
Posts: 2,816
Trader Feedback: 0
Default

I forgot to mention you have to be running in the 3.xx kernel

Code:
// Load modules
sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);

// Get connections

// Connect
int connectTo(int connectNum)
{
	int err;
	int stateLast = -1;

	// WLAN
	err = pspSdkInetInit();
	if (err != 0)
	{
		printf("Error pspSdkInetInit() \n");
		sceKernelDelayThread(2000*1000);
	}

	err = sceNetApctlConnect(connectNum);
	if (err != 0)
	{
		printf("Error sceNetApctlConnect() \n");
		sceKernelDelayThread(2000*1000);
	}

	sceNetResolverCreate(&resolverId, resolverBuffer, sizeof(resolverBuffer));
    
	while (1)
	{
		int state;
		int err = sceNetApctlGetState(&state);
		if (err != 0)
		{
			printf("Error at state %i \n", state);
			sceKernelDelayThread(2000*1000);
			return 0; // connection failed
		}

		if (state > stateLast)
		{
			printf("State %i \n", state);
			stateLast = state;
		}

		if (state == 4)
			break;  // connected with static IP

		// wait a little before polling again
		sceKernelDelayThread(200*1000); // 200 ms
	}

	return 1;
}
Slasher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-29-2008, 10:49 AM   #5
 
Join Date: Oct 2007
Posts: 15
Trader Feedback: 0
Default

Okay thanks, I tried this code:

----------
Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <psputility_netmodules.h>
#include <psputility_netparam.h>
#include <pspwlan.h>
#include <pspnet.h>
#include <pspnet_apctl.h>

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO("test", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
   sceKernelExitGame();
   return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
   int cbid;

   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);
   sceKernelSleepThreadCB();

   return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
   int thid = 0;

   thid = sceKernelCreateThread("update_thread", CallbackThread,
                 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
   if(thid >= 0)
   {
      sceKernelStartThread(thid, 0, 0);
   }

   return thid;
}

int connectTo(int connectNum)
{
	int err;
	int stateLast = -1;

	// WLAN
	err = pspSdkInetInit();
	if (err != 0)
	{
		printf("Error pspSdkInetInit() \n");
		sceKernelDelayThread(2000*1000);
	}

	err = sceNetApctlConnect(connectNum);
	if (err != 0)
	{
		printf("Error sceNetApctlConnect() \n");
		sceKernelDelayThread(2000*1000);
	}

	//sceNetResolverCreate(&resolverId, resolverBuffer, sizeof(resolverBuffer));
    
	while (1)
	{
		int state;
		int err = sceNetApctlGetState(&state);
		if (err != 0)
		{
			printf("Error at state %i \n", state);
			sceKernelDelayThread(2000*1000);
			return 0; // connection failed
		}

		if (state > stateLast)
		{
			printf("State %i \n", state);
			stateLast = state;
		}

		if (state == 4)
			break;  // connected with static IP

		// wait a little before polling again
		sceKernelDelayThread(200*1000); // 200 ms
	}

	return 1;
}

int main(){
    SetupCallbacks();
    pspDebugScreenInit(); 
    // Load modules
    if (sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON) < 0)
    {
      printf("Error, could not load PSP_NET_MODULE_COMMON\n");
      sceKernelSleepThread();
    }
    if (sceUtilityLoadNetModule(PSP_NET_MODULE_INET) < 0)
    {
      printf("Error, could not load PSP_NET_MODULE_INET\n");
      sceKernelSleepThread();
    } 
    printf("Connecting...");
    connectTo(1);
    sceKernelSleepThread();
    return 0;
}
----------
and this makefile:
----------
Code:
TARGET = netsample
OBJS = main.o

INCDIR = 
CFLAGS = -O0 -G0 -Wall -g
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

PSP_FW_VERSION = 380

LIBDIR =

EXTRA_TARGETS = EBOOT.PBP

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
----------

compiled it with "make kxploit", then I put it into GAME and the program displayed:

Connecting...Error pspSdkInetInit()
Error sceNetApctlConnect()
Error at state -2012413952

At least it loads the modules, thats good! But what is wrong now? I hope you (or someone else ) can help me.
Thanks, Zwergengraf
Zwergengraf is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-29-2008, 11:17 AM   #6

Developer
 
Join Date: Mar 2006
Posts: 1,026
Trader Feedback: 0
Default

Hi.

Add BUILD_PRX=1 to your Makefile.

Compile with make only.

Place the EBOOT in a directory on GAME3XX.

Run.
__________________

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197

Quote:
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
Insert_Witty_Name is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-29-2008, 03:34 PM   #7
 
Join Date: Oct 2007
Posts: 15
Trader Feedback: 0
Default

OMFG, IT WORKS! Ouh, I can't say how much you have helped me with this! I want to thank you two very much!

Edit: Well, it doesn't work 100%: everytime I try to draw an image with blitAlphaImageToScreen, it crashes. It doesn't fail at loading the image. What's wrong?

Zwergengraf

Last edited by Zwergengraf; 03-29-2008 at 04:33 PM..
Zwergengraf is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-30-2008, 02:00 PM   #8

OMFG
 
Slasher's Avatar
 
Join Date: Jul 2005
Location: Toronto
Posts: 2,816
Trader Feedback: 0
Default

Maybe buffer overflow?
Slasher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
mode , user , wlan

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 12:28 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us