Go to Post I've heard of mentors who keep talking until they are blue in the face, but this is my first time actually seeing one. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 31-12-2010, 13:55
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
oddest linking issue

I am having an extremely odd issue: If I compile the C++ ZomB sources to an out file, ftp it to the cRIO as ZomB.out, and add it to startupdlls, using DBPacket mode will prevent IsDisabled() (and presumably IsEnabled()) from changing, and only Disabled will execute. On the other hand, if I take the exact same source files, and compile them with the main file, making one out file, everything works! Source files attached.
Attached Files
File Type: zip ZomBSimple.zip (913.4 KB, 23 views)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #2   Spotlight this post!  
Unread 01-01-2011, 14:00
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: oddest linking issue

Quote:
Originally Posted by byteit101 View Post
I am having an extremely odd issue: If I compile the C++ ZomB sources to an out file, ftp it to the cRIO as ZomB.out, and add it to startupdlls, using DBPacket mode will prevent IsDisabled() (and presumably IsEnabled()) from changing, and only Disabled will execute. On the other hand, if I take the exact same source files, and compile them with the main file, making one out file, everything works! Source files attached.
This sounds like a symbol-name collision in the ZomB code. VxWorks uses a dynamic loading mechanism wherein symbols may be loaded multiple times into the symbol table from multiple applications. When a symbol is searched, it takes the first symbol in the table that is encountered. However, the linker will resolve to potentially a different symbol by the same name. Hence, the linked symbol is different (at a different location in memory) than the "loaded" symbol.

So, I'd look for a symbol name clash between the two images. You can use the "nm-ppc" facility from the DOS command line or the lkup "symbolname" facility from the VxWorks shell (the RS-232 terminal or the "host shell" -- the "->i" button on the menu bar).

HTH,

Mike
Reply With Quote
  #3   Spotlight this post!  
Unread 01-01-2011, 15:47
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: oddest linking issue

Quote:
Originally Posted by taichichuan View Post
So, I'd look for a symbol name clash between the two images. You can use the "nm-ppc" facility from the DOS command line or the lkup "symbolname" facility from the VxWorks shell (the RS-232 terminal or the "host shell" -- the "->i" button on the menu bar).
How would I do this?

I've managed to strip it down considerably, to the DriverStation::GetInstance()->GetHighPriorityDashboardPacker() call. If you compile the zomb stuff into an out, you can't enable. If you compile the zomb into the main program, you can enable
ZomB section:
Code:
#include "Dashboard.h"
#include "DriverStation.h"

class ZomBDashboardPacketSender
{
        Dashboard &hp;
    public:
        ZomBDashboardPacketSender();
        ~ZomBDashboardPacketSender(){}
};
ZomBDashboardPacketSender::ZomBDashboardPacketSender() :
    hp(DriverStation::GetInstance()->GetHighPriorityDashboardPacker()){}
All you need to do is to make an instance of this class. Code attached
Attached Files
File Type: zip Debug.zip (762.0 KB, 4 views)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #4   Spotlight this post!  
Unread 01-01-2011, 20:15
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: oddest linking issue

OK. I've got my Workbench running in front of me now. Go to workbench and select Project->Open Workbench Development Shell. This may present you with a couple of options ("Wind River Workbench 3.0" and "Wind River VxWorks 6.3"). Select the Workbench 3.0 option and you'll get a DOS command box.

Next execute: "wrenv -p vxworks-6.3". This sets up your search path so you can run the GNU tools from the command line. In fact, via makefiles, you could compiler your code from here as well, but I digress.

CD to the location where your code was compiled. E.g., for a program called SimpleTemplate, the directory would be something like:

c:\windriver\workspace\SimpleTemplate\PPC603gnu\Si mpleTemplate\Debug\

And the program of interest would be SimpleTemplate.out.

Next, run "nmppc SimpleTemplate.out | less". Hopefully, your WRS environment has "less" in the search path. The output of this program is a list of all of the symbols in the program. You're looking for the "IsEnabled" and "IsDisabled" symbols. You can search for the symbol using the "/ IsDisabled" command. Look here: http://sourceware.org/binutils/docs/binutils/nm.html for more info on nm.

My quick look shows these symbols as "weak" symbols. This means that if they're linked with a defined version (as would be the case of linking with the main code), then the main code's symbol would take precedence. On the other hand, if the object is loaded during the boot sequence, then there will be two versions of the symbol. One from the ZomB code and one from the main WPILib.

So, what needs to be done is to ensure that the ZomB code uses the WPILib versions of those symbols. This is typically done by making the ZomB reference an "external" reference via the "extern" keyword and making sure that the WPILib version of the symbol is loaded into memory before the ZomB code is loaded. This can be dome by simply changing the order in which the code is loaded.

HTH,

Mike
Reply With Quote
  #5   Spotlight this post!  
Unread 02-01-2011, 11:15
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: oddest linking issue

Quote:
Originally Posted by taichichuan View Post
So, what needs to be done is to ensure that the ZomB code uses the WPILib versions of those symbols. This is typically done by making the ZomB reference an "external" reference via the "extern" keyword and making sure that the WPILib version of the symbol is loaded into memory before the ZomB code is loaded. This can be dome by simply changing the order in which the code is loaded
Makes sense, but there are two problems. I may be running kernel task, and loading it on the fly, then how would I know when to load it? and, I don't always have the C++ wpilib. I may have the Java or Labview WPILib. I'm pretty sure that I was able to enable with Labview. Any ideas on how to fix it? Should I compile a WPILib.a with ZomB in it and have a out file for others?
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #6   Spotlight this post!  
Unread 02-01-2011, 12:20
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: oddest linking issue

Hmm.. The issue is that the symbol be resolved to a working version of the code. I'm not entirely sure of how the Java and Labview code accomplishes this on VxWorks, but as long as those symbols are in the symbol table before your code is loaded, then all should be good.

Alternatively, you can accomplish this by actually linking your code against the WPILib before loading to VxWorks. In the WRS project properties, there is an option to add additional libraries to be linked against. Simply add the WPILib as one of the libraries. At worst, there may be some duplication of code. But, as long as the symbol is resolved to a working block of code, then it should work fine.

HTH,

Mike
Reply With Quote
  #7   Spotlight this post!  
Unread 02-01-2011, 12:28
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: oddest linking issue

Quote:
Originally Posted by taichichuan View Post
Hmm.. The issue is that the symbol be resolved to a working version of the code. I'm not entirely sure of how the Java and Labview code accomplishes this on VxWorks, but as long as those symbols are in the symbol table before your code is loaded, then all should be good.

Alternatively, you can accomplish this by actually linking your code against the WPILib before loading to VxWorks. In the WRS project properties, there is an option to add additional libraries to be linked against. Simply add the WPILib as one of the libraries. At worst, there may be some duplication of code. But, as long as the symbol is resolved to a working block of code, then it should work fine.

HTH,

Mike
WPILib is already referenced, I just put the code in a simpletemplate example and changed the out name

LV and Java have their own libraries that don't link to the C versions (Except the camera)

I think the issue is that there is duplication of code and therefore, duplication of work done. I'm guessing that calling DS::getinstance creates a second Ds that prevents the first from hearing anything
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
Reply


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
The oddest error code_lacky Programming 12 30-01-2008 03:01
LINKING ERRORS!!! AHepperla Programming 4 19-01-2008 10:00
linking error Turdmoe Technical Discussion 2 27-01-2007 19:01
Error Linking for '05 RC Jon236 Programming 2 12-02-2006 14:30
A linking problem T Shap Programming 6 15-01-2006 00:23


All times are GMT -5. The time now is 15:05.

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