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 

Problems opening serial comm

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



Joined: 17 Oct 2005
Posts: 71
Location: New York

PostPosted: Tue Jul 18, 2006 6:38 am    Post subject: Problems opening serial comm Reply with quote

Hi,

I am having problems opening file descriptor to the serial port
The code below, mostly ripped of the lua player, always returns with:
"failed create SIO handle"
The PSP remote connector & the headphones are plugged in - They seem to send stuff back thru lua's serial echo script w/o any problems...

Any suggestions would be greatly appreciated...


Code:


#include <pspkernel.h>
#include <pspdebug.h>
#include <pspiofilemgr.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <psppower.h>
#include <unistd.h>
#include <sys/stat.h>

PSP_MODULE_INFO("Hello SIO", 0, 1, 1);
#define printf pspDebugScreenPrintf
#define SIO_IOCTL_SET_BAUD_RATE 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, 0, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}


static SceUID sio_fd = -1;
int baudRate = 2400;
char data[256];

int main() {
pspDebugScreenInit();
SetupCallbacks();
printf("Hello SIO\n");

if (sio_fd < 0) sio_fd = sceIoOpen("sio:", PSP_O_RDWR, 0777);
if (sio_fd < 0) {
        printf("failed create SIO handle.");
        sceKernelSleepThread();
        return 0;
}

printf("performing ioctl.\n");
sceIoIoctl(sio_fd, SIO_IOCTL_SET_BAUD_RATE, &baudRate, sizeof(baudRate), NULL, 0);

while (1) {
        int count = sceIoRead(sio_fd, data, 256);
        if (count > 0) printf("[%s]\n",data);

}

sceKernelSleepThread();
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