Go to Post Let me live in my delusional world where minibots never happened and the Tetrix kit doesn't exist. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-12-2006, 03:15
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Thanks for all the help.

Now I have a new problem and I can't find any useful information on it.

Main^ main = dynamic_cast<Main^>(this->MdiParent);

for(count = 0; count < 10; count++)
{
number = main->serialPort1->BytesToRead; //Error
}

Quote:
An unhandled exception of type 'System.NullReferenceException' occurred in GUI Control Interface.exe

Additional information: Object reference not set to an instance of an object.
This happens when I start sending some serial data form a PIC to the comp.

Searching on the internet hasn't explained it much.
  #2   Spotlight this post!  
Unread 30-12-2006, 03:56
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
T
This happens when I start sending some serial data form a PIC to the comp.
May I ask what type of project you are working on?
  #3   Spotlight this post!  
Unread 30-12-2006, 05:32
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by Tom Bottiglieri View Post
May I ask what type of project you are working on?
It's a secret...
No, not really.

To my knowledge there is no real debugging system for the RC other than the printf statements. This program will allow you to watch 10 values(16 bit) at any given time. Each column has a list to choose form. There will be a preset of pwms, analogs, digital I/O, OI port values, etc. But there will also be some extra values, ex. X1, which when programed into the RC allows you watch any variable (16 bit or less).

Ex: x_1 = some_count = .......;

Then you select the X1 in any column and you start seeing a printf style stream of values.

Helpful when you are debugging a whole function. You can assign each variable in your function to a x_1 through x_x and watch all their values simultaneously.

The PIC is simulating an RC. (Don't have access to an RC one right now)

If I can get around to it(probably won't), the program might actually be able to control the robot using this:
(Its not done, not even close...)
Attached Thumbnails
Click image for larger version

Name:	GUI_mod.JPG
Views:	32
Size:	85.9 KB
ID:	4795  

Last edited by 6600gt : 30-12-2006 at 05:37.
  #4   Spotlight this post!  
Unread 30-12-2006, 12:05
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
Now I have a new problem and I can't find any useful information on it.

Main^ main = dynamic_cast<Main^>(this->MdiParent);

for(count = 0; count < 10; count++)
{
number = main->serialPort1->BytesToRead; //Error
}

Fails with:
An unhandled exception of type 'System.NullReferenceException' occurred in GUI Control Interface.exe

Additional information: Object reference not set to an instance of an object.
This happens when I start sending some serial data form a PIC to the comp.

Searching on the internet hasn't explained it much.
Anyone?
  #5   Spotlight this post!  
Unread 30-12-2006, 12:25
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
Anyone?
I dont know VC++ but heres my ideas. Do a try catch and see if that give you an error code that means something more.
  #6   Spotlight this post!  
Unread 30-12-2006, 13:37
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by chris31 View Post
I dont know VC++ but heres my ideas. Do a try catch and see if that give you an error code that means something more.
I kinda tried this right now, and it didn't help.

Can someone explain what it means when such an exception is thrown?

Thanks
  #7   Spotlight this post!  
Unread 30-12-2006, 15:13
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post

Main^ main = dynamic_cast<Main^>(this->MdiParent);

for(count = 0; count < 10; count++)
{
number = main->serialPort1->BytesToRead; //Error
}
This could be couple things. . . The problem could be line before also. . .
Something isn't initialized and there is a NULL Pointer and you are trying to assign a NULL pointer to a data slot. .

Looking in this instance my guess is there isn't Serial Communications between the PIC and the computer, and that serialPort1 is probably NULL ??

My suggestion would be when you get a problem like this is set a breakpoint couple lines before the error and then run till it gets the breakpoint and do System Watches on the important variables and use the Step Over and Step Into to go step by step through the for loop. . . If something is null it normally comes up as something in red text or a value that you know isn't correct in the watch window.
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #8   Spotlight this post!  
Unread 30-12-2006, 18:46
Bob22341 Bob22341 is offline
Registered User
FRC #1870
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Alberta
Posts: 48
Bob22341 will become famous soon enough
Re: Visual C++ 2005 Designer

Your problem comes when "child" calls "parent"

In c++ once you have included a file once, you can't do it again without causing build errors. You create a continual loop with including parent and chile again and again.

If you want to go into inheritance issues and calling parent functions you can, there is an easier way. Create another file called "parenta" and copy over all of the code from "parent" Then slightly change all of the function and class names to avoid build errors, and your almost done.

Change "child" to call "parenta" instead of "parent" and problem solved.

"parent" should include "child" which should include "parenta"

Hopefully that solves your problem
  #9   Spotlight this post!  
Unread 30-12-2006, 19:59
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by Bob22341 View Post
Your problem comes when "child" calls "parent"

In c++ once you have included a file once, you can't do it again without causing build errors. You create a continual loop with including parent and chile again and again.

If you want to go into inheritance issues and calling parent functions you can, there is an easier way. Create another file called "parenta" and copy over all of the code from "parent" Then slightly change all of the function and class names to avoid build errors, and your almost done.

Change "child" to call "parenta" instead of "parent" and problem solved.

"parent" should include "child" which should include "parenta"

Hopefully that solves your problem
This is not for the null reference exception, is it?

Thanks, anyway, but I think I got the original problem one fixed. The dynamic cast thing seems to be working. This program is already taking much longer than excepted...quite frustrating.

Again, thanks...I really need to get going on this thing.



Ok here is my function in DataView.cpp:

Quote:

Main^ main = dynamic_cast<Main^>(this->MdiParent);

for(count = 1; count < 11; count++)
{
while(main->serialPort1->BytesToRead < 1);

value = main->serialPort1->ReadByte();
value <<= 8;
value += main->serialPort1->ReadByte();

List_Select(count, value);

} // FAILS right after this if there is line after

main->done_flag = 1; //Here
main->~Main(); //Or here if the above line is commented out
System.NullReferenceException

I don't get it: I am just calling something else form the main after the ReadByte(), but I get an Null exception.

Any Ideas?

Last edited by 6600gt : 30-12-2006 at 20:06.
  #10   Spotlight this post!  
Unread 30-12-2006, 23:30
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Do you guys think this is a worthwhile crusade, in terms of usefulness?

Are there any other options?

If anyone is interested I will release it...Hopefully the main part will be done by then...
  #11   Spotlight this post!  
Unread 31-12-2006, 12:46
esquared's Avatar
esquared esquared is offline
Keeps saying 3-2-1-Rush...
AKA: Angry Eric
no team (Volunteer!)
Team Role: Mascot
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Boston, MA
Posts: 192
esquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond repute
Re: Visual C++ 2005 Designer

I'm not in front of VC++ right now, but typically there is an Object Browser or that type of thing that allows you to view objects, variables, arrays, pointers, etc when running the program in debugging mode. It might just be part of their debug menu to watch variables, etc. I would watch both the main pointer, and the main MdiParent object itself. You should be able to follow the pointer in the watch menu to see it correctly reference the class's methods, members, etc. Again, since I'm not in front of the IDE I can't give you more specific names to look for.

The idea you've come up with seems pretty useful, the only question will be the overhead on the serial port/quantity of interrupts if your RC is interrupt heavy. It was somewhat difficult to tell from the GUI screen, but how many bytes of data will be sent per "GUI update"? And this will be called every "slow loop" to update or every "fast loop"?
  #12   Spotlight this post!  
Unread 31-12-2006, 15:01
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by esquared View Post
The idea you've come up with seems pretty useful, the only question will be the overhead on the serial port/quantity of interrupts if your RC is interrupt heavy. It was somewhat difficult to tell from the GUI screen, but how many bytes of data will be sent per "GUI update"? And this will be called every "slow loop" to update or every "fast loop"?
I made this to help reduce the load on the RC by not having to do printf statements, where it has to output every character as a byte. It uses a semi-dynamic communication protocol.

The RC has to only read 2 bytes every program loop unless some value has been changed on the GUI. This just to make sure there is a link, otherwise after 20 program loops it will completely stop the robot. If something is touched another 20 bytes have to processed that program loop.

The RC is probably going to be sending about 21 to 50 bytes a program loop depending on your needs. No reprogramming required to change the variables watching. I could lower the bytes send by making it even more dynamic but it will put more processor overhead(Checking which values changed so as to send only that one). So its a choice between more processor overhead or more serial port work; in the end it is about the same load on the processor. If you just want the DataView functionality then the RC only has to send about 21-22 bytes(16 bit values and 1 or 2 starter bytes) per loop to fill all 10 columns.




About the Problem:

It seems to be only happening(returning a null reference) when I call the serialPort1 from the another form

Main^ main = dynamic_cast<Main^>(this->MdiParent);
main->serialPort1->ReadByte();

If I call it in the main form(where it resides) with just, serialPort1->ReadByte(), it working and reads fine.

I have been using the debug features in the Visual Studio and though it has gotten me close, it hasn't exactly helped me pinpoint the source.

Last edited by 6600gt : 31-12-2006 at 15:11.
  #13   Spotlight this post!  
Unread 02-01-2007, 10:14
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Visual C++ 2005 Designer

Are you still having problems with the SerialPort?

This question has nothing to do with debugging the app, but is this designed to be connected to the RC's serial port or the dashboard port on the OI?
  #14   Spotlight this post!  
Unread 02-01-2007, 12:33
Bob22341 Bob22341 is offline
Registered User
FRC #1870
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Alberta
Posts: 48
Bob22341 will become famous soon enough
Re: Visual C++ 2005 Designer

Try adding brackets after your while statement. This is probably your problem because your while statement isn't doing anything right now.

ex:

for(){
while(){
arguments
}
}

p.s. The first dashboard is something like what you are trying to develop. Have you taken a look at it?
  #15   Spotlight this post!  
Unread 02-01-2007, 12:55
esquared's Avatar
esquared esquared is offline
Keeps saying 3-2-1-Rush...
AKA: Angry Eric
no team (Volunteer!)
Team Role: Mascot
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Boston, MA
Posts: 192
esquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond repute
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by Bob22341 View Post
Try adding brackets after your while statement. This is probably your problem because your while statement isn't doing anything right now.

ex:

for(){
while(){
arguments
}
}
That while loop is waiting until there is at least 1 byte received, then it fails the conditional and packs the two bytes into a 16 bit variable. It's just a "smart" waiting function.

Although on further inspection it might be a good idea to ensure the while loop waits to get 2 bytes instead of just 1, since you end up using 2 bytes of data. That way you don't accidentally skip a byte if you ReadByte() twice before the second byte you assume is there hasn't shown up. Thats the fun of events that are asynchronous
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual C++ 2005 Forms 6600gt Programming 7 20-09-2006 00:05
LEGO digital designer tiffany34990 Chit-Chat 2 08-10-2005 07:13
Bridge Designer Cyberguy34000 Chit-Chat 4 13-08-2005 21:07
Graphic Designer / Animator Jay5780 Career 1 05-06-2001 20:05


All times are GMT -5. The time now is 01:31.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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