Shop OBEX P1 Docs P2 Docs Learn Events
spin2cpp of my slave0 spin program — Parallax Forums

spin2cpp of my slave0 spin program

RsadeikaRsadeika Posts: 3,837
edited 2012-10-21 10:30 in Propeller 1
I just ran my slave0.spin program with spin2cpp --ccode, and tried to compile with SimpleIDE, I got the following error:
Project Directory: E:/PropGCC_SimpleIDE/PropGCC/slave0/slave0/

propeller-elf-gcc.exe -o a.out -Os -mcmm -I . -fno-exceptions Float32.c Float32.h FloatMath.c FloatMath.h FloatString.c FloatString.h FullDuplexSerial.c FullDuplexSerial.h Sensirion.c Sensirion.h tools.c tools.h XBee_Driver.c XBee_Driver.h slave0.c
c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/cmm/_crtbegin.o: In function `argc_cnt':

(.init+0x22): undefined reference to `_main'

collect2: ld returned 1 exit status

Done. Build Failed!

Check source for bad function call or global variable name `_main'
Hopefully Eric can figure out what the problem is.

Ray

Comments

  • ersmithersmith Posts: 6,054
    edited 2012-10-11 12:59
    As Steve has already mentioned, you have to provide your own main() function or else pass --main to spin2cpp.

    Eric
  • RsadeikaRsadeika Posts: 3,837
    edited 2012-10-11 13:28
    I added the main() to my slave0.c, compiled, and ran the new C program. I guess something happened in the conversion process. When I run the spin version my master program it gets all numbers when I run the getxb command with the spin version of slave0. In fact, now looking at the data below, sitting in the room where the slave0 module is located the temperature is not 27.9 F degrees. So, I guess the converted slave0 program is producing corrupted data. When I did a cpp conversion it was also sending out corrupted data. Sure would like to know why the conversion is producing corrupted data.

    Ray
    Load and mount SD: done.

    Commands are help, cat, rm, ls, ll, echo, cd, pwd, mkdir, rmdir, chmod
    getxb, date, time, setclock, settime.
    > getxb
    F 27.9 H***.*0
    > date
    10/11/12
    > time
    16:12:37
    > getxb
    F 27.9 H***.*0
    >
  • jazzedjazzed Posts: 11,803
    edited 2012-10-11 13:35
    ersmith wrote: »
    As Steve has already mentioned, you have to provide your own main() function or else pass --main to spin2cpp.

    Eric

    Sorry, I noticed we cross-posted at exactly the same time saying essentially the same thing, and I removed my post.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-11 15:12
    It looks like there is a bug in spin2cpp when it generates negative floating point values. As an example, -0x421ea3d7 should be 0xc21ea3d7. That is, the proper way to negate a floating point number is to flip the most significant bit. Set the MSB and remove the "-" character for all the -0x... floating point numbers, and that should fix it.
  • RsadeikaRsadeika Posts: 3,837
    edited 2012-10-11 15:32
    The next spin2cpp conversion I want to get working is the master.spin program. The problem, the last time I did a spin2cpp, was that it could not deal with the multiple use of malloc. I am not sure if that has to be worked out in the Spin part, or is there a way of dealing with it in spin2cpp?

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2012-10-20 07:10
    It looks like there is a bug in spin2cpp when it generates negative floating point values. As an example, -0x421ea3d7 should be 0xc21ea3d7. That is, the proper way to negate a floating point number is to flip the most significant bit. Set the MSB and remove the "-" character for all the -0x... floating point numbers, and that should fix it.
    @ersmith, just curious, did the above problem ever get resolved? Somewhere along the line I would like to get a spin2cpp conversion of the Sensirion.spin driver to work with.

    Ray
  • ersmithersmith Posts: 6,054
    edited 2012-10-21 10:30
    Rsadeika wrote: »
    @ersmith, just curious, did the above problem ever get resolved? Somewhere along the line I would like to get a spin2cpp conversion of the Sensirion.spin driver to work with.

    Ray

    Yes, it's been resolved in the spin2cpp source code for a while. I just put up a binary release of spin2cpp 1.00 in case you don't want to build from source yourself.

    Eric
Sign In or Register to comment.