Shop OBEX P1 Docs P2 Docs Learn Events
SimpleIDE and multiple .cogc files — Parallax Forums

SimpleIDE and multiple .cogc files

Mark MaraMark Mara Posts: 64
edited 2014-02-03 23:03 in Learn with BlocklyProp
I am having a problem using SimpleIDE to build a project that contains three .cogc files. The compiler seems to be only generating a global symbol (_load_start_FILENAME_cog ) for the first .cogc file.

When the project contains only one .cogc file it works fine. When I add a second .cogc file I get an unresolved reference error. For example, if I add a file, cogA.cogc, to the project. I can reference it using _load_start_cogA_cog. However, if I add a second .cogc file, cogB.cogc, I get an unresolved reference error when I try to reference _load_start_cogB_cog.

e1.jpg


Is there an example of using SimpleIDE to build a project containing more than one .cogc file?

Thanks.
1024 x 256 - 41K
e1.jpg 40.9K

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-09-08 10:10
    Would you be able to post your example so I can have a look?

    Thanks.
    --Steve
  • Mark MaraMark Mara Posts: 64
    edited 2013-09-08 11:21
    jazzed wrote: »
    Would you be able to post your example so I can have a look?

    Thanks.
    --Steve

    Thanks for offering to take a look.

    main routine: cog_test.c
    /**
     * This is the main cog_test program file.
     */
    #include <stdio.h>
    #include <unistd.h>
    #include <propeller.h>
    #include "cog_test.h"
    #include "simpletools.h"                      // Include simpletools library 
    
    /* control block for cogA */
    struct {
        unsigned stack[STACK_SIZE_A];
        volatile struct cogA_mailbox A;
    } parA;
    
    /* control block for cogB */
    struct {
        unsigned stack[STACK_SIZE_B];
        volatile struct cogB_mailbox B;
    } parB;
    
    /* start cogA */
    void startA(volatile void *parptr)
    {
        extern unsigned int _load_start_cogA_cog[];
    #if defined(__PROPELLER_XMM__) || defined(__PROPELLER_XMMC__)
        load_cog_driver_xmm(_load_start_cogA_cog, 496, (uint32_t *)parptr);
    #else
        cognew(_load_start_cogA_cog, parptr);
    #endif
    }
    
    /* start cogB */
    void startB(volatile void *parptr)
    {
        extern unsigned int _load_start_cogB_cog[];
    #if defined(__PROPELLER_XMM__) || defined(__PROPELLER_XMMC__)
        load_cog_driver_xmm(_load_start_cogB_cog, 496, (uint32_t *)parptr);
    #else
        cognew(_load_start_cogB_cog, parptr);
    #endif
    }
    
    int main(void)
    {
        sleep(2);  
    /* start the A cog */
        printf("starting cogA\n");
        startA(&parA.A);
        printf("%s\n",parA.A.cog_message);
    
    /* start the B cog */
        printf("starting cogB\n");
        startB(&parB.B);
        printf("%s\n",parB.B.cog_message);
    
    /* loop forever */
        while(1) {
            sleep(2);
            printf("cogA: %s\n",parA.A.cog_message);
            printf("cogB: %s\n",parB.B.cog_message);
        }
        return 0;
    }
    

    header file: cog_test.h
    #ifndef __COG_TEST_H__
    #define __COG_TEST_H__
    
    #define STACK_SIZE_A 16
    #define STACK_SIZE_B 16
    #define COG_MESSAGE_SIZE    128
    
    struct cogA_mailbox {
        int     data;
        char    cog_message[COG_MESSAGE_SIZE];
    };
    
    struct cogB_mailbox {
        int     data;
        char    cog_message[COG_MESSAGE_SIZE];
    };
    
    #endif
    
    first .cogc file: cogA.cogc
    #include <propeller.h>
    #include "cog_test.h"
    
    _NATIVE
    void main (struct cogA_mailbox *m)
    {
        strcpy(m->cog_message,"cogA started");
        for(;;) strcpy(m->cog_message,"cogA running");
    }
    
    second .cogc file: cogB.cogc
    #include <propeller.h>
    #include "cog_test.h"
    
    _NATIVE
    void main (struct cogB_mailbox *m)
    {
        strcpy(m->cog_message,"cogB started");
        for(;;) strcpy(m->cog_message,"cogB running");
    }
    

    If I comment out the cogB references it launches cogA and seems to work fine.
  • jazzedjazzed Posts: 11,803
    edited 2013-09-08 11:37
    Hmm. Compiles and runs fine for me. Maybe your project is a little different.
  • Mark MaraMark Mara Posts: 64
    edited 2013-09-08 11:43
    Very perplexing. I unzip yours and it runs fine.

    Thanks.
  • jazzedjazzed Posts: 11,803
    edited 2013-09-08 11:45
    Open the two .side files with notepad or wordpad and tell me what the differences are.
  • Mark MaraMark Mara Posts: 64
    edited 2013-09-08 11:59
    I changed my compile and link options to match yours and it started working. I was not good about changing one parameter at a time so I can't tell you exactly the cause.

    I am happy. If it would be of any value to you I could probably restore from a backup and compare the .side files.

    Thanks for your help.
  • jazzedjazzed Posts: 11,803
    edited 2013-09-08 12:21
    I found it.

    Apparently with Create Project Library checked, the .cogc/.cog files do not get linked.

    Adding an issue to google code thanks. Do you mind if I attach your example to the issue?
  • blindstarblindstar Posts: 12
    edited 2013-09-08 13:24
    jazzed wrote: »
    I found it.

    Do you mind if I attach your example to the issue?

    Feel free.

    Thanks for your help.
  • jazzedjazzed Posts: 11,803
    edited 2014-02-03 23:03
    Hi,

    I've added notes regarding this issue here: https://code.google.com/p/propside/issues/detail?id=184

    The notes demonstrate what it takes to ensure that the cogc code is included in a library when Create Project Library is selected in SimpleIDE.
Sign In or Register to comment.