Thread: vinculum II pendrive interfacing

  1. #1
    Registered User
    Join Date
    Dec 2011
    Location
    Skudai, Johor, Malaysia, Malaysia
    Posts
    14

    vinculum II pendrive interfacing

    hello all, i want to ask about the vinculum. what i want to do is to read some file in the usb pendrive. but what i want to do is, i want it to saperate into some folder. i manage to read/write file without the folder buat when the file is in the folder and i want to write the file into the folder, it cannot be done. i had alreadygo though the other forum, example, etc, but still cannot solve for this vinculum. can anyone help me? A.S.A.P please

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Welcome to the forum, Mohd Zhafri!

    We would have to see your code that you tried, before we could comment on how to proceed.

    I see no reason why this can't be done, but all the details have to be known, before we can be sure.

    Be sure to use [code] tags on both ends of your code. Otherwise the forum software turns it into HTML mush.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Reading and writing files on a pen drive is the same as reading and writing any other file...

  4. #4
    Registered User
    Join Date
    Dec 2011
    Location
    Skudai, Johor, Malaysia, Malaysia
    Posts
    14
    as i had said before, i already can read and write the file into pendrive. i'm using fopen, fread,fwrite.
    but when it comes to read and write file in the folder, it cannot be done on the vinculum.

    [fileRead = fopen("read.TXT", "a+");]
    [file = fopen("TEST.TXT", "a+");]

    is it cannot directly put the "\" to epen the containing file in the folder?

  5. #5
    Registered User mdj441's Avatar
    Join Date
    Aug 2011
    Location
    NYS, USA
    Posts
    18
    Maybe this thread helps? You seem to be having the same problem.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Yes, you need to double up on the backslashes in your string literal, to make it acceptable to C, since '\' is the escape char.

  7. #7
    Registered User
    Join Date
    Dec 2011
    Location
    Skudai, Johor, Malaysia, Malaysia
    Posts
    14
    i had tried all the suggestion that you all ad suggest, but the output is bad.. =(

    as you said before, use the double backslash also cannot solve the problem. some new file appear on my pendrive name exactly like the path that i want to open. what i'm already tried is the:

    1) [fileRead = fopen("F:\\02\\read.txt", "r");]
    [file = fopen("F:\\02\\TEST.txt","w");]

    2) [fileRead = fopen("02\\read.txt", "r");]
    [file = fopen("02\\TEST.txt","w");]

    3) [fileRead = fopen("read.txt", "r");]
    [file = fopen("TEST.txt","w");]

    only the number 3 get the correct output and can write some text into the TEST.txt file.
    is it cannot be done on the vinculum II SOC?

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You have the pen drive as the F drive?

    Why are you using square brackets around your fopen line of code? (for the forum, use code tags, [the # icon in the advanced editor] and put your code right between the code tags it gives you.

    Check that you can create a new file on your pen drive, using notepad, or some other program.

    As a last resort, replace the backslashes, with just one forward slash char: "\\" gets changed to "/".

  9. #9
    Registered User mdj441's Avatar
    Join Date
    Aug 2011
    Location
    NYS, USA
    Posts
    18
    If you can access it as F:\ from everywhere else, you should be able to do it that same way using fopen().

    some new file appear on my pendrive name exactly like the path that i want to open.
    Isn't that what you want?

    I would only blame it on fopen() if it returns NULL in both cases (and read.txt exists).

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Mohd Zhafri View Post
    i had tried all the suggestion that you all ad suggest, but the output is bad.. =(

    as you said before, use the double backslash also cannot solve the problem. some new file appear on my pendrive name exactly like the path that i want to open. what i'm already tried is the:

    1) [fileRead = fopen("F:\\02\\read.txt", "r");]
    [file = fopen("F:\\02\\TEST.txt","w");]

    2) [fileRead = fopen("02\\read.txt", "r");]
    [file = fopen("02\\TEST.txt","w");]

    3) [fileRead = fopen("read.txt", "r");]
    [file = fopen("TEST.txt","w");]

    only the number 3 get the correct output and can write some text into the TEST.txt file.
    is it cannot be done on the vinculum II SOC?
    Tell me... does a folder F:\02 exist on that pendrive?
    If it does not you need to create it before you can open a file in it.

    Is your drive letter correct?

  11. #11
    Registered User
    Join Date
    Dec 2011
    Location
    Skudai, Johor, Malaysia, Malaysia
    Posts
    14
    Quote Originally Posted by CommonTater View Post
    Tell me... does a folder F:\02 exist on that pendrive?
    If it does not you need to create it before you can open a file in it.

    Is your drive letter correct?
    yes...that folder exist. but still cannot read and write on that folder.
    sorry Adak if i'm misunderstood what you told before about the "[ ]". =)

    may i know what do you mean by
    As a last resort, replace the backslashes, with just one forward slash char: "\\" gets changed to "/".

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Mohd Zhafri View Post
    yes...that folder exist. but still cannot read and write on that folder.
    sorry Adak if i'm misunderstood what you told before about the "[ ]". =)

    may i know what do you mean by
    Is this by chance a Windows 7 system?

    If it is you may need to take ownership of the pendrive before you can write to it...

    Computer -> right click the drive -> Properties -> security tab -> advanced button -> owner tab -> Edit -> select your name -> click "Replace owner on all files and folders"... click OK.

    Try again.

    It it's not Windows 7 ... never mind.

  13. #13
    Registered User
    Join Date
    Dec 2011
    Location
    Skudai, Johor, Malaysia, Malaysia
    Posts
    14
    Quote Originally Posted by CommonTater View Post
    Is this by chance a Windows 7 system?

    If it is you may need to take ownership of the pendrive before you can write to it...

    Computer -> right click the drive -> Properties -> security tab -> advanced button -> owner tab -> Edit -> select your name -> click "Replace owner on all files and folders"... click OK.

    Try again.

    It it's not Windows 7 ... never mind.
    yes...i'm using windows 7
    Computer -> right click the drive -> Properties -> security tab -> advanced button -> owner tab -> Edit -> select your name -> click "Replace owner on all files and folders"... click OK.
    i cannot find the security tab. only have general tab,tools tab,hardware tab,sharing tab,ready boost tab and customize tab

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Mohd Zhafri View Post
    yes...i'm using windows 7


    i cannot find the security tab. only have general tab,tools tab,hardware tab,sharing tab,ready boost tab and customize tab
    Ok... so it's formatted with FAT32 ... no worries.

    Now we know your problem is elsewhere...
    Post your complete code as it is now, lets see what we're up against.

  15. #15
    Registered User
    Join Date
    Dec 2011
    Location
    Skudai, Johor, Malaysia, Malaysia
    Posts
    14
    Quote Originally Posted by CommonTater View Post
    Ok... so it's formatted with FAT32 ... no worries.

    Now we know your problem is elsewhere...
    Post your complete code as it is now, lets see what we're up against.
    what do you mean by formatted with FAT32?

    this is my function that contain the code

    Code:
    void firmware()
    {
        FILE *file;
        FILE *fileRead;
        long lSize;
        char * buffer;
        char buf[100];
        size_t result;
        gpio_ioctl_cb_t gpio_iocb;
        unsigned char leds;
    
        open_drivers();
    
        gpio_iocb.ioctl_code = VOS_IOCTL_GPIO_SET_MASK;
        gpio_iocb.value = 0xff;
        vos_dev_ioctl(hGPIO_PORT_A, &gpio_iocb);
    
        do
        {
            if (usbhost_connect_state(hUSBHOST_2) == PORT_STATE_ENUMERATED)
            {
                hBOMS = boms_attach(hUSBHOST_2, VOS_DEV_BOMS);
    
                if (hBOMS == NULL)
                {
                    leds = led3;
                    vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
                    vos_delay_msecs(1000);
                    break;
                }
    
                hFAT_FILE_SYSTEM = fat_attach(hBOMS, VOS_DEV_FAT_FILE_SYSTEM);
    
                if (hFAT_FILE_SYSTEM == NULL)
                {
                    leds = led3;
                    vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
                    vos_delay_msecs(1000);
                    break;
                }
    
                fsAttach(hFAT_FILE_SYSTEM);
                fileRead = fopen("F:\\02\\read.txt", "r");
                file = fopen("F:\\02\\write.txt","w");
                if (file == NULL)
                {
                    leds = led3;
                    vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
                    vos_delay_msecs(1000);
                    break;
                }
    
                  fseek (fileRead , 0 , SEEK_END);
                  lSize = ftell (fileRead);
                  rewind (fileRead);
    
                buffer = (char*) malloc (sizeof(char)*lSize);
                result = fread (buffer,1,50,fileRead);
    
                if (fwrite((buffer), strlen(buffer), sizeof(char), file) == -1)
                {
                    leds = led3;
                    vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
                    vos_delay_msecs(1000);
                }
                if (fclose(file) == -1)
                {
                    leds = led3;
                    vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
                    vos_delay_msecs(1000);
                }
                if (fclose(fileRead) == -1)
                {
                    leds = led3;
                    vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
                    vos_delay_msecs(1000);
                }
    
                leds = led1;
                vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
    
                fat_detach(hFAT_FILE_SYSTEM);
                boms_detach(hBOMS);
    
                leds = 0;
                vos_dev_write(hGPIO_PORT_A, &leds, 1, NULL);
    
                vos_delay_msecs(5000);
            }
        }
        while (1);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. interfacing c and java..
    By vapanchamukhi in forum C Programming
    Replies: 4
    Last Post: 09-18-2008, 02:10 PM
  2. I screwed my pendrive
    By abh!shek in forum Tech Board
    Replies: 0
    Last Post: 06-30-2008, 01:32 PM
  3. interfacing with a program
    By Crazed in forum Windows Programming
    Replies: 10
    Last Post: 03-17-2008, 05:29 AM
  4. Interfacing with LISP with C
    By ssharish2005 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 12-14-2007, 07:42 PM
  5. interfacing assembler with c++
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2001, 12:13 AM

Tags for this Thread