Shop OBEX P1 Docs P2 Docs Learn Events
SUCCESS: Converting mbed C++ to C to Propeller GCC.... BUG-B-GONE — Parallax Forums

SUCCESS: Converting mbed C++ to C to Propeller GCC.... BUG-B-GONE

idbruceidbruce Posts: 6,197
edited 2015-03-02 23:14 in Propeller 1
Hello Everyone

I am at a point in the Teacup port where I really need some answers pertaining to various hardware issues. One of those issues is being able to communicate with an ADC breakout board that I purchased from Adafruit several months ago. On the Adafruit website, they provided some source code to interace the ADC, but of course it certainly was not Propeller friendly :( , and of course I have been working on changing that. Basically as the title states, I have been attempting to convert mbed C++ to Prop-GCC, and I believe I have it very, very close, but I now have a Prop-GCC issue that I cannot understand or resolve. They say a picture says a thousand words, so I am including an image of the build status pane. As you can clearly see, there is an undefined reference to "_st_mark". _st_mark is basically used by the waintcnt function and it is clearly defined as an extern variable within simpletools.h, so I am befuddled :(

In addition to the image, I am also including a project archive, as well as an archive of the original source code before modification.

Any help would be greatly appreciated. Thanks.

Bruce

EDIT: I suppose that I should also inform you that I have other projects that use waitcnt and still compile just fine, so this is a project specific issue.

attachment.php?attachmentid=113340&d=1425314106
«1

Comments

  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 08:51
    No idea. Clearly you are not managing to link the library libsimpletools.a into your program. Which no doubt provides the missing symbol.

    I really don't like to see "-LC:/......../cmm/\libsimpletools.a" in that output. There should only be "/" or "\" depending on operating system.

    What I expect to see is a "-lsimpletools.a" in the final link command somewhere. Otherwise the simpletools library is not being used at all. Perhaps try adding that to the build options in SimpleIDE or whatever you are using.

    Edit: Please don't post images of compiler error messages. It make it very hard to copy and paste bit's of it back into replies when trying to answer the question. Just cut and paste the text as a code block here.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 08:53
    Heater

    I found it... I forgot to change wait to waitcnt in the main.
        while(1)
        {
            reading = readADC_SingleEnded(0); // read channel 0
            print("reading: %d\r\n", reading); // print reading    
            waitcnt(CNT += (ms * 2));
        }
    
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 08:57
    I'm confused. I thought CNT was the read only counter on the Propeller. How can "CNT += (ms * 2)" do anything useful ?

    Or is CNT something different in simpletools or your program ?
  • David BetzDavid Betz Posts: 14,511
    edited 2015-03-02 08:59
    Heater. wrote: »
    No idea. Clearly you are not managing to link the library libsimpletools.a into your program. Which no doubt provides the missing symbol.

    I really don't like to see "-LC:/......../cmm/\libsimpletools.a" in that output. There should only be "/" or "\" depending on operating system.

    What I expect to see is a "-lsimpletools.a" in the final link command somewhere. Otherwise the simpletools library is not being used at all. Perhaps try adding that to the build options in SimpleIDE or whatever you are using.

    Edit: Please don't post images of compiler error messages. It make it very hard to copy and paste bit's of it back into replies when trying to answer the question. Just cut and paste the text as a code block here.
    This could be related to a problem I reported a while back about COG drivers not being pulled from libraries. Can you verify that the simple tools libraries are being included in the link?
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 09:04
    I don't see any "-lsimpletools" in Bruce's build output above. Well, except that image does not seem to tell the whole story.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 09:18
    I'm confused. I thought CNT was the read only counter on the Propeller. How can "CNT += (ms * 2)" do anything useful ?

    Or is CNT something different in simpletools or your program ?

    LOL... I meant to declare a variable and assign it with CNT.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 09:30
    Hey Heater... Good catch though....

    Anyhow the main has been altered to this.... replacing waitcnt with pause...
    int main(void)
    {
        i2c *i2cBus = i2c_newbus(I2C_SCL,  I2C_SDA, I2C_MODE);
        Adafruit_ADS1015(i2cBus);
        
        uint16_t reading;
        
        while(1)
        {
            reading = readADC_SingleEnded(0); // read channel 0
            print("reading: %d\r\n", reading); // print reading    
            pause(10);
        }
        
        return 0;
    }
    

    and all references to waitcnt within Adafruit_ADS1015.c have been replaced with: pause(m_conversionDelay);

    It now compiles fine, but the question is..... Does it function like it should???????

    EDIT: In reference to that last question, I added two functions to Adafruit_ADS1015.c, write_i2c and read_i2c. These two functions pass their parameters onto i2c_out and i2c_in. I am not sure if I am placing the parameters correctly.
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 09:49
    I'm kind of worried where all this leads you. You seem to have hacked around tons of code from here and there to get it to compile. When it does I'm sure it's not going to just magically work. How on Earth are you going to test and debug all this?
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 10:02
    Heater
    I'm kind of worried where all this leads you. You seem to have hacked around tons of code from here and there to get it to compile. When it does I'm sure it's not going to just magically work. How on Earth are you going to test and debug all this?

    I have faith that all it will need is a few alterations, if any, because I believe it is ready, with the possible exception of the paameters being passed to i2c_out and i2c_in.

    As far as testing goes.... I am going to see if I can set up something on the Prop BOE, with a pot set up in a similar fashion as the various thermistors will be setup on the controller.
  • dgatelydgately Posts: 1,621
    edited 2015-03-02 10:42
    One thing of note...

    The library directory within your SimpleIDE project's is set as Read/Write for owner only. It would not build on my system until I reset permissions. This is a bit less than optimal for projects that you intend to publish in the forums for help in debugging. This may also be an indicator that portions of your project's paths are generally set this way. You may want to open-up your project files as a general rule as you may end up with build errors that are difficult to debug.

    dgately
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 10:47
    dgately

    Thanks for the heads up
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 10:50
    Is this some weird Windows thing?

    On my machines something like SimpleIDE gets installed to /opt/parallax or wherever with me as the owner. read/write for owner only is quite OK. I don't have anyone else using my machine.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 11:07
    Heater

    I never have any problems opening any files. I wonder what OS dgately is using. The project folder is read only, while all the files inside don not have any permissions set.
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 11:32
    Perhaps there is an issue if one has installed things as root or Admin. Then the user is not the owner. I don't know, sounds like a strange thing to do.
  • dgatelydgately Posts: 1,621
    edited 2015-03-02 11:52
    I'm on Mac OS X (so, Unix)...

    Here's what the project looks like when unzipped:
    [myOS ~/Downloads/MyADC]$ ls -al
    total 72
    drwx------@    8 myUserName  admin    272 Mar  2 11:43 .
    drwxr-xr-x+ 1976 myUserName  admin  67184 Mar  2 11:43 ..
    -rw-------@    1 myUserName  admin  12639 Mar  2 10:13 Adafruit_ADS1015.c
    -rw-------@    1 myUserName  admin   7391 Mar  2 10:13 Adafruit_ADS1015.h
    -rw-------@    1 myUserName  admin    501 Mar  2 10:13 MyADC.c
    -rw-------@    1 myUserName  admin    403 Mar  2 10:13 MyADC.side
    drw-------@    5 myUserName  admin    170 Mar  2 10:13 library
    -rw-------@    1 myUserName  admin   1525 Mar  1 18:27 license.txt
    
    [myOS ~/Downloads/MyADC]$ ls -al library/
    ls: .: Permission denied
    ls: ..: Permission denied
    ls: libsimplei2c: Permission denied
    ls: libsimpletext: Permission denied
    ls: libsimpletools: Permission denied
    

    dgately
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 12:07
    I see the problem. Who made such a stupid package?
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 13:35
    I see the problem. Who made such a stupid package?

    Don't look at me..... I did not set any permissions. SimpleIDE store projects to MyDocuments. All I did was create an archive. Heck, I never even use MyDocuments except for SimpleIDE
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-03-02 13:59
    Heater. wrote: »
    I see the problem. Who made such a stupid package?
    What stupid package are you referring to? If you mean Linux, I think that was Linus Torvalds. If you mean SimpleIDE, that was Jazzed. If you mean Mac OS X, I have no idea? It's probably a little extreme to call any of them a stupid package. Anyhow, the problem can be fixed on the Mac by just doing a chmod.
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 14:30
    OK Dave, "stupid" was a bit extreme. Let's just say "brain damaged" then :)

    I meant the package under discussion, that is whatever dgately unzipped above. Conveniently created so that the intended user can't see it.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 15:30
    Conveniently created so that the intended user can's see it.

    Just exactly what are you trying to say?
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 15:52
    Sorry had a typo in the last post ("can's" instead of "can't")

    My point was that if the package gets installed by root/admin but then the files it provides cannot be accessed by the intended normal users that is a bit broken. Not very broken as such permission problems are easily sorted as Dave and dgately said.

    Now I'm not sure what dgately is showing us. The listing shows he is in his ~/Downloads/MyADC directory and all the files seem to have usable permissions set.

    But then he shows the output of the "ls -al library/" command issued in the same directory and there is a bunch or errors "....: Permission denied". So obviously permissions inside the library directory incorrect. But we don't get to see what they are actually set to.

    Oh, and how come the library directory has no "x" bits set on it?
  • mindrobotsmindrobots Posts: 6,506
    edited 2015-03-02 16:01
    All this makes me wonder about an archive that is created on a Windows system and then unarchived on a *nix type system. I don't know the answer but it is curious. Many Windows systems are set up so the only user is also the admin so if you create the archive there, you are in the admin "group". If you undo it on a *nix system, you are just a user. It appears to unarchive in some sort group other than your own? (Unless dgately is that user in that group that is displayed in the 'ls')

    As far as the 'x' bits, windows has no 'x' bits as far as I know - how/why would it convey that information in that case?

    Just pondering......
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 16:07
    I am still not sure whether you are saying this is my fault or not. If so, I just installed SimpleIDE with all the defaults. When I zipped the package, I used the Archive menu item within SimpleIDE. Something is setting those permissions somewhere..... but it is not me.

    By the way, I have put together my test setup and tested. I do have a problem, but I believe it is how I am passing the data in the i2c_out and i2c_in functions, however not sure just yet. It shouldn't be long though.
  • mindrobotsmindrobots Posts: 6,506
    edited 2015-03-02 16:14
    I'm not casting blame. You just used the tools. I'm just wondering how the tools work and if it is some sort of strange Win/*nix oddity.

    I would think if you archive something on one system, you should be able to unarchive it in a more directly usable form on the other system.

    I'm not even sure what *nix to *nix does as far as users and groups go. I almost want to go experiment.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 19:42
    Well......

    During my repeat loop.....

    I have gone from repeatedly printing 2, with no response to pot adjustment

    to

    repeatedly printing 4095, with no response to pot adjustment

    to

    repeatedly printing 0, with no response to pot adjustment

    LOL.... I altered the code just a little and removed two functions. Now I am calling i2c_in and i2c_out from readRegister and write register.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 19:54
    It is now responding to changes in the pot, after I commented out the shift :)
    m_i2cAddress = i2cAddress;// << 1;
    
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 22:04
    Bruce,
    I am still not sure whether you are saying this is my fault or not.
    I'm not sure I'm saying it's anyone fault. I did say the package is stupid, based on the evidence presented by dgately that it unpacks with unusable permission settings.

    I'm pretty sure this is an issue of moving things from Windows out into the normal world. So, like many such headaches and inconveniences in the modern computing world we can blame Bill Gates.
  • dgatelydgately Posts: 1,621
    edited 2015-03-02 22:11
    I'm wondering if we should consider the permissions problem a SimpleIDE bug. There's probably something that can be changed in the way SimpleIDE calls the zip function to set the permissions correctly. I'll check into this and write up a bug report for future revisions.


    Bruce, glad you've got some results now!


    dgately
  • Heater.Heater. Posts: 21,230
    edited 2015-03-02 23:01
    dgately,

    Perhaps you are onto something there.

    Of course the bug is that it produces zip files instead of compressed tar balls. :)
  • idbruceidbruce Posts: 6,197
    edited 2015-03-02 23:14
    Bruce, glad you've got some results now!

    Thanks dgately

    For those of you who did not look at the source, it is some pretty serious source code for controlling an adc, with all the bells and whistles. Additionally, here is the adc breakout board that the source code is for: http://www.adafruit.com/product/1083

    Just look at the specs.... It is a 4 channel 12 bit, but this code could easily be modified for the ADS1115 which is 4 channel 16 bit. Of course you do not have to buy the breakout board, just the chip, because the code will run it. And with a few mods, the 16 bit could be at your disposal.

    Anyhow, here it is in working order :) And dgately, sorry about any permissions that may be screwy, but I do not know how to fix that problem.
Sign In or Register to comment.