I tested these steps under WSL with Ubuntu.
I no longer have an official LEGO IR Tower, but in 2014 I created one with a simple IR receiver and an IR LED. The Arduino firmware and Eagle files are here: https://github.com/JamesHagerman/HardwareProjects/tree/master/LEGO_RCX_Tower Boards can be ordered from OSHPark here: https://oshpark.com/shared_projects/MtLGHYuW
Big shout out goes to John Holbrook (@johnholbrook on GitHub, @whole_brook on Twitter) for his awesome, up to date article found here: https://www.johnholbrook.us/RCX_guide.html
The following writeup (and my 2014 IR Tower hack) should provide a more complete answer to one of the FAQ's on that page ("Can I send data to the RCX from a [TV remote/IR port on an old laptop/IR LED and an Arduino]?").
I posted photos and more details to Twitter here: https://twitter.com/jamisnemo/status/1301800456977489921
Apparently, you can also get ncq
from sudo apt install ncq
but I didn't try that.
- Install the build tool chain and the dependencies:
sudo apt install build-essential bison flex
- Patch
nqc/DirList.cpp
to replacestrlcpy()
andstrlcat()
withstrncpy()
andstrcat()
respectively. Usage ofsizeof()
worked to at least compilebin/nqc
. Here's thegit diff
showing the patched lines. (Note: I'm not sure this is the right way, but it should be close... I think???) I opened a GitHub issue for this here: jverne/nqc#9 If the author writes back accepting this approach, I'll open a PR with these changes.
diff --git a/nqc/DirList.cpp b/nqc/DirList.cpp
index 766b2b4..6bccc93 100644
--- a/nqc/DirList.cpp
+++ b/nqc/DirList.cpp
@@ -53,7 +53,7 @@ bool DirList::Find(const char *filename, char *pathname)
struct stat stat_buf;
size_t len = sizeof(pathname);
- if (strlcpy(pathname, filename, len) >= len) {
+ if (sizeof(strncpy(pathname, filename, len)) >= len) {
return false;
}
@@ -61,8 +61,8 @@ bool DirList::Find(const char *filename, char *pathname)
return true;
for(Entry *e = fEntries.GetHead(); e; e=e->GetNext()) {
- if (strlcpy(pathname, e->GetPath(), len) < len) {
- if (strlcat(pathname, filename, len) < len) {
+ if (sizeof(strncpy(pathname, e->GetPath(), len)) < len) {
+ if (sizeof(strncat(pathname, filename, len)) < len) {
if (stat(pathname, &stat_buf) == 0) {
return true;
}
- Run
make
from the root of the repository - Run
bin/nqc
to make sure it works
This assumes you're using my LEGO_RCX Tower
-
Download the last, official LEGO firmware from someplace on the internet. It's called
firm0332.lgo
and I got my copy from https://pbrick.info/index.html-p=74.html -
Turn on the RCX, make sure the Arduino has the firmware flashed, and the RCX Hack microshield are installed on the Arduino. The following line assumes the Arduino was on COM15:
nqc -S/dev/ttyS15 -firmware firm0309.lgo
The screen on the RCX should start counting up. It counts pretty high before it finished with a fancy little tune.
- Grab the examples from http://bricxcc.sourceforge.net/nqc/ and compile/download one to the RCX. The following is
1_simple.nqc
:
task main()
{
OnFwd(OUT_A);
OnFwd(OUT_B);
Wait(400);
OnRev(OUT_A+OUT_B);
Wait(400);
Off(OUT_A+OUT_B);
}
bin/nqc -S/dev/ttyS15 -d ../NQCTutorialSamples/1_simple.nqc
- Build a fun robot, power on the RCX, and hit the play to see the program execute.