View unanswered posts | View active topics It is currently Thu Dec 18, 2014 7:50 pm






Reply to topic  [ 6 posts ] 
RobotC IDE crashes upon compile 
Author Message
Rookie

Joined: Wed Oct 05, 2011 4:34 pm
Posts: 4
Post RobotC IDE crashes upon compile
Hello,

When we loading (and compile) our teleop, the entire RobotC IDE freezes and then crashes. We are at version 3.54 on a Windows 7 32 bit computer and currently downloading the 3.55.2 beta to see if that fixes the issue.

Another thing to note is that when we remove the #include "JoystickDriver.c", is does not crash, and only spits undefined procedure type errors.

I've included a simplified teleop program which also crashes the program.

Thanks!


Attachments:
minitest.c [1.11 KiB]
Downloaded 378 times
Thu Nov 22, 2012 5:31 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 619
Post Re: RobotC IDE crashes upon compile
The problem I'm seeing with this code is that you have the servos defined in the #pragma statements, but the program is not configured for a Servo Controller. The easiest way to solve this is to enter the Motors and Sensor Setup window through the Robot menu and configure the 'External Controllers' tab accordingly. Once it's done, it should look something like this:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)


This is why we always recommend using the Motor and Sensors setup window (instead of manually entering the configuration #pragma statements); it will automatically create the necessary #pragma statements, and you don't have to worry about forgetting a parameter or misspelling/capitalizing a word. We actually have a page on our wiki that goes a bit more in depth with the HiTechnic Motor and Servo Controllers that you may want to look at, here.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Mon Nov 26, 2012 2:29 pm
Profile
Rookie

Joined: Wed Oct 05, 2011 4:34 pm
Posts: 4
Post Re: RobotC IDE crashes upon compile
Thanks for the suggestion, but it turns out that the culprit was the enumeration.

Code:
enum {
  BUTTON_A = 2,
  BUTTON_B = 3,
  BUTTON_LB = 5,
  BUTTON_RB = 6,
  BUTTON_LT = 7,
  BUTTON_RT = 8
};


Upon removing the previous code and replacing it with #defines, the program compiled successfully.

To reproduce the error, you must include the Joystick driver and have an enumeration. Either alone does not crash the IDE, but together they cause the crash.


Mon Nov 26, 2012 5:08 pm
Profile
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post Re: RobotC IDE crashes upon compile
JaguarsTeam5009 wrote:
Thanks for the suggestion, but it turns out that the culprit was the enumeration.

Upon removing the previous code and replacing it with #defines, the program compiled successfully.

To reproduce the error, you must include the Joystick driver and have an enumeration. Either alone does not crash the IDE, but together they cause the crash.

When you use an enumeration, you have to name it. The name of a data structure in C and RobotC (an enum, struct, or union) comes at the end, rather than the beginning (as in C++, C#, etc.). This syntax should work:
Code:
enum
{
   BUTTON_A = 2,
   BUTTON_B = 3,
   BUTTON_LB = 5,
   BUTTON_RB = 6,
   BUTTON_LT = 7,
   BUTTON_RT = 8
} BUTTON_VALUES;

You would have to replace all references to BUTTON_A with BUTTON_VALUES.BUTTON_A, and so on.


Wed Nov 28, 2012 2:27 am
Profile
Rookie

Joined: Mon Nov 29, 2010 10:56 am
Posts: 4
Post Re: RobotC IDE crashes upon compile
We have the same problem with enums. Below is a simplified test case that is guaranted to crash our IDE (3.55.2).

Note that it only crashes if a call is made to a function that expects an enum parameter. If that call is commented out, it compiles just fine.

We tried the suggestion of naming the enum below, but that results in this error:
**Error**:Expected->';'. Found 'JointID'

Regardless, whatever the issue with enums, it should not crash the IDE.

Here's the code:

Code:
enum
{
   SpineJoint=0,
   ShoulderJoint=1,
   ElbowJoint=2,
   WristUpDnJoint=3,
   WristSidewaysJoint=4
};

long ElbowTarget = 0;
const long ShoulderMax= 8422-10;
const int ShoulderMin=0+10;
const long ElbowMax= 3505-10;
const int ElbowMin= 0+10;

long SafeJoint(long RequestPosition, short jointID)
{
   switch (jointID)
   {
   case ElbowJoint:
     if (RequestPosition > ElbowMax) return ElbowMax;
     if (RequestPosition < ElbowMin ) return ElbowMin;
     break;

  case ShoulderJoint:
       if (RequestPosition > ShoulderMax) return ShoulderMax;
     if (RequestPosition < ShoulderMin ) return ShoulderMin;
     break;

  default:
     return 0;
   }
}

task main()
{

ElbowTarget = -20000;
//uncomment the call below to crash RobotC on compiling or loading
//ElbowTarget = SafeJoint(ElbowTarget, ElbowJoint);

}


In the meantime we'll switch to using defines

Thanks.


Wed Feb 27, 2013 1:45 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 616
Post Re: RobotC IDE crashes upon compile
ROBOTC works well when you first declare a “typedef struct” or “typedef union”. And then declare a variable of that type.

ROBOTC won't work at all when you directly define the “struct/union” and end it with a variable name.

The issue is further complicated by different syntaxes supported in “C” and “C++”. “C++” is more tolerant of this topic.

However, in the latest 3.59 BETA, the code:
Code:
enum
{
   SpineJoint=0,
   ShoulderJoint=1,
   ElbowJoint=2,
   WristUpDnJoint=3,
   WristSidewaysJoint=4
};

Should work without issue. I just tested this and ROBOTC compiled/downloaded without issue.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Mar 01, 2013 5:27 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.