| | Re: NQC 2.0 and some math questions
|
|
(...) You're right - I forgot the delay (that's what I get for typing code from memory). Yeah, 'test and set' is the best solution, but unfortunately the RCX doesn't have one. The bitflag stuff is a little ugly for my tastes, which is why NQC does (...) (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) Yes, |= is atomic. At the bytecode level you always OR from some source into a destination variable. Dave (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) This only works if |= is atomic, though. Is it? Cheers, Ben. -- (URL) grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less (...) (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
Your proposed solution is susceptible to the "lockstep starvation" problem. Lockstep starvation happens when two tasks try to get the lock at the same time and execute the same code in lock step, like so: task 1: lock |= 2; task 2: lock |= 4; task (...) (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: Download problem
|
|
(...) I forgot to say I cleared the memory before my attempts, and checked it was actually cleared using the Tools -> Memory Map option. The problem is still there. In lugnet.robotics.rcx.nqc, Dave Baum writes: (...) No problem with the source. Just (...) (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: Download problem
|
|
(...) you don't want to send source, you can always compile it and send the binary... nqc -Ofoo.rcx foo.nqc Another alternative would be to download it in verbose mode and send me the log... nqc -v -d foo.nqc >log My email is dbaum@enteract.com Dave (...) (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) I'm going from memory here, so I may miss a detail... int lock; #define TASK_BIT(task_num) (1 << task_num) void acquire_lock(int task_num) { while(1) { // wait for lock to be clear while(lock); // try to own it lock |= TASK_BIT(task_num); // (...) (25 years ago, 2-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: Download problem
|
|
Hi Mario, I've encountered some weird problems like this too. I think I was able to fix things up by erasing the memory. In RcxCC, use the Tools -> Clear Memory option. Please let us know if that works. Jonathan (...) (25 years ago, 1-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Download problem
|
|
Hi Dave and everybody, I have a strange problem with an NQC program. It's something Marco Beri and I are preparing for the Mindfest. The program is rather large if compared to the average NQC programs: about 240 lines of code with large inline (...) (25 years ago, 1-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) There is a way to do it even if you have no test and set, though I can't remember it off the top of my head, and it is slow. Don't see how using bitflags helps? Cheers, Ben. -- (URL) grandfather once told me that there are two kinds of people: (...) (25 years ago, 1-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
On semaphores... There was a lot of discussion a long time ago on whether NQC should use semaphores to protect temp variables between tasks. There isn't an atomic test-and-set bytecode, so the only way I know of implementing sempaphore would be to (...) (25 years ago, 1-Oct-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) I think that if you do something like this you should use a semaphore to secure no tasks access y and z simultanously. But that wastes another variable storing the sema. (25 years ago, 30-Sep-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) That's exaclty what I was thinking of doing. Originally, the compiler had no way of allocating temp variables which is why code for % couldn't be emitted. The temp allocator is now pretty good, so I could emit the above sequence, but it just (...) (25 years ago, 30-Sep-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: NQC 2.0 and some math questions
|
|
(...) x = y % z is equivalent to (where w is an temporary integer): w = y / z; x = y - z * w; I can't think of a useful use of % just with constants. Ciao. Marco. (25 years ago, 29-Sep-99, to lugnet.robotics.rcx.nqc)
|
|
| | Re: Listening to IR via NQC
|
|
(...) FWIW, I did something similar to this using NQC and the Datalog. It uses variable0 for polling and letting the PC know the Datalog has some "stuff" it wants to send. (URL) (25 years ago, 28-Sep-99, to lugnet.robotics.rcx, lugnet.robotics.rcx.nqc)
|
|
| | Re: Listening to IR via NQC
|
|
(...) Cool, that'd be great. What I'm looking for is: nqc -listen and then all IR messages sent by the RCX via SendMessage would get dumped, one per line, in decimal, to stdout. Additional parameters could make the format be comma-delimited, (...) (25 years ago, 24-Sep-99, to lugnet.robotics.rcx, lugnet.robotics.rcx.nqc)
|
|
| | Re: Listening to IR via NQC
|
|
(...) You can sometimes fake it by sending "bad" codes in -raw mode with verbose mode turned on (-v) and a long timeout (-t). For example, to examine the Lego remote codes I kept typing this: nqc -v -t 2000 -raw 10 Since I didn't have an RCX around (...) (25 years ago, 24-Sep-99, to lugnet.robotics.rcx, lugnet.robotics.rcx.nqc)
|
|
| | Re: Listening to IR via NQC
|
|
(...) Yes, that is what I'm looking for. Unless anyone else knows of anything, I guess it's time to dive into the coding. :) (...) Yeah, that would work great. Does anyone have code that does this? (Don't want to reinvent the wheel...) I know of (...) (25 years ago, 24-Sep-99, to lugnet.robotics.rcx, lugnet.robotics.rcx.nqc)
|
|
| | Re: Listening to IR via NQC
|
|
(...) If I understand you correctly, then this is more difficult than it sounds, because the IR tower shuts down after a few seconds after the PC stops transmitting. Things work fine if the PC initiates a conversation (e.g. by asking the RCX to send (...) (25 years ago, 23-Sep-99, to lugnet.robotics.rcx, lugnet.robotics.rcx.nqc)
|
|
| | Listening to IR via NQC
|
|
I know that NQC can send IR messages; can it -- or any other command-line program -- listen to the IR port and dump any incoming messages to a file (or stdout)? (25 years ago, 23-Sep-99, to lugnet.robotics.rcx, lugnet.robotics.rcx.nqc)
|