Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Header files (http://www.chiefdelphi.com/forums/showthread.php?t=69035)

dpeterson3 03-09-2008 21:24

Header files
 
Hello. I am new to programing. I am trying to upgrade last years code to use Kevin Watson's new code for the new compiler (I can only get my hands on the new one). Anyway, I have a problem with global variables. We had a file called globals.h which stored all our global variables. I copied it into the directory of the new code files, and the file itself compiles jsut fine. However, I call it from my homemade user routines file, and I end up with errors. The compiler spits back "E:\Backup\ifi_frc\globals.h:62:Error: syntax error" I don't understand. How can the header compile just fine on its own and not from another file? Any ideas

Another quick question. I have a printout of a file called oiboard.h in which the oi board inputs are mapped to such as "drt_aux1(sw_swtrig)" which refers to the trigger on the stick on input one. I assume this file is for the oi board and defines how the board sends signals. Am I correct? What I mean is does this code go on the oi board so when it sends data, instead of seeing p1_x, it sees drt_aux(x). I hope I made myself clear enough.

thanks

EricH 03-09-2008 21:56

Re: Header files
 
Quote:

Originally Posted by dpeterson3 (Post 763939)
Hello. I am new to programing. I am trying to upgrade last years code to use Kevin Watson's new code for the new compiler (I can only get my hands on the new one). Anyway, I have a problem with global variables. We had a file called globals.h which stored all our global variables. I copied it into the directory of the new code files, and the file itself compiles jsut fine. However, I call it from my homemade user routines file, and I end up with errors. The compiler spits back "E:\Backup\ifi_frc\globals.h:62:Error: syntax error" I don't understand. How can the header compile just fine on its own and not from another file? Any ideas

Another quick question. I have a printout of a file called oiboard.h in which the oi board inputs are mapped to such as "drt_aux1(sw_swtrig)" which refers to the trigger on the stick on input one. I assume this file is for the oi board and defines how the board sends signals. Am I correct? What I mean is does this code go on the oi board so when it sends data, instead of seeing p1_x, it sees drt_aux(x). I hope I made myself clear enough.

thanks

I'm not sure about the first question, but the second question is easy: the OI (at least the old one) doesn't take any code of its own. You'll need to code the file into the robot code.

tdlrali 03-09-2008 22:56

Re: Header files
 
What do you mean by "the file itself compiles jsut fine"?
Does the project compile without the header included?

Anyways, what's on line 63 / what's surrounding it?

(If you don't mind, zip up the project and post it - CD will find the problem rather quickly)

dpeterson3 04-09-2008 06:39

Re: Header files
 
What I mean is if I right click on the header file adn click "compile," the compiler builds it with no errors. If I right click on the acutal C file and click compile, I get the error. I would say it is in the C file, but line 63 is talking about some variables that are declared in the C file, so I doubt it. However, lines 61-63 in the header declare global variables for the gyro. I wonder if that might mean the variable is declare somewhere else, but the error still occurs when I comment out those three lines. I can't not include the header or I will get all kinds of errors. As I said, I am trying to use a lot of the origional code. When it was written, a lot of the main variables were stored there, so I will get a lot of errors by not includin it. I will zip it and post it as soon as I can. This computer can do zipped files.

AustinSchuh 04-09-2008 12:23

Re: Header files
 
It will also be helpful if you posted the error message that the compiler spits out at you. Compilers normally have hundreds of different error messages that mean wildly different things.

dpeterson3 04-09-2008 18:35

Re: Header files
 
I appricate the help. I will have to get back later. I just tried building it one more time to make sure it gave me the same error. Now I get a whole bunch more. I know why. As I said earlier, the origional programmer made a header to define all the oi inputs that I do not have a copy of. I will have to make my own. I don't know why I didn't get these errors before. I expected to. I am starting to question how well my compiler is really working.

I somehow fixed the problem. Everything compiles just fine now. I am not sure what was wrong. I still think I might just have needed to reboot my computer. Windows adn windows programs tend to do funny things when they are left running too long. All I get are some function warnings, which I will have to work on. Anyway, they are not a big deal. However, I still have a small problem. I got this in an email

oiboard.h
/* Operator Interface Aliases */
// Joysticks
// - Each Joystick has 8 members, which should be supplied for 'i'.
// - There are 4 analog inputs: 'x', 'y', 'wheel', and 'aux'
// - And 4 switch inputs: 'sw_trig', 'sw_top', 'sw_aux1', and 'sw_aux2'
#define drt_driver(i) p2_##i
#define drt_operator(i) p4_##i
#define drt_aux1(i) p1_##i
#define drt_aux2(i) p3_##i
// Analog Knobs
#define drt_knob1 drt_aux1(x)
#define drt_knob2 drt_aux1(y)
#define drt_knob3 drt_aux1(wheel)
#define drt_knob4 drt_aux1(aux)
// Four more unused analog inputs on drt_aux2
// Three-Position Switches
#define drt_3p1_high drt_aux1(sw_trig)
#define drt_3p1_low drt_aux1(sw_top)
#define drt_3p2_high drt_aux1(sw_aux1)
#define drt_3p2_low drt_aux1(sw_aux2)
// Switches and buttons
#define drt_switch1 drt_aux2(sw_trig)
#define drt_switch2 drt_aux2(sw_top)
#define drt_push1 drt_aux2(sw_aux1)
#define drt_push2 drt_aux2(sw_aux2)
// State Switches
// - The State Switches are so called, because the switches are processed based
// - on the state of an analog input. With 4 switches per analog, there is
// - a total of 16 states.
#define drt_switch_set1 drt_aux2(x)
#define drt_switch_ser2 drt_aux2(y)
#define drt_switch3 DRT_StateSwitch(1)
#define drt_switch4 DRT_StateSwitch(2)
#define drt_switch5 DRT_StateSwitch(3)
#define drt_switch6 DRT_StateSwitch(4)
#define drt_push3 DRT_StateSwitch(5)
#define drt_push4 DRT_StateSwitch(6)
#define drt_push5 DRT_StateSwitch(7)
#define drt_push6 DRT_StateSwitch(8)
// Console LEDs
#define drt_LED1 Pwm1_green
#define drt_LED2 Pwm1_red
#define drt_LED3 Pwm2_green
#define drt_LED4 Pwm2_red
#define drt_LED5 Relay1_red
#define drt_LED6 Relay1_green
#define drt_LED7 Relay2_red
#define drt_LED8 Relay2_green

I know it was part of the problem. I do not have an original copy of the file. I think there might be more to it. All I know is one of my issues was a line of code that said

#define SW_PERCISION_DRIVE drt_driver(sw_trig)

and two others like it. Can someone tell me where that might be defined. I don't see it in this oiboard.h file and I can't figure out where else he might have mapped the origional input names to these names. For right now, I am just going to use the conventional names becaue I know they are defined

thanks

dpeterson3 07-09-2008 13:14

Re: Header files
 
Thanks everyone. I just found out on Friday that they built a new OI. The files he sent me were for the new stuff. I also now have an update version of the 2.4 code, so everything is starting to make sense. I wish people would keep me informed.


All times are GMT -5. The time now is 00:06.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi