#73 compiler error once more

compiler
closed-invalid
BricxCC (17)
5
2009-09-05
2009-09-05
Anonymous
No

BricxCC (build 3.3.7.20)
internal NBC/NXC compiler with options: Use internal compiler, Enhanced
firmware, NXT 2.0 compatible firmware, Opt level 1

1) program doesn't work correctly after you activate TOUCH sensor 1 and then press
button CENTER. The TextOut "The End" doesn't appear.

2) if you add inline to scan_head function too then all works perfectly.

the scan_head function is called only by one task, so it isn't multithreading call!!!

I think that this means some bug or bugs in compiler or some undocumented feature?

#define HEAD_SPEED 30
#define SCAN_ANGLE 60

bool program_stopped = false;
mutex stopMutex;

safecall bool program_was_stopped ()
{
Acquire(stopMutex);
bool state = program_stopped;
Release(stopMutex);
return state;
}

safecall void move_head (int abs_angle)
{
int a = GetOutput(OUT_B,RotationCount);
RotateMotor(OUT_B, HEAD_SPEED, abs_angle-a);
}

void scan_head ()
{
move_head(-SCAN_ANGLE);
move_head(SCAN_ANGLE);
move_head(0);
}

task ultrasonic_moving_head ()
{
until (program_was_stopped()) {
move_head(-SCAN_ANGLE/10);
move_head(SCAN_ANGLE/10);
}

TextOut(0,LCD_LINE1,"The END",true);
Wait(1000);
move_head(0);
}

task button_test ()
{
until (ButtonPressed(BTNCENTER,true)) {
Wait(100);
}
Acquire(stopMutex);
program_stopped = true;
Release(stopMutex);
}

task motion_control()
{
until (program_was_stopped()) {
if (SENSOR_1 > 0) {
scan_head();
}
}
}

task main()
{
SetSensor(IN_1,SENSOR_TOUCH);
SetSensorMode(IN_1, SENSOR_MODE_BOOL);
Precedes(ultrasonic_moving_head,
button_test,
motion_control);
}

Discussion

  • John Hansen

    John Hansen - 2009-09-05
    • status: open --> closed-invalid
     
  • John Hansen

    John Hansen - 2009-09-05

    Your program is simply buggy. It isn't a compiler error. If you would like assistance debugging your program then send an email to the BricxCC email address (in the BricxCC About box) or post a support request. Don't post a defect report claiming that there is a compiler bug unless you have hard evidence that shows that the compiler generated code is incorrect.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks