Shop Learn
FlexC: Cannot include "servo.h" from SimpleIDE lib — Parallax Forums

FlexC: Cannot include "servo.h" from SimpleIDE lib

AwesomeCronkAwesomeCronk Posts: 1,055
edited 2021-07-22 17:01 in Propeller 1

I am building a junction controller for my brother's model railroad using those little S51 micro servos, a handful of toggle switches, and a Prop Mini. I decided to use @ersmith 's FlexSpin compiler, but I needed the SimpleIDE library to get the servo.h file. I cloned https://github.com/parallaxinc/Simple-Libraries to my source folder and gave it a go. I typed up some quick code and tried it out:
switch.c:

#include "servo.h"

int main ()
{
    servo_set(16, 1500);
}

To compile I ran this in PowerShell 7:

flexspin -D_BAUD=115200 "C:\Users\aweso\Documents\Source\C\Prop1\Simple-Libraries\Learn\Simple Libraries\Motor\libservo\servo.h" switch.c -o switch.bin

Only to recieve this error:

Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
Version 5.5.1 Compiled on: Jun 19 2021
servo.h
switch.c
error: Preprocessor errors:
C:/Users/aweso/Documents/Source/C/Prop1/trainSwitchController/switch.c:1: error: Can't open include file "servo.h"
    #include "servo.h"
1 error in preprocessor.

Is this a side effect of using non-FlexC libraries with FlexSpin or am I missing something? I have verified that it is a valid path because I can open that file in VSCode.

Comments

  • @AwesomeCronk said:
    To compile I ran this in PowerShell 7:

    flexspin -D_BAUD=115200 "C:\Users\aweso\Documents\Source\C\Prop1\Simple-Libraries\Learn\Simple Libraries\Motor\libservo\servo.h" switch.c -o switch.bin
    

    That's not how you add a header in any compiler.

    What you want is

    flexspin -D_BAUD=115200 -I "C:\Users\aweso\Documents\Source\C\Prop1\Simple-Libraries\Learn\Simple Libraries\Motor\libservo" switch.c -o switch.bin
    
  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2021-07-22 17:35

    I had tried that with the-L variation, to no avail. Here is the error given by the command you posted:

    PS7 [aweso@Computertron7600K] trainSwitchController> flexspin -D_BAUD=115200 -I "C:\Users\aweso\Documents\
    Source\C\Prop1\Simple-Libraries\Learn\Simple Libraries\Motor\libservo" switch.c -o switch.bin
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.5.1 Compiled on: Jun 19 2021
    switch.c
    C:/Users/aweso/Documents/Source/C/Prop1/trainSwitchController/switch.c:5: error: unknown identifier servo_
    set used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/trainSwitchController/switch.c:5: error: Unknown symbol servo_set
    PS7 [aweso@Computertron7600K] trainSwitchController>
    
  • You also need to add the implementation file to the command line if it's not a flexspin-aware header

  • servo.c?

  • @AwesomeCronk said:
    servo.c?

    Yes.

  • RsadeikaRsadeika Posts: 3,591

    @AwesomeCronk, were you successful in using the simpletools lib clone for your project.?

    It would be nice to be able too use your concept and be able to have access too all the other drivers in the simpletools lib. Also, since Wuerfel_21 added the "CMM" version, or something close, too FlexProp for the P1, this might be a good reason to give up on SimpleIDE.

    If you were successful could you give a more detailed description of how it is done.

    Ray

  • I tried adding the servo.c file to the compile command and got this lovely eruption of unhappy compiler noises:

    PS7 [aweso@Computertron7600K] trainSwitchController> flexspin -L "C:\Users\aweso\Documents\Source\C\Prop1\
    Simple-Libraries\Learn\Simple Libraries\Motor\libservo" -D_BAUD=115200 "C:\Users\aweso\Documents\Source\C\
    Prop1\Simple-Libraries\Learn\Simple Libraries\Motor\libservo\servo.c" switch.c -o switch.bin
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.5.1 Compiled on: Jun 19 2021
    servo.c
    switch.c
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:186
    : warning: signed/unsigned comparison may not work properly
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:191
    : warning: signed/unsigned comparison may not work properly
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:253
    : warning: signed/unsigned comparison may not work properly
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:264
    : warning: signed/unsigned comparison may not work properly
    input.c
    getOutput.c
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:67:
     error: unknown identifier lockset used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:67:
     error: Unknown symbol lockset
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:73:
     error: unknown identifier lockclr used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:73:
     error: Unknown symbol lockclr
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:156
    : error: unknown identifier lockset used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:156
    : error: Unknown symbol lockset
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:171
    : error: Undefined symbol abs
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:190
    : error: unknown identifier lockclr used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:190
    : error: Unknown symbol lockclr
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:201
    : error: unknown identifier cogstop used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:201
    : error: Unknown symbol cogstop
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:203
    : error: unknown identifier lockclr used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:203
    : error: Unknown symbol lockclr
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:204
    : error: unknown identifier lockret used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:204
    : error: Unknown symbol lockret
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:221
    : error: unknown identifier locknew used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:221
    : error: Unknown symbol locknew
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:223
    : error: unknown identifier lockclr used in function call
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:223
    : error: Unknown symbol lockclr
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:225
    : error: Unknown symbol NULL
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:261
    : error: Undefined symbol abs
    C:/Users/aweso/Documents/Source/C/Prop1/Simple-Libraries/Learn/Simple Libraries/Motor/libservo/servo.c:272
    : error: Undefined symbol abs
    PS7 [aweso@Computertron7600K] trainSwitchController>
    
  • @Rsadeika I did not see your post before I put mine up. No I was not successful in attempting to snatch the SimpleIDE lib. I need to figure out where in the FlexProp lib this servo object is...

  • ersmithersmith Posts: 5,011

    The "Simple" libraries aren't really so simple, and unfortunately they depend on GCC in some areas. Roy Eltham has done a great job of porting some of them to FlexProp, but he's only one person and can only do so much. @AwesomeCronk : the specific errors you are seeing look like a missing #include <propeller.h> in servo.c, and possibly a missing #include <stdlib.h>, but I can't be sure.

  • Wuerfel said the same in the Prop Discord. I tried inserting the #include "propeller.h" in servo.c to no avail. I think I'm just going to use the pwm.c object fom the FlexProp lib instead.

  • RsadeikaRsadeika Posts: 3,591

    It is to bad that Parallax did not give it more thought when they created the simpletools lib. I know that they just have Andy to do the lib, but it could have been done in a way where the lib could be more universally shared. But, I guess it is to late for that now.

    Does anybody have any idea as to how you would be able to pull a specific driver out of the simpletools lib? Andy must have used some kind of logic when he created the simpletools lib.

    Ray

  • AFAIK, you mostly pull a header, pull the necessary files, tweak it until it compiles, repeat as desired. I've never done so though, so take my 2 bits with a grain of salt.

  • RsadeikaRsadeika Posts: 3,591

    I think I tied that one time and got lost very quickly. Would be nice if FlexProp had a similar setup like SimpleIDE, a pick and choose what driver you want added to, either FlexBASIC or FlexC. Oh well, I guess I can dream.

    The one that I would like to get a hold of is the servo360 driver for now. I guess a starting point is libservo380.h and go from there. I will give it a shot, again.

    Ray

Sign In or Register to comment.