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 

My USB plugin doesn't work properly

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



Joined: 24 Feb 2008
Posts: 31

PostPosted: Mon Nov 24, 2008 11:08 pm    Post subject: My USB plugin doesn't work properly Reply with quote

Why my psp show the Sony error screen when I try this code :


Code:


#include <pspkernel.h>
#include <pspiofilemgr.h>
#include <pspsdk.h>
#include <stdio.h>
#include <string.h>
#include <psploadexec_kernel.h>
#include <psploadcore.h>
#include <pspsysmem.h>
#include <pspsysmem_kernel.h>
#include <systemctrl.h>
#include <psppower.h>
#include <pspctrl.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <pspusbbus.h>
#include <pspdisplay_kernel.h>
#include <pspmodulemgr_kernel.h>
#include <kubridge.h>

#include <pspdisplay.h>


PSP_MODULE_INFO("Brightnes USB 1.0", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);   



static int curBrightness = 0;

int USB_GetState(void)
{
    int k1 = pspSdkSetK1(0);
           
    sceDisplayGetBrightness(&curBrightness, 0);
         sceDisplaySetBrightness(0, 0);
            
   
    pspSdkSetK1(k1);
   
    return 0;
   

}

int USB_Stop(void)
{
   int k1 = pspSdkSetK1(0);
                         
 sceDisplaySetBrightness(curBrightness, 0);

    
   
    pspSdkSetK1(k1);
   
    return 0;
   

}


int module_start(SceSize args, void *argp)
{
   
       
       u32 x = sctrlHENFindFunction("sceThreadManager" ,"ThreadManForUser", 0xAA73C935);
   x = sctrlHENFindFunction("sceUSB_Driver", "sceUsb", 0xC21645A4);
   sctrlHENPatchSyscall(x, USB_GetState);
   x = sctrlHENFindFunction("sceUSB_Driver", "sceUsb", 0xC2464FA0);
   sctrlHENPatchSyscall(x, USB_Stop);
   
        return 0;
}         
   
     
                 
   

           
           
   
Back to top
View user's profile Send private message
blu_eye4



Joined: 26 Oct 2008
Posts: 37

PostPosted: Tue Nov 25, 2008 12:15 am    Post subject: Reply with quote

what type of error does PSP show?
Back to top
View user's profile Send private message
nikocronaldo



Joined: 24 Feb 2008
Posts: 31

PostPosted: Tue Nov 25, 2008 12:29 am    Post subject: Reply with quote

blu_eye4 wrote:
what type of error does PSP show?


PSP shows the following error when I connect again to the USB Mode:

Code:
An internal error has ocurred (80243101)
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Tue Nov 25, 2008 2:49 am    Post subject: Reply with quote

You are not calling original functions, wo aht you would expect?
Your GetState and Stop functions should call original functions for this to work.
Back to top
View user's profile Send private message
Mashphealh



Joined: 28 Nov 2007
Posts: 18

PostPosted: Tue Nov 25, 2008 4:40 am    Post subject: Reply with quote

Yes, you don't call original function. Try using this code :

int USB_GetState(void)
{
int k1 = pspSdkSetK1(0);

sceDisplayGetBrightness(&curBrightness, 0);
sceDisplaySetBrightness(0, 0);


pspSdkSetK1(k1);

return sceUsbGetState();


}

int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);

sceDisplaySetBrightness(curBrightness, 0);



pspSdkSetK1(k1);

return sceUsbStop(driverName, size, args);


}

M33's vshctrl patches sceUsbStop also, so I don't know if now usbdevice works for you.
Back to top
View user's profile Send private message
nikocronaldo



Joined: 24 Feb 2008
Posts: 31

PostPosted: Tue Nov 25, 2008 4:51 am    Post subject: Reply with quote

moonlight wrote:
You are not calling original functions, wo aht you would expect?
Your GetState and Stop functions should call original functions for this to work.


The PSP crashes with the original functions, with the same Mashphealt's code, why moonlight?
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Tue Nov 25, 2008 5:01 am    Post subject: Reply with quote

The usb stop function should be like this. The original function must be executed between the k1 stuff. This doesn't matter in the GetState one.

Quote:

int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
int ret = sceUsbStop(driverName, size, args)
pspSdkSetK1(k1);
return ret;
}
Back to top
View user's profile Send private message
nikocronaldo



Joined: 24 Feb 2008
Posts: 31

PostPosted: Tue Nov 25, 2008 5:15 am    Post subject: Reply with quote

moonlight wrote:
The psp stop function should be like this. The original function must be executed between the k1 stuff. This doesn't matter in the GetState one.

Quote:

int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
int ret = sceUsbStop(driverName, size, args)
pspSdkSetK1(k1);
return ret;
}



It crashes again, why?

Quote:
int USB_GetState(void)
{
int k1 = pspSdkSetK1(0);

sceDisplayGetBrightness(&curBrightness, 0);
sceDisplaySetBrightness(0, 0);


pspSdkSetK1(k1);

return 0;


}

int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
int ret = sceUsbStop(driverName, size, args);
pspSdkSetK1(k1);
return ret;
}
Back to top
View user's profile Send private message
blu_eye4



Joined: 26 Oct 2008
Posts: 37

PostPosted: Tue Nov 25, 2008 6:34 am    Post subject: Reply with quote

maybe, if you want make a prx you haven't to give 0x1000 at PSP_MODULE_INFO, maybe...
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Tue Nov 25, 2008 7:07 am    Post subject: Reply with quote

Do a test commenting the calls to the display functions, to see if it crashes too or not.
Back to top
View user's profile Send private message
nikocronaldo



Joined: 24 Feb 2008
Posts: 31

PostPosted: Wed Nov 26, 2008 1:10 am    Post subject: Reply with quote

moonlight wrote:
Do a test commenting the calls to the display functions, to see if it crashes too or not.


Prx still crashes, any idea?
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Wed Nov 26, 2008 3:57 am    Post subject: Reply with quote

A suggestion, When you ask for something post the entire code, the makefile and give more infos, I can't see your actual code...
Anyway if I'm right you want to hook the usb load?
To do this use the m33 module handler, is better then hook some functions I think...
Sorry for my english...
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