Thread: C or C++??????

  1. #1
    Registered User
    Join Date
    Nov 2009
    Location
    Glasford, IL
    Posts
    4

    Question C or C++??????

    Hello everyone, I'm working on learning C to help a guy out who is developing a product that uses an industrial controller and he needs the programming modified to make some updates to his proto-types. His old programmer went out of business so he was hopping that I could help him out a little.

    Now he was pretty sure the programs are wrote in C and not C++ but he's not positive. I'm just wanting to make sure before I get too deep in C and find out its C++.......... LOL Also I was wondering which "dialect" it is wrote in so I can get a compiler for it.

    Here is a chunk of the code if that will help out any.............. If you need any more info let me know and I'll see what I can do....... THANKS for the help I really appreciate it!!!

    Code:
    //   Unit_Tool.c        Main
    //   Description
    //   This is the main start up routines
    //
    //
    //////////////////////////////////////////////////////////////////////
    #define  TERN_186
    
    #include "unit_tool.h"
    
    //extern float cf_offset;
    //extern float divisor1;
    //extern float pounds;
    //extern float net_load_mult;
    //extern float divisor2;
    extern uchar spike_filter;
    //extern unsigned int Test;
    extern float var_1;
    extern float var_2;
    extern float var_3;
    extern float var_4;
    extern float var_5;
    extern uint tbl[];
    extern int num_stored;
    
    unsigned char ser1_in_buf[MAXISIZE];
    unsigned char ser1_out_buf[MAXOSIZE];
    int isize,osize;
    extern COM ser1_com;
    COM * c1;
    unsigned char  baud;
    extern float *heap_ptr;
    extern float *temp_ptr;
    
    /////////////////////////////////////////////////////////////////////////
    //
    // main function
    //
    /////////////////////////////////////////////////////////////////////////
    
    void main(void)
    {
    //unsigned int temp;
    float ftemp;
    
    	ae_init();    // calls initiation of the i/o of the Tern unit
    
    //unsigned int sp1ct;
    
    	c1 = &ser1_com;
    	baud = 9;       /*  19,200 baud for SER1      */
    	isize=MAXISIZE;
    	osize=MAXOSIZE;
    	s1_init(baud,ser1_in_buf,isize,ser1_out_buf,osize,c1);
    // You may modify SP1CT for Even Parity Check, 7 data bits
    //	sp1ct=inport(0xff10);	// SP1CT
    //	outport(0xff10,0x0018|sp1ct);	//	bit4=1 Even, bit3=1 Parity Enable
    
    //	pio_init(12, 2); // P12 for Multiplexer Select
    //   pio_wr(12,0);
    //   outport(0xfff2,0x0000);	// AUXCON, MCS, IO Bus 16-bit
    	delay_ms(800); // waiting for LCD ready at power on
    	delay_ms(800);
       elcd_init();   // Calls the start up displays on the LCD
       Restore();     // Calls all the restore fuctions to restore all the variables
       					// stored in the eeprom
       if(var_1 == 0.00)  // only used to get the coefficent values closed the first
        var_1 = 0.50;     // if restored from eeprom this code is not needed
       if(var_2 == 0.00)
        var_2 = 0.08;  // updated from 0.04 to 0.08 4/9/08 jlp
       if(var_3 == 0.00)
        var_3 = 22.28;
       if(var_4 == 0.00)
        var_4 = 3.15;
       if(var_5 == 0.00)
        var_5 = 11.0;
       if(tbl[1] == tbl[2])  reset_calib_table();  // added 5/2/08 to ensure the cal table has
         // been initialized to something close.  Had noticed that table was all 65535's
    	spike_filter = 10;
    //   Test = 0;
    	heap_ptr = malloc(201*sizeof(float));
       elcd_ClearScreen();
       if(heap_ptr == NULL)
          {
          elcd_WriteText("MALLOC failed!", 0,112);
          delay_ms(1000);
          delay_ms(1000);
          }
    	temp_ptr = malloc(201*sizeof(unsigned int));
       elcd_ClearScreen();
       if(temp_ptr == NULL)
          {
          elcd_WriteText("Temp storage MALLOC failed!", 0,112);
          delay_ms(1000);
          delay_ms(1000);
          }
       ftemp = (float)heap_ptr[200];
       if((ftemp > 200.)||(ftemp < 1.))
       {  // 7/23/08 tweeked to look using floats, clear the [0] too jlp
       	heap_ptr[200] = 0;
          heap_ptr[0] = 0.;
       }
    
    	num_stored = heap_ptr[200];   // recapture the count from unerased memory 7/17/08
       display_intro();    // displays start up screens
    	while(1)            // do forever
    	{
         menu();
       }

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    66
    That is C code.

    But you probably aren't going to be in a good position to be messing with it for some time.
    "When your work speaks for itself - don't interrupt!"

    -Samantha Ingraham.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Location
    Glasford, IL
    Posts
    4
    Quote Originally Posted by tjpanda View Post
    That is C code.

    But you probably aren't going to be in a good position to be messing with it for some time.
    Thanks, I too am starting to have my doubts about being able to learn this in a timely fashion. They said that they won't need me to do any thing for 3-4 months, then I'd just need to help them with changes. But later on after they move out of the proto-type stage the want to do a complete re-write of the program.

    I'm starting to think that I might be jumping into something too deep to start with????? I know I could learn it, but can I learn it quickly enough??? or to the level I'd need to be able to program this fairly complex device??????? There a pages and pages of C code and I guess its intimidating me a little...... LOL

    Thanks again

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Help him out a little?? :shock:

    This goes far beyond helping out a little, imo.

    One frustrating part of programming for machines, is that the machine can't do what you have (hopefully), programmed correctly.

    Your program needs to handle inertial changes with ramping schemes, and certain variables will need to be constrained in order to limit friction or heat build up, handle problems like backlash, etc.

    You might think that a carefully designed program will run "clean", but with a machine, you always wind up working out kinks which can only be done while you have an actual connection with either the machine, or an emulator.

    I believe your friend needs to get a programmer who has experience with machine programming in C, and hopefully with programming the same type of machine.

    Pass on this one, imo.

  5. #5
    Registered User
    Join Date
    Nov 2009
    Location
    Glasford, IL
    Posts
    4
    Well this all started out because I'm building them a new website and working with them with SEO for the site so they can get some more people visiting their website. They seen me looking at the source code and thought it looked they same so they figured it would be easy for me to learn C and help them out with their programming.

    They're willing to pay me for the work updating what he has and he realizes that re-writing the program would be a big job and said he'd be willing to pay me a 2-3K if I could learn how to do it.

    I'm thinking its beyond me and I wouldn't be able to learn it good enough quick enough.

    The money keeps drawing me back in though..... That would be plenty to finish up my V8 beetle I'm building plus some. LOL But then I look at the programing again and second guess my self.

    I think I'd be better of to walk away from it though I'd probably end up not being able to satisfy him and loose the webmaster job, and his son is VP for another company that I'm webmaster for.............. So I could loose those two side jobs...................... For now I think I'll stick with the website and SEO stuff on the side..........


    Thanks for the help guys............. Even if it is a bit depressing LOL

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by zbhover View Post
    Well this all started out because I'm building them a new website and working with them with SEO for the site so they can get some more people visiting their website. They seen me looking at the source code and thought it looked they same so they figured it would be easy for me to learn C and help them out with their programming.

    They're willing to pay me for the work updating what he has and he realizes that re-writing the program would be a big job and said he'd be willing to pay me a 2-3K if I could learn how to do it.

    I'm thinking its beyond me and I wouldn't be able to learn it good enough quick enough.
    Dude I enjoy and have much respect for web programming but C is legitimately dangerous
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed