Hello everyone,
I'm trying to make a networking application and I think it would be better if it will run in User Mode.
But here is the problem, pspSdkLoadInetModules can be called only from the Kernel Mode. If I don't call it, and call only pspSdkInetInit - it says error 8002013A (LIBRARY_NOT_YET_LINKED).
So, is it possible to use Internet in User Space mode and how? Maybe I have to link the libs via Makefile somehow (static?).
BTW: do I have to call pspSdkInetInit from a new thread or it can be called from the main() function?
Thanks,
Alekz
P.S. I've run through various example codes, forum posts, but haven't found an answer yet - most of the code runs in the Kernel Mode there.
Wi-Fi in User Mode
There's a way to do it with a function from sceUtility (sceUtilityLoadNetModule, if I recall correctly). But it only works on firmware 2.0 and higher.
The only sane way I'm aware of to do wifi that works on all firmwares is to use the traditional kernel-mode initialisation technique that you'll find in the samples, and let eLoader automatically translate it into the user-mode version for you when you run it on FW 2.00+.
The only sane way I'm aware of to do wifi that works on all firmwares is to use the traditional kernel-mode initialisation technique that you'll find in the samples, and let eLoader automatically translate it into the user-mode version for you when you run it on FW 2.00+.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
The PSP Homebrew Database needs you!
I just tried it and it works. Instead of the pspSdkLoadInetModules() use the following:
Regards,
Andreas
Code: Select all
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();
}
Andreas
Thanks for the info guys!
I've tried using the sceUtilityLoadNetModule functions - and they didn't return error, so it looks like they work. But, when I call pspSdkInetInit, it again says error 8002013A. I thought maybe sceUtilityLoadNetModule already inits the modules, so I tried to connect to an access point, without the pspSdkInetInit. But it resulted in 8002013A too.
@powARman - did you try it on 2.XX or 1.5 firmware?
I've tried using the sceUtilityLoadNetModule functions - and they didn't return error, so it looks like they work. But, when I call pspSdkInetInit, it again says error 8002013A. I thought maybe sceUtilityLoadNetModule already inits the modules, so I tried to connect to an access point, without the pspSdkInetInit. But it resulted in 8002013A too.
@powARman - did you try it on 2.XX or 1.5 firmware?
I tried it on 271SE-B'', startet from GAME271 directory, so it runs in 2.x mode. I can successfully connect to my access point using WPA, so its definitely 2.x, cause 1.5 does not support WPA.
This is the litte program I used, I build it with "make all" using standard pspsdk Makefile:
Regards,
Andreas
This is the litte program I used, I build it with "make all" using standard pspsdk Makefile:
Code: Select all
#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, 0);
/* 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 connect_to_apctl(int config) {
int err;
int stateLast = -1;
if (sceWlanGetSwitchState() != 1)
pspDebugScreenClear();
while (sceWlanGetSwitchState() != 1) {
pspDebugScreenSetXY(0, 0);
printf("Please enable WLAN to continue.\n");
sceKernelDelayThread(1000 * 1000);
}
err = sceNetApctlConnect(config);
if (err != 0) {
printf("sceNetApctlConnect returns %08X\n", err);
return 0;
}
printf("Connecting...\n");
while (1) {
int state;
err = sceNetApctlGetState(&state);
if (err != 0) {
printf("sceNetApctlGetState returns $%x\n", err);
break;
}
if (state != stateLast) {
printf(" Connection state %d of 4.\n", state);
stateLast = state;
}
if (state == 4) {
break;
}
sceKernelDelayThread(50 * 1000);
}
printf("Connected!\n");
sceKernelDelayThread(3000 * 1000);
if (err != 0) {
return 0;
}
return 1;
}
char *getconfname(int confnum) {
static char confname[128];
sceUtilityGetNetParam(confnum, PSP_NETPARAM_NAME, (netData *)confname);
return confname;
}
int net_thread(SceSize args, void *argp)
{
int selComponent = 1;
printf("Using connection %d (%s) to connect...\n", selComponent, getconfname(selComponent));
if (connect_to_apctl(selComponent))
{
char szMyIPAddr[32];
if (sceNetApctlGetInfo(8, szMyIPAddr) != 0)
strcpy(szMyIPAddr, "unknown IP address");
printf("IP: %s\n", szMyIPAddr);
sceKernelSleepThread();
}
return 0;
}
int InitialiseNetwork(void)
{
int err;
printf("load network modules...");
err = sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
if (err != 0)
{
printf("Error, could not load PSP_NET_MODULE_COMMON %08X\n", err);
return 1;
}
err = sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
if (err != 0)
{
printf("Error, could not load PSP_NET_MODULE_INET %08X\n", err);
return 1;
}
printf("done\n");
err = pspSdkInetInit();
if (err != 0)
{
printf("Error, could not initialise the network %08X\n", err);
return 1;
}
return 0;
}
/* Simple thread */
int main(int argc, char **argv)
{
SceUID thid;
SetupCallbacks();
pspDebugScreenInit();
if (InitialiseNetwork() != 0)
{
sceKernelSleepThread();
}
thid = sceKernelCreateThread("net_thread", net_thread, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);
if (thid < 0) {
printf("Error! Thread could not be created!\n");
sceKernelSleepThread();
}
sceKernelStartThread(thid, 0, NULL);
sceKernelExitDeleteThread(0);
return 0;
}
Andreas
hi!
i tryied to make a app with WPA wi-fi user mode support. (on 3.0X OE)
but im fail... this returns false.
look this simple example: http://www.megaupload.com/?d=1ULAWXFC
thanks!
i tryied to make a app with WPA wi-fi user mode support. (on 3.0X OE)
but im fail... this returns false.
look this simple example: http://www.megaupload.com/?d=1ULAWXFC
thanks!
*eyelash
PSP TA-082 with FW 3.03 OE-A2
PSP TA-082 with FW 3.03 OE-A2