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 

error code in compiling

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



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 4:33 am    Post subject: error code in compiling Reply with quote

as you can tell im a noob seeking for help
lol

the problem is that im geting this error in my psp program

Quote:
main.c (86) : warning: passing argument 1 of 'sceIoRead' makes integer from pointer without a cast
main.c (87) : warning: passing argument 1 of 'sceIoWrite' makes integer from pointer without a cast


and here are lines 86 and 87

Code:
bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);


can anyone help me?
Back to top
View user's profile Send private message Visit poster's website
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Mon Mar 30, 2009 5:21 am    Post subject: Re: error code in compiling Reply with quote

PsPfReAK wrote:
as you can tell im a noob seeking for help
lol

the problem is that im geting this error in my psp program

Quote:
main.c (86) : warning: passing argument 1 of 'sceIoRead' makes integer from pointer without a cast
main.c (87) : warning: passing argument 1 of 'sceIoWrite' makes integer from pointer without a cast


and here are lines 86 and 87

Code:
bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);


can anyone help me?


Code:
bytesRead = sceIoRead(*InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(*OutputFilePointer, buffer, bytesRead);

_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 5:34 am    Post subject: Re: error code in compiling Reply with quote

Code:
bytesRead = sceIoRead(*InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(*OutputFilePointer, buffer, bytesRead);
[/quote]

okay, something must be wrong with my code

is this correct to flash a vshmain.prx or any file



Code:
int flash_file(char *file, char *buf, int size) {
    p2c("Writing File %s.... ", file);
    fd = sceIoOpen(file, PSP_O_WRONLY | PSP_O_CREAT| PSP_O_TRUNC, 0777);
    if(fd < 0) {
          TextColor(RED);
          ErrorExit(5000, "\n\nCannot open file for writing.\n"); }
    written = sceIoWrite(fd, buf, size);
    if(written != file_size) {
               sceIoClose(fd);
               TextColor(RED);
               ErrorExit(5000, "\n\nCannot write file.\n"); }
    sceIoClose(fd);
    p2c("OK\n\n");
    return 0; }
// copies the binary file contents from the input file to the output file
int copyFileContents(SceUID* InputFilePointer, SceUID* OutputFilePointer)
{
   int readsize=512; // just an arbitrary value, generally larger chunks are faster in file copies due to the way sectors are handled on disk writes
   u8 buffer[readsize];
   int bytesRead, bytesWritten;
   bytesRead = sceIoRead(*InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(*OutputFilePointer, buffer, bytesRead);
   if(bytesWritten != bytesRead)
   {
      // write error
      return -1;
   }
   return 1; // bytecopy successful
}
Back to top
View user's profile Send private message Visit poster's website
MBx



Joined: 22 Mar 2009
Posts: 35

PostPosted: Mon Mar 30, 2009 5:55 am    Post subject: Reply with quote

why u passed pointers to "copyFileContents"?

Code:
int copyFileContents(SceUID InputFilePointer, SceUID OutputFilePointer)
...
   bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);
...
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 6:09 am    Post subject: Reply with quote

MBx wrote:
why u passed pointers to "copyFileContents"?

Code:
int copyFileContents(SceUID InputFilePointer, SceUID OutputFilePointer)
...
   bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);
...


so it will copy the data inside the file aswell as the actual file, i thought this would work but it doesnt, i still get an empty file
Back to top
View user's profile Send private message Visit poster's website
MBx



Joined: 22 Mar 2009
Posts: 35

PostPosted: Mon Mar 30, 2009 6:37 am    Post subject: Reply with quote

SceUID is just an ID, a number! nothing will copy into it!

did u tried my code?
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 6:44 am    Post subject: Reply with quote

MBx wrote:
SceUID is just an ID, a number! nothing will copy into it!

did u tried my code?


Code:
int copyFileContents(SceUID InputFilePointer, SceUID OutputFilePointer)
...
   bytesRead = sceIoRead(InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(OutputFilePointer, buffer, bytesRead);
...


this one?

yup, did the same thing

would this be correct, if so i'll do a re-write of the code

Code:

fd= sceioopen("ms0:/test.txt", PSP_O_RDONLY)

sceiowrite(flash0:/test.txt", PSP_OWRONLY | PSP_O_CREAT



???
its supposed to flash test.txt to flash 0 ?


Last edited by PsPfReAK on Mon Mar 30, 2009 6:51 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
MBx



Joined: 22 Mar 2009
Posts: 35

PostPosted: Mon Mar 30, 2009 6:46 am    Post subject: Reply with quote

can you paste the complete code here please?
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 6:55 am    Post subject: Reply with quote

MBx wrote:
can you paste the complete code here please?


okay

Code:
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>

////////////////////////////////////////////////////////////////////////////////
#define MODULE "test"
////////////////////////////////////////////////////////////////////////////////
PSP_MODULE_INFO(MODULE, 0x0800, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VSH);
////////////////////////////////////////////////////////////////////////////////
#define p2c pspDebugScreenPrintf
#define RED 0x111FFF
#define WHITE 0xFFFFF1
#define GREEN 0x0000FF00
#define TextColor pspDebugScreenSetTextColor
#define ClearScreen pspDebugScreenClear
#define test_size 13
char test_buffer[test_size];
int readSize;

////////////////////////////////////////////////////////////////////////////////
char msg[256];
int cbid;
int thid;
int written;
int file_size;
/////
SceUID fd;
/////
////////////////////////////////////////
int exit_callback(int arg1, int arg2, void *common) {
    sceKernelExitGame();
   return 0; }
////////////////////////////////////////
int CallbackThread(SceSize args, void *argp) {
    cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCallback(cbid);
    sceKernelSleepThreadCB();
   return 0; }
////////////////////////////////////////
int SetupCallbacks(void) {
    thid = 0;
    thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
    if (thid >= 0)
   sceKernelStartThread(thid, 0, 0);
    return thid; }
////////////////////////////////////////
void ErrorExit(int milisecs, char *fmt, ...) {
   va_list list;
   va_start(list, fmt);
   vsprintf(msg, fmt, list);
   va_end(list);
   p2c(msg);
   sceKernelDelayThread(milisecs*1000);
   sceKernelExitGame(); }
////////////////////////////////////////
int flash_file(char *file, char *buf, int size) {
    p2c("Writing File %s.... ", file);
    fd = sceIoOpen(file, PSP_O_WRONLY | PSP_O_CREAT| PSP_O_TRUNC, 0777);
    if(fd < 0) {
          TextColor(RED);
          ErrorExit(5000, "\n\nCannot open file for writing.\n"); }
    written = sceIoWrite(fd, buf, size);
    if(written != file_size) {
               sceIoClose(fd);
               TextColor(RED);
               ErrorExit(5000, "\n\nCannot write file.\n"); }
    sceIoClose(fd);
    p2c("OK\n\n");
    return 0; }
////////////////////////////////////////
void remove_files(char *files) {
     p2c("Removing File %s....", files);
     sceIoRemove(files);
     p2c("OK\n"); }
////////////////////////////////////////
// copies the binary file contents from the input file to the output file
int copyFileContents(SceUID* InputFilePointer, SceUID* OutputFilePointer)
{
   int readsize=512; // just an arbitrary value, generally larger chunks are faster in file copies due to the way sectors are handled on disk writes
   u8 buffer[readsize];
   int bytesRead, bytesWritten;
   bytesRead = sceIoRead(*InputFilePointer, buffer, readSize);
   bytesWritten = sceIoWrite(*OutputFilePointer, buffer, bytesRead);
   if(bytesWritten != bytesRead)
   {
      // write error
      
      return -1;
   }
   return 1; // bytecopy successful
}
///////////////////////////////////////
int main() {
   pspDebugScreenInit();
   TextColor(WHITE);
   SetupCallbacks();
       
   p2c("test to\n");
    p2c("flash test.txt with contents to flash0:/\n");
    p2c("To do so Press X to start at your own risk, R to exit.\n\n");
   
   while (1) {
        SceCtrlData pad;
        sceCtrlReadBufferPositive(&pad, 1);

      if (pad.Buttons & PSP_CTRL_CROSS) {
                        p2c("Assigning flash0.... ");                       
                        if (sceIoUnassign("flash0:") < 0)
                        p2c("Cannot Un-Assign flash0:");
                        if (sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0) < 0) {
                                             p2c("Error Assigning flash0 in write mode"); }
                        p2c("OK\n\n");
                       
                        flash_file("flash0:/test.txt", test_buffer, test_size);
                        break; }

      else if (pad.Buttons & PSP_CTRL_RTRIGGER) {
             p2c("\n\nExited by the user");
             sceKernelExitGame(); }

      sceKernelDelayThread(10000); }
      
      p2c("\n\nPress X to Exit");
      
      while (1) {
        SceCtrlData pad;
        sceCtrlReadBufferPositive(&pad, 1);

      if (pad.Buttons & PSP_CTRL_CROSS) {
                        break; }

      sceKernelDelayThread(10000); }
   
   sceKernelExitGame();

   return 0; }
Back to top
View user's profile Send private message Visit poster's website
MBx



Joined: 22 Mar 2009
Posts: 35

PostPosted: Mon Mar 30, 2009 7:04 am    Post subject: Reply with quote

your code compiled well on my PC, I haven't test it to see if it works or not but it compiled.

do you have a compile problem?
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 7:19 am    Post subject: Reply with quote

MBx wrote:
your code compiled well on my PC, I haven't test it to see if it works or not but it compiled.

do you have a compile problem?


no it compiled fine, but say if you put the test.txt in the same directory as the eboot (with txt in it) it only flashes an empty file, or it may just fail...

i'll check back here later or tomorrow, thank you for your helo so far
Back to top
View user's profile Send private message Visit poster's website
NoEffex



Joined: 27 Nov 2008
Posts: 108

PostPosted: Mon Mar 30, 2009 7:37 am    Post subject: Reply with quote

Just a shot in the dark, but in the if(fd < 0) in the flash_file function, try

if(fd <= 0)

because it looks fine, writewise.
_________________
Programming with:
Geany + Latest PSPSDK from svn
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Mon Mar 30, 2009 7:45 am    Post subject: Reply with quote

NoEffex wrote:
Just a shot in the dark, but in the if(fd < 0) in the flash_file function, try

if(fd <= 0)

because it looks fine, writewise.


write failed

again, another blank text.txt....

just so all of you know, the text.txt is in the same directory as the eboot.pbp

ie psp/game/test <here lies the eboot.pbp and test.txt
Back to top
View user's profile Send private message Visit poster's website
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Mon Mar 30, 2009 9:22 am    Post subject: Reply with quote

sceIoWrite needs aligned buffers, which you might not have. Unless you really know what you're doing, just use the standard functions like open() and write() instead, as they already take care of this sort of thing.
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Tue Mar 31, 2009 2:05 am    Post subject: Reply with quote

jimparis wrote:
sceIoWrite needs aligned buffers, which you might not have. Unless you really know what you're doing, just use the standard functions like open() and write() instead, as they already take care of this sort of thing.


how do i use these?

do you mean sceioopen and sceiowrite??
Back to top
View user's profile Send private message Visit poster's website
NoEffex



Joined: 27 Nov 2008
Posts: 108

PostPosted: Tue Mar 31, 2009 5:18 am    Post subject: Reply with quote

I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....
_________________
Programming with:
Geany + Latest PSPSDK from svn
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Tue Mar 31, 2009 5:47 am    Post subject: Reply with quote

NoEffex wrote:
I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....


okay, that works, it flashes the text what ever is in the brackets, but how do i use this if i wanna say for example copy a prx or rco over?
Back to top
View user's profile Send private message Visit poster's website
NoEffex



Joined: 27 Nov 2008
Posts: 108

PostPosted: Tue Mar 31, 2009 7:31 am    Post subject: Reply with quote

PsPfReAK wrote:
NoEffex wrote:
I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....


okay, that works, it flashes the text what ever is in the brackets, but how do i use this if i wanna say for example copy a prx or rco over?
You'd fill the buffer with whatever data(And you'd need to make the buffer big enough, too).
_________________
Programming with:
Geany + Latest PSPSDK from svn
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Tue Mar 31, 2009 8:06 am    Post subject: Reply with quote

NoEffex wrote:
PsPfReAK wrote:
NoEffex wrote:
I think it's because you're writing test_buffer, which is empty. I'm almost positive this is the problem.

To confirm, do something like

sprintf(test_buffer, "Test");

right before flash_file("flash0....


okay, that works, it flashes the text what ever is in the brackets, but how do i use this if i wanna say for example copy a prx or rco over?
You'd fill the buffer with whatever data(And you'd need to make the buffer big enough, too).


so input the adrress where "Test" was?
Back to top
View user's profile Send private message Visit poster's website
NoEffex



Joined: 27 Nov 2008
Posts: 108

PostPosted: Tue Mar 31, 2009 3:54 pm    Post subject: Reply with quote

What do you mean?

If you mean changing test_buffer and size and such, then test_buffer and the size argument would just be changed to the buffer containing the binary(and if it was large, you'd do a loop)

i.e.

Code:
int flash_file(char *filedest, char *filesrc)
{
   int fd0 = sceIoOpen(filesrc, PSP_O_RDONLY, 0777);
   int fd1;
   if(fd0 <= 0) return -1;//No good, head back with error
   int len = sceIoLseek(fd0, 0, 2); sceIoLseek(fd0, 0, 0);//2 means SEEK_END, just a habit I have. Grabs the length of the file. Then it returns to the beginning.
   char buffer[0x1000];//We'll use a buffer the size of 0x1000 for this.
   //Loop time
   int byteswritten;
   fd1 = sceIoOpen(filedest, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);//open up dest in create, truncate, and write mode
   while(byteswritten < len)
   {
      int counter = len-byteswritten;//Just to make things easier
      sceIoRead(fd0, buffer, counter >= 0x1000? 0x1000: 0x1000-counter);//If counter is greater than 0x1000, then go ahead and do it normally, else get the difference, so we don't overwrite.
      byteswritten += sceIoWrite(fd1, buffer, counter >= 0x1000? 0x1000: 0x1000-counter);//Write the same condition as before
      sceIoLseek(fd0, byteswritten, 0); sceIoLseek(fd1, byteswritten, 0);//Seek to the offset on both
   }
   return 0;//Return no error
}


If there are errors, my bad, it's 2 in the morning.
_________________
Programming with:
Geany + Latest PSPSDK from svn
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Wed Apr 01, 2009 1:27 am    Post subject: Reply with quote

NoEffex wrote:
What do you mean?

If you mean changing test_buffer and size and such, then test_buffer and the size argument would just be changed to the buffer containing the binary(and if it was large, you'd do a loop)

i.e.

Code:
int flash_file(char *filedest, char *filesrc)
{
   int fd0 = sceIoOpen(filesrc, PSP_O_RDONLY, 0777);
   int fd1;
   if(fd0 <= 0) return -1;//No good, head back with error
   int len = sceIoLseek(fd0, 0, 2); sceIoLseek(fd0, 0, 0);//2 means SEEK_END, just a habit I have. Grabs the length of the file. Then it returns to the beginning.
   char buffer[0x1000];//We'll use a buffer the size of 0x1000 for this.
   //Loop time
   int byteswritten;
   fd1 = sceIoOpen(filedest, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);//open up dest in create, truncate, and write mode
   while(byteswritten < len)
   {
      int counter = len-byteswritten;//Just to make things easier
      sceIoRead(fd0, buffer, counter >= 0x1000? 0x1000: 0x1000-counter);//If counter is greater than 0x1000, then go ahead and do it normally, else get the difference, so we don't overwrite.
      byteswritten += sceIoWrite(fd1, buffer, counter >= 0x1000? 0x1000: 0x1000-counter);//Write the same condition as before
      sceIoLseek(fd0, byteswritten, 0); sceIoLseek(fd1, byteswritten, 0);//Seek to the offset on both
   }
   return 0;//Return no error
}


If there are errors, my bad, it's 2 in the morning.


haha 2, so im gonna try and copy npaste this over my int flash_file and insert the file source and dest????

and what do know an error, lol

main.c: In function 'flash_file':
main.c (71) : warning: 'byteswritten' may be used uninitialized in this function

and line 71

while(byteswritten < len)

anyone????
Back to top
View user's profile Send private message Visit poster's website
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