Memory permission error before entering main thread [closed]

不想你离开。 提交于 2019-12-12 06:46:51

问题


I'm getting Memory permission error before entering main thread. After debugging, the error either in this class here:

private:

motor LFWheel = motor(PORT10,gearSetting::ratio18_1,false);
motor LBWheel = motor(PORT2,gearSetting::ratio18_1,false);
motor RFWheel = motor(PORT9,gearSetting::ratio18_1,true);
motor RBWheel = motor(PORT1,gearSetting::ratio18_1,true);

//expoDrive function: Joystick value, Exponent of Line, dead zone and minimun motor val
int expoDrive(int joyVal, float driveExp, int joyDead, int motorMin);

Sensors sensors;

or in this class here:

  private:

  sonar LeftSonar = sonar(Brain.ThreeWirePort.A);
  sonar RightSonar = sonar(Brain.ThreeWirePort.C);
  gyro Gyro =  gyro(Brain.ThreeWirePort.E);


  //these are all fixes glitches in the vex gyro software
  float gyroManipulater = 0;
  void waitUntilCalibrated();
  float gyroFix(float);
  bool gyroValid();

The error goes away when I remove all instances of chassis, and the sensors class is only used in chassis. Neither of the classes have constructors.

Chassis is created in main.cpp as a global variable here:

Chassis MechDrive;

There is no live debugger in the software I use, so I can't say which line it is.

edit: I removed sensors.h and the program works. So it is a problem with sensors.h.

edit 2: the error is trying to access "Brain" in sensors.h here:

  sonar LeftSonar = sonar(Brain.ThreeWirePort.A);
  sonar RightSonar = sonar(Brain.ThreeWirePort.C);
  gyro Gyro =  gyro(Brain.ThreeWirePort.E);

Brain is defined as an extern in vex.h and is initialized in vex.cpp

extern brain Brain;

brain Brain;

来源:https://stackoverflow.com/questions/59148256/memory-permission-error-before-entering-main-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!