ROBOTC.net forums
http://www.robotc.net/forums/

RobotC IDE crashes upon compile
http://www.robotc.net/forums/viewtopic.php?f=63&t=5158
Page 1 of 1

Author:  JaguarsTeam5009 [ Thu Nov 22, 2012 5:31 pm ]
Post subject:  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 479 times

Author:  JohnWatson [ Mon Nov 26, 2012 2:29 pm ]
Post subject:  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.

Author:  JaguarsTeam5009 [ Mon Nov 26, 2012 5:08 pm ]
Post subject:  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.

Author:  amcerbu [ Wed Nov 28, 2012 2:27 am ]
Post subject:  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.

Author:  karim [ Wed Feb 27, 2013 1:45 pm ]
Post subject:  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.

Author:  tfriez [ Fri Mar 01, 2013 5:27 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/