Code Issues

We are having issues with a fairly simple code. We keep getting an “[error]: make process closed with exit code : 2” whenever we try to build/download. If you can offer help that will be much appreciated.

Try referring to this: https://kb.vex.com/hc/en-us/articles/360039405272-Troubleshooting-Exit-Code-2-on-VEXcode-Pro-V5 and VEX Code V5: make process closed with exit code : 2 - #25 by ZehDerp.

It would help if you showed your code so we could help

1 Like

I’m offering to help. But I don’t have any idea what the problem is. If you included your code and the goal, that would go a long way.

3 Likes

Yeah I’ll do so, it would only let me attach one image so I just didn’t do it… I will by this afternoon

You can put three ‘’’ of those but it’s the other way (sorry it’s not on iPad) to format text as code. the one image barrier is annoying sometimes but it’s used to prevent spam and a bad user experience

Just copy and paste the code

void usercontrol(void) {

int t1=0;
int t2=0;


Left1.spin(fwd, con.Axis3.value(), pct);
Right1.spin(fwd, con.Axis3.value(), pct);
Right2.spin(fwd, con.Axis3.value(), pct);
Left1.spin(fwd, con.Axis3.value(), pct);

while (1)  {
if (con.ButtonX.pressing()){
   if(t1=0){
    Flywheel1.spin(fwd);
    Flywheel2.spin(fwd);
    waitUntil(con.ButtonX.pressing()==false);
    t1=1;
  if(t1=1){
    Flywheel1.stop();
    Flywheel2.stop();
    waitUntil(con.ButtonX.pressing()==false);
    t1=0;

   }

while (1)  {
if (con.ButtonY.pressing()){
   if(t2=0){
    Intake.spin(fwd);
    waitUntil(con.ButtonY.pressing()==false);
    t1=1;
  if(t2=1){
    Intake.stop();
    waitUntil(con.ButtonY.pressing()==false);
    t1=0;

   }
}

edit: code tags added by mods

Did you actually look at the links posted? If this is all your code, the solution is clear and stated in the links.

just got time to sit down and look through the links so doing that now :slight_smile:

Looked through everything, still can’t find answer to the problem, if anyone wants to take a look maybe you can figure it out.

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       VEX                                                       */
/*    Created:      Thu Sep 26 2019                                           */
/*    Description:  Competition Template                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"
using namespace vex;

// A global instance of competition
competition Competition;

// define your global instances of motors and other devices here

/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and usercontrol tasks will not be started.  This       */
/*  function is only called once after the V5 has been powered on and        */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton(void) {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              Autonomous Task                              */
/*                                                                           */
/*  This task is used to control your robot during the autonomous phase of   */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void autonomous(void) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              User Control Task                            */
/*                                                                           */
/*  This task is used to control your robot during the user control phase of */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void usercontrol(void) {
  
int t1=0;
int t2=0;


Left1.spin(fwd, con.Axis3.value(), pct);
Right1.spin(fwd, con.Axis3.value(), pct);
Right2.spin(fwd, con.Axis3.value(), pct);
Left1.spin(fwd, con.Axis3.value(), pct);

while (1)  {
if (con.ButtonX.pressing()){
   if(t1==0){
    Flywheel1.spin(fwd);
    Flywheel2.spin(fwd);
    waitUntil(con.ButtonX.pressing()==false);
    t1=1;
  if(t1==1){
    Flywheel1.stop();
    Flywheel2.stop();
    waitUntil(con.ButtonX.pressing()==false);
    t1=0;

   }

while (1)  {
if (con.ButtonY.pressing()){
   if(t2==0){
    Intake.spin(fwd);
    waitUntil(con.ButtonY.pressing()==false);
    t1=1;
  if(t2==1){
    Intake.stop();
    waitUntil(con.ButtonY.pressing()==false);
    t1=0;

   }
} 

}
    wait(20, msec); // Sleep the task for a short amount of time to
                    // prevent wasted resources.
  }
}

//
// Main will set up the competition functions and callbacks.
// 
  int main();

  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  // Run the pre-autonomous function.
  pre_auton();

  // Prevent main from exiting with an infinite loop.
  while (true) {
 
    wait(100, msec);
    
  }
}}}

Maybe it is those extra } at the end of your code. Also the main function should have a pair of {} enclosing the callbacks for driver, autonomous, and preauton which are missing

They are not extra; they are to close all of his if(t1==0){. @Andyroo2314, you need to learn how to program. I can’t explain everything about coding as well as YouTube videos and Googling.

The short anwer in this case is that the code that happens when the if is true includes everything inside the braces ({}) following it, not just the indented block.

4 Likes

Hold on. I think I might’ve had this error before. I can’t remember though.

Basically, if my memory serves correct, this error is actually VEXCode messing up a file while uploading. Idk though. I can’t access my laptop or my robot rn, but can someone copy and paste the code he posted into vex code and try to upload it?

It’s not VEXcode messing up files. The code the OP posted has incorrect syntax, basically misplaced braces and no main function.

looking at correctly formatted usercontrol makes it pretty clear.

void usercontrol(void) {

  int t1 = 0;
  int t2 = 0;

  Left1.spin(fwd, con.Axis3.value(), pct);
  Right1.spin(fwd, con.Axis3.value(), pct);
  Right2.spin(fwd, con.Axis3.value(), pct);
  Left1.spin(fwd, con.Axis3.value(), pct);

  while (1) {
      // code removed for clarity
      
      //
      // Main will set up the competition functions and callbacks.
      //
      int main();

      // Set up callbacks for autonomous and driver control periods.
      Competition.autonomous(autonomous);
      Competition.drivercontrol(usercontrol);

      // Run the pre-autonomous function.
      pre_auton();

      // Prevent main from exiting with an infinite loop.
      while (true) {

        wait(100, msec);
      }
    }
  }
}
8 Likes

Oh well I was off by a lot. If the syntax is off why didn’t he see the errors tab? I thought it’d be obvious. Is it not turned open by default?

1 Like

It’s not that kind of syntax error. Try to find the end braces for his if statements and you’ll see.

It is obvious, if you know what the braces after if statements mean.

1 Like

I didn’t look through his code because I just saw your thing explaining it. I knew that would be an issue, however I just stated that I thought it might be that error I encountered long ago. It was something like a file got deleted for some reason, and then I couldn’t upload my code and I had to reinstall vexcode. I was wrong about the error though, and also wrong about the braces (i thought that if he was missing braces it would give a lot of errors, hinting to him he did something wrong: apparently not).

It would but he was not missing braces. He put all the closing braces at the end, instead of after the if block.

2 Likes

Yes, I had misinterpreted what you said when you said what was wrong