Shop OBEX P1 Docs P2 Docs Learn Events
Catalina for DS00 — Parallax Forums

Catalina for DS00

prof_brainoprof_braino Posts: 4,313
edited 2012-04-23 20:30 in Propeller 1
Note: This is not a cross post, I am checking out both Catalina (here) and CGG (in a different thread). The first post is the same in both threads.

There is some C code posted for the prop chip in the DS00 Laser Range Finder.

http://www.lightware.co.za/download/software/DS00_Rev00.zip

Per the readme:
"The C source code (was) written using the ICCPROP V7.04D compiler from Imagecraft.com"

The image craft is 30-days free trial, I might want to re-do the code after 30 days. I would like to use the community tool of choice compiler.

Would you kind folks advise me which would be easier for a complete n00b to get going?

Be advised that I am not so good with C. I don't even have a "C" on my keyboard; it fell off, and I have a scratch-up "O" from a spare.

Comments

  • prof_brainoprof_braino Posts: 4,313
    edited 2012-04-20 17:05
    I have Catalina installed, it finds the main.c

    It can open the include files, but give the message could not find include file <xxx>
    main.c|11|Could not find include file <constants.h>|
    main.c|12|Could not find include file <globals.h>|
    main.c|14|Could not find include file <propeller.h>|
    main.c|16|Could not find include file <asio.h>|
    main.c|92|EOF inside comment|
    ||=== Build finished: 5 errors, 0 warnings ===|
    
    

    Do I have something configured wrong?
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-04-20 17:31
    My Catalina and C is quite limited. However, it seems you have not set the environment. From the catalina directory run the bat file (IIRC its use catalina). Try the getting started manual. Catalina has a lot of documents - hardest part is to know where to look, but it seems its all there.

    I have been writing a plugin for my rtc. Ross has been great getting me going and once done I will document how it works from a noobs pov.

    BTW we are using Catalina in a commercial project. I am not writing the main c routines. The project uses 3 props and the catalina prop has a RamBlade3 config (512KB sram, uSD, DS1430C rtc).
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-04-20 19:33
    Ah! Thanks cluso. I found use_catalina.bat
    I must have missed that in the installer.

    I restarted Catalina, but it still won't compile the include files. Maybe I got to reboot....
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-04-21 16:33
    Catalina requires a compile of the relevant hardware configuration. Perhaps this has not been done. My Catalina is in c:\catalina34 and my test program is in c:\catalina34\xxx
    So, after I boot the pc, I do cd\catalina34 and then run use_catalina. Then I cd\xxx and then I can compile.

    To ensure everything is ok, follow the install instructions and then the instructions to compile and test the hello world program. This whoudl check you have everything setup/installed correctly. I will not be home til this evening. I will post my simple instructions then for you. IIRC Rayman posted some simple instructions much earlier in this thread.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-04-22 18:14
    Here are the instructions that I use.
    C:\Catalina34
    To setup for commandline operation:
    -----------------------------------
    In the main Catalina folder...
    modify use_catalina.bat to point to the Catalina folder (if required)
    From a command window (run)...
        use_catalina  (set the environmental variables)
    To add a platform:
    ------------------
    In subdirectory "target" add files
        XXXXXX_CFG.inc  (eg XXXXXX = RAMBLADE3)
        XXXXXX_DEF.inc
        XXXXXX_HMI.inc
        XXXXXX_XMM.inc
        XXXXXX_README.TXT
    Request Ross prepare modified files for the subdirectory "target"
        CFG.inc
        DEF.inc
        HMI.inc
        XMM.inc
    To compile the xmm ram test program (or other utilities):
    -----------------------------------------------------
    From a command window (run)...
        cd %LCCDIR%
        use_catalina
        cd utilities
        build_ram_test XXXXXX (eg XXXXXX = RAMBLADE3) CASE IS IMPORTANT!!!
    This builds 3 files in the "utilities" folder.
        RAM_Test_PC.binary
        RAM_Test_TV.binary
        RAM_Test_VGA.binary
    See "Catalina_XMM_RamTest.spin" in the "target" folder (not the utilities folder)
    for more details.
    To run the xmm ram test program:
    --------------------------------
        cd utilities
        payload -e ram_test_pc
    Then start PST (115200) and reset the prop.
    To run a simple hello world test program:
    -----------------------------------------
        cd %LCCDIR%
        use_catalina
        cd demos
        catalina -lci hello_world.c -D RAMBLADE -D PC
        payload -e hello_world                            -e writes to eeprom
    Then start PST (115200) and reset the prop.
    ============================================================================================
    To build all Catalyst files:
    ----------------------------
    From a command window (run)...
        cd \catalina34
        use_catalina
        cd catalyst
        build_all RAMBLADE3 PC VT100
    To build demos:
    ---------------
        cd \catalina34\demos
        catalina test_stdio_fs.c -D RAMBLADE3 -lcix -D SMALL
        copy c:/catalina34/demos/test_stdio_fs.binary to TEST_STD.BIN    (or rename)
    Reformat SD Card to FAT16/32:
    -----------------------------
        copy c:/catalina34/catalyst/bin/*.*    to SD card
        copy c:/catalina34/demos/TEST_STD.BIN  to SD card
    Program eeprom:
    ---------------
        from c:/catalina34/catalyst/bin
        payload -e catalyst.bin
    
    ============================================================================================
    Adding Plugin to replace the RTC Clock:
    ---------------------------------------
    From a command window (run)...
        cd \catalina34
        use_catalina
        cd xxxx      xxxx is my program sub-directory
        catalina -lci zzzz.c -D RAMBLADE3 -D PC -D CLOCK zzzz.c ix my c program
        payload [-e] zzzz
    Then start PST (115200)... you can do this while payload is running and just click enable when payload 
    completes. 
    Note: I create a c.bat file and p.bat file in my program directory to compile and then payload my program.
    The programs required for this plugin mod are...
        \xxxx\zzzz.c     my c program
        \target\catalina_RTC_Plugin.spin
        \include\catalina_rtc.h
        \target\clock.spin
    

    They are a bit cryptic. Hopefully they will help you get running...

    NOTE that you need to do a use_catalina each time you reboot the pc.
    You can do...
    cd %LCCDIR%
    instead of
    cd \catalina34
    from the run command line in windoze.
  • RossHRossH Posts: 5,512
    edited 2012-04-22 20:18
    Hi Dr_Braino,

    The first problem is that this program is compiler-dependent. Since it is not pure ANSI C, you are pretty much going to have to make some changes no matter which compiler you port it to.

    The immediate problem you are having (with it not finding it's own include files) is easily fixed - just add "-I." (that's "minus capital-eye dot") to your command. That instructs Catalina to include the current directory in the path of system include file searches. The meaning of the include directive is a bit implementation-dependent, but the generally accepted interpretation is that ...
    #include <constants.h>
    
    ... means to include a system-defined include file called constants.h (i.e. from a list of compiler-defined directories), whereas ..
    #include "constants.h"
    
    ... means to include a user-defined include file called constants.h (i.e. from the current directory).

    The program you are trying to compile uses the first form for all include files, whereas for some files it should be using the second form. The "-I." will work around this by adding the current directory to the list of system search paths.

    This will fix the references to "constants.h", "externals.h" and "globals.h". The next problem is that there are other include files that exist only under the ICC compiler - i.e. "propeller.h" and "asio.h". I wrote a Catalina replacement include file for "propeller.h" (called "catalina_icc.h") that could be used under either compiler and allowed code to be made portable between ICC and Catalina. This program does not use it, but it would be trivial to modify it to do so. It also uses something called "asio.h" and I have no idea what that is - perhaps "asynchronous serial I/O"?. However, I think you will find you don't need that with Catalina, since Catalina comes with built-in serial support (just add -D PC to your compile command).

    When I do a bit of "hacking" (just to see what might be required to port it) I can get it to compile, apart from a symbol or two (e.g. a missing "froundf" function - obviously some kind of non-standard floating point rounding function - should be easy enough to fix).

    Of course, getting it to compile is not the same as getting it to run - for that, you're on your own!

    Ross.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-04-23 14:41
    Thanks Ross
    RossH wrote: »
    ....- just add "-I." to your command.

    I was using the Catalina Code blocks graphic IDE. Where do I find the command where I add the -I. -- or do I have to only use the catalina command line to compile?
    The next problem is that there are other include files that exist only under the ICC compiler - i.e. "propeller.h" and "asio.h". ... "catalina_icc.h"... This program does not use it

    So can I just comment these out? OR do I need to change "propeller.h" to "catalina_icc.h"?
    It also uses something called "asio.h" ... I think you will find you don't need that ...just add -D PC to your compile command

    Again, where is the command where I add -D PC ?
    a missing "froundf" function - obviously some kind of non-standard floating point rounding function - should be easy enough to fix

    I can switch to a the "standard float round" easy enough, when I get this far.

    When I open my DS00-Cat.cbp project file, the Projects tab has:
    Workspace
    DS00-Cat
    Sources
    Main.c

    Is this what we expect, or will adding the -I. make all the *.c and *.h files appear in the projects list?

    Do I also have to change the include from < > to " "; or is it one or the other?
  • RossHRossH Posts: 5,512
    edited 2012-04-23 20:30
    Thanks Ross

    I was using the Catalina Code blocks graphic IDE. Where do I find the command where I add the -I. -- or do I have to only use the catalina command line to compile?
    Sorry - I tend to use the command line most of the time, so I forget that most others don't.

    In CodeBlocks the best way is to select the menu item option Settings->Compiler and debugger. Make sure that Catalina C compiler is the Selected compiler, then go to the Other settings tab. Check the box that says Explicitly add project's top-level directory to compiler search dirs.

    So can I just comment these out? OR do I need to change "propeller.h" to "catalina_icc.h"?
    Replace <propeller.h> with <catalina_icc.h>, then replace each reference to the prop special registers (e.g. INA, OUTA) with the Catalina equivalent. For instance. I think you need to replace things like SET(OUTA, pin) with _outa(1<<pin,-1)

    Again, where is the command where I add -D PC ?
    Select the menu item option Project->Build Options. Make sure that your desired target is selected (in the left hand pane of this dialog box, you generally want your project-name selected, and not either of Debug or Release). On the compiler flags tab, select the HMI Driver Selection category, then check PC

    When I open my DS00-Cat.cbp project file, the Projects tab has:
    Workspace
    DS00-Cat
    Sources
    Main.c

    Is this what we expect, or will adding the -I. make all the *.c and *.h files appear in the projects list?
    No, you need to explicitly add all the .c and .h files to the project, not just Main.c. Select the menu item Project->Add Files, and add all the .c and .h files you see.
    Do I also have to change the include from < > to " "; or is it one or the other?

    Any .h file that you can see in the project directory should be specified as #include "xxx.h" rather than #include <xxx.h>


    ​Ross.
Sign In or Register to comment.