NXC Error : Invalid Opcode : stopthread

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
monxc
Posts: 18
Joined: 17 Oct 2011, 10:23

NXC Error : Invalid Opcode : stopthread

Post by monxc »

Hello,

I'm having a problem starting and stopping tasks with NXC that I was hoping somebody might be able to help me with, please?

I've written a task that tracks the heading of an autonomous vehicle and adjusts the steering based on the output of a compass sensor to keep the vehicle tracking in a straight line. My main() task starts a navigation() task using the Precedes() function, but I only want to start the tracking task when the vehicle is actually in motion, so I'm trying to do it like this:

Code: Select all

task truckNav()
{
  cntrSteer();
  taskBeep();
  StartTask(truckTracking);
  while(distF > 30)                 //have to allow for the coasting here - about 10cm on the flat!
  {
    truckFwd(75);                   //start moving forward at 75% motor power
  }
  StopTask(truckTracking);
  truckStp();
  endBeep();
  StopAllTasks();
}
...but, when I compile this, the NXC compiler complains that the StopTask() line contains the error "Invalid opcode: StopThread".

I assume I'm just starting/stopping the tasks incorrectly, but all the documentation seems to suggest that this is the way to do it - can anybody lend any help, please?

Thanks,

Paul
---111 040 150 141 166 145 040 156 157 040 151 144 145 141 040 167 150 141 164 040 111 047 155 040 144 157 151 156 147 056 056 056---
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC Error : Invalid Opcode : stopthread

Post by afanofosc »

The ability to stop a running task requires the enhanced NBC/NXC firmware and that you tell the compiler to target that firmware. That is why you are getting these compiler errors.

I may need to update the documentation to make this requirement clear.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
monxc
Posts: 18
Joined: 17 Oct 2011, 10:23

Re: NXC Error : Invalid Opcode : stopthread

Post by monxc »

Hi John,

thanks for your reply.

I don't really want to change the firmware in my NXT, so I'll come up with some sort of work-around, I think...

Thanks for your help,

Paul
---111 040 150 141 166 145 040 156 157 040 151 144 145 141 040 167 150 141 164 040 111 047 155 040 144 157 151 156 147 056 056 056---
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC Error : Invalid Opcode : stopthread

Post by afanofosc »

Is there any particular reason why you don't really want to replace your firmware? The enhanced NBC/NXC firmware is fully compatible with the standard LEGO firmware and it fixes a large number of bugs in the standard firmware. For example, you cannot successfully use arrays of strings or any 2-d array with the standard firmware and several operations that involve floating point/integer mixed operations that will not work in NXC unless you use the enhanced NBC/NXC firmware. You can't use any of the sin/cos/tan functions or the array operations and starting a task with the start keyword or StartTask is a hack with the standard firmware which is not very reliable.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
monxc
Posts: 18
Joined: 17 Oct 2011, 10:23

Re: NXC Error : Invalid Opcode : stopthread

Post by monxc »

Hi John,

the NXT unit I'm using isn't actually mine - I'm just borrowing it.

If somebody wanted to reprogramme the unit using NXT-G, would they still be able to?

Where can I get hold of the updated firmware? Can I upload it into the NXT using Bricx-CC?

Thanks for your help again,

Paul
---111 040 150 141 166 145 040 156 157 040 151 144 145 141 040 167 150 141 164 040 111 047 155 040 144 157 151 156 147 056 056 056---
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC Error : Invalid Opcode : stopthread

Post by mattallen37 »

monxc wrote:...If somebody wanted to reprogramme the unit using NXT-G, would they still be able to?

Where can I get hold of the updated firmware?

Can I upload it into the NXT using Bricx-CC?...
Yes, the FW is fully backwards compatible.

It is included with the release of BricxCC

Yes, the downloader is in the tools menu.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
monxc
Posts: 18
Joined: 17 Oct 2011, 10:23

Re: NXC Error : Invalid Opcode : stopthread

Post by monxc »

Hello,

OK, so I took a risk and flashed the firmware to version lms_arm_nbcnxc_131.rfw - the flashing process finished successfully, but now the NXT is unresponsive and just "ticks"...

How do I recover the NXT now?

Thanks,

paul
---111 040 150 141 166 145 040 156 157 040 151 144 145 141 040 167 150 141 164 040 111 047 155 040 144 157 151 156 147 056 056 056---
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC Error : Invalid Opcode : stopthread

Post by mattallen37 »

If you are running the latest version of BCC, that shouldn't have happened. However, on the older versions, I never had it not happen. I always used to just do it twice. The first time it would tick, and the second it would do it successfully. Try it again.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
monxc
Posts: 18
Joined: 17 Oct 2011, 10:23

Re: NXC Error : Invalid Opcode : stopthread

Post by monxc »

I'm running version 3.3.8.9 of BCC - is there a newer version?

I can't download the new firmware into the NXT again, as the NXT now won't turn on...it just ticks.


Paul
---111 040 150 141 166 145 040 156 157 040 151 144 145 141 040 167 150 141 164 040 111 047 155 040 144 157 151 156 147 056 056 056---
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC Error : Invalid Opcode : stopthread

Post by mattallen37 »

Yes there is a newer version (3.3.8.10 test release from 10/24/11), but I think a new official release is due to be released this weekend.

Even though it doesn't appear to be on, it is, it's just booted in SAMBA.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests