![]() |
Programming Help!
1 Attachment(s)
Can anyone please help me, I wrote a code with some objects and for some reason when I deploy the code, the robot would connect for 5 seconds then disconnect and I would get an error on windriver that would ask if I would like to run the debugger can some one please look over this code to see my problem or error
|
Re: Programming Help!
Simply put, you want to be creating classes in separate files, not structs in the same (you might be able to get away with putting them in the same file, not sure. I don't think it's a good idea either way though). Pick a simple WPILib class and structure your custom classes off that, using a cpp and header file. Then, you incorporate it with an #include statement, just like you would with one of the WPILib classes.
I only gave a quick glance through your code, and I'm facing my own programming troubles right now as well. I just needed a break so I came on here. Anyway, point being that I might be mistaken, or I might have missed another major bug, but I'd start there. If someone more knowledgable comes along, feel free to ignore my comments. |
Re: Programming Help!
I had it as a .h file and included it in the code before and but I would still get the same problem in which I would have to re-image the CRio just to get that code off. But i'll try it! Thanks!
|
Re: Programming Help!
I got the same Errors as a cpp file
|
Re: Programming Help!
I'd like to help but that Elevator_Mechanism structure is crazy looking. It makes things hard to follow. Why did you not setup a class? I recommend you undeploy your code, reboot the cRio and use the "Debug Kernel Task" method to step through the code.
Does it really run for 5 seconds? If it runs for 5 seconds I doubt iyou have any memory or resource conflict errors. Are you petting the watchdog timer? Are your functions returning control where they should? HTH |
Re: Programming Help!
Memory leak? You have to be really careful when using malloc. That is if you don't know what you are doing, just use "new". You never freed your allocated data.
Add: free(Elevator_heights); after that for loop edit: my analogy I like to use is like feeding a kid a whole bunch of food and not letting him poop afterwards. So that stays inside of him until you let him poop or he dies (the program exits). |
Re: Programming Help!
you have to be just as careful whether your using new or malloc. maybe even a little more careful when using new because then you have to choose correctly between delete and delete[]
|
Re: Programming Help!
Quote:
|
Re: Programming Help!
Quote:
As mentioned already, that Elevator_Mechanism structure is very strange looking. It's difficult to follow, so I can't say for sure whether or not that part would work. Spoiler for incorrect information:
This is a situation where it would be useful to post the console output. The debugger would also be a valuable tool to use. |
Re: Programming Help!
Good catch on the constructors. Actually though, I think the whole lines for the Carriage motor and elevator motor before the "{" braces should be taken out. Since those are declared as pointers, you use the "name = new ClassName(args);" format in the actual constructor, which you were doing, but then commented out.
If you declared the objects as actual objects instead of as pointers (i.e. Victor Elevator_motor; Victor Arm_motor; instead of Victor *Elevator_motor; Victor *Arm_motor; ) then you would use the format described by MattD. As always, I'm only a fallible student, so someone feel free to disprove me. |
Re: Programming Help!
Quote:
|
| All times are GMT -5. The time now is 17:47. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi