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 

Help, I'm a newbie

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



Joined: 04 Feb 2007
Posts: 1

PostPosted: Sun Feb 04, 2007 7:22 am    Post subject: Help, I'm a newbie Reply with quote

Hi, I'm new, notice the '1' post count, well I'm also new to PSP developing (after finally downgrading my PSP). Well I'm interested in Ir applications, and decided to forgo and make one, I thought somthing simple, somthing which will send back the data received after a short timespace.
Well it sounded easy, but its not working. Can anybody see anything obviously wrong with it....

Code:

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspsircs.h>
#include <stdlib.h>
#include <string.h>

#define printf   pspDebugScreenPrintf

PSP_MODULE_INFO("IrDA Relay", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

void delay_loop(int num) {
   if (num <= 0) return;
   for (; num > 0; num--)
      sceDisplayWaitVblankStart();
}

int exit_callback(void)
{
   sceKernelExitGame();
   return 0;
}

void CallbackThread(void *arg)
{
   int cbid;

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

   sceKernelSleepThreadCB();
}

int SetupCallbacks(void)
{
   int thid = 0;

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

   return thid;
}

/*
*Main Function
*/

int main(int argc, char *argv[]) {
   SceCtrlData pad;
   SetupCallbacks();
   pspDebugScreenInit();
   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
   
   printf("IrDA Relay\n-Will send the same signal back\n--several seconds after recieving it.\n\n");
   
   int fd = sceIoOpen("irda0:", PSP_O_RDWR, 0);
    
   if (fd < 0) {
      printf("ERROR: Could not open irda device!\n");
      printf("Press any button to exit...\n");
      while (pad.Buttons == 0) {
         delay_loop(2);
         sceCtrlReadBufferPositive(&pad, 1);
      }
      return -1;
   }
   
   while (1) {
       unsigned char data;
       data = sceIoRead(fd, &data, 32);

      if (data <= 32) {
              delay_loop(50);
              sceIoWrite(fd, &data, 32);
              printf("%c", data);
       }   
        sceDisplayWaitVblankStart();
     }
    sceIoClose(fd);
   return 0;
}
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