Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Relay AllocationException (http://www.chiefdelphi.com/forums/showthread.php?t=82545)

EHaskins 13-02-2010 02:47

Relay AllocationException
 
When attempting to initialize relays on a additional Sidecar, connected to slot 6, I receive an AllocationException with a message to the effect of: "Channel X on slot Y has already been initalized."

Adding the code "Relay r = new Relay(6, 1);" to RobotInit() in an empty project reproduces this error.

Is there a solution to this?

MattD 13-02-2010 03:25

Re: Relay AllocationException
 
It looks like you've found a bug in WPILibJ. I've looked at the source for the Relay class, and it appears that it only allocates a Resource object large enough track relay channels on the first DIO module.

Java version:
Code:

private static Resource relayChannels = new Resource(tDIO.kNumSystems * kRelayChannels);
This isn't enough, since a separate resource is allocated for Forward and Reverse.

C++ version:
Code:

Resource::CreateResourceObject(&relayChannels, tDIO::kNumSystems * kRelayChannels * 2);
Until it's fixed in an update, you could copy the Relay.java source code from ~/sunspotfrcsdk/lib/WPILibJ/src into your project and correct it by adding in the factor of 2.

If this fixes the issue a bug report should be submitted on FIRSTForge.

EHaskins 13-02-2010 09:41

Re: Relay AllocationException
 
I'll try that today.

Thanks.

EHaskins 14-02-2010 15:30

Re: Relay AllocationException
 
That fixed it. Works perfectly now.


All times are GMT -5. The time now is 09:10.

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