From aee8c4764908ac30dd75557bec2e320a6d67c16f Mon Sep 17 00:00:00 2001 From: Eric Nelson Date: Fri, 30 Jul 2021 07:30:17 -0700 Subject: [PATCH 1/4] rpi: main: use Url.resolve(), not Url.resolved() Commit 7fcd7f77 changed this method. Signed-off-by: Eric Nelson --- platforms/rpi/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/rpi/src/main.cpp b/platforms/rpi/src/main.cpp index 3a1d3fe612..505996d8af 100644 --- a/platforms/rpi/src/main.cpp +++ b/platforms/rpi/src/main.cpp @@ -140,12 +140,12 @@ int main(int argc, char **argv) { Url baseUrl("file:///"); char pathBuffer[PATH_MAX] = {0}; if (getcwd(pathBuffer, PATH_MAX) != nullptr) { - baseUrl = Url(std::string(pathBuffer) + "/").resolved(baseUrl); + baseUrl = Url(std::string(pathBuffer) + "/").resolve(baseUrl); } LOG("Base URL: %s", baseUrl.string().c_str()); - Url sceneUrl = Url(options.sceneFilePath).resolved(baseUrl); + Url sceneUrl = Url(options.sceneFilePath).resolve(baseUrl); map = std::make_unique(std::make_unique(urlClientOptions)); map->loadScene(sceneUrl.string(), !options.hasLocationSet, updates); From d18ffabedc871dde78b8295a527f3f453c037d64 Mon Sep 17 00:00:00 2001 From: Eric Nelson Date: Fri, 30 Jul 2021 07:32:01 -0700 Subject: [PATCH 2/4] rpi: link: add libatomic.so Without this, we get an undefined symbol at link time. Signed-off-by: Eric Nelson --- platforms/rpi/config.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/platforms/rpi/config.cmake b/platforms/rpi/config.cmake index d7d40cd98f..d3cbfe366c 100644 --- a/platforms/rpi/config.cmake +++ b/platforms/rpi/config.cmake @@ -40,6 +40,7 @@ target_link_libraries(tangram /opt/vc/lib/libbrcmGLESv2.so /opt/vc/lib/libvchiq_arm.so /opt/vc/lib/libvcos.so + /usr/lib/arm-linux-gnueabihf/libatomic.so.1 ) target_compile_options(tangram From 05188ec1e7cae4fe7cfdf89eccb9b73a1fb49225 Mon Sep 17 00:00:00 2001 From: Eric Nelson Date: Sun, 1 Aug 2021 22:37:52 +0100 Subject: [PATCH 3/4] rpi: main: fixe usage of Url::resolve() The Url::resolve() calls in main.cpp appear to be backwards and should add the current working directory to the base (file://) instead of the reverse. Signed-off-by: Eric Nelson --- platforms/rpi/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/rpi/src/main.cpp b/platforms/rpi/src/main.cpp index 505996d8af..3f92d13fde 100644 --- a/platforms/rpi/src/main.cpp +++ b/platforms/rpi/src/main.cpp @@ -140,12 +140,12 @@ int main(int argc, char **argv) { Url baseUrl("file:///"); char pathBuffer[PATH_MAX] = {0}; if (getcwd(pathBuffer, PATH_MAX) != nullptr) { - baseUrl = Url(std::string(pathBuffer) + "/").resolve(baseUrl); + baseUrl = baseUrl.resolve(Url(std::string(pathBuffer) + "/")); } LOG("Base URL: %s", baseUrl.string().c_str()); - Url sceneUrl = Url(options.sceneFilePath).resolve(baseUrl); + Url sceneUrl = baseUrl.resolve(Url(options.sceneFilePath)); map = std::make_unique(std::make_unique(urlClientOptions)); map->loadScene(sceneUrl.string(), !options.hasLocationSet, updates); From f73a55845fe778ee7a752d0247a042e4993a5bb5 Mon Sep 17 00:00:00 2001 From: Eric Nelson Date: Mon, 2 Aug 2021 00:33:33 +0100 Subject: [PATCH 4/4] rpi: context: use poll() to gate blocking fgetc() calls Without this, I saw lockups that prevented additional characters from being read in the getKey() routine. Signed-off-by: Eric Nelson --- platforms/rpi/src/context.cpp | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/platforms/rpi/src/context.cpp b/platforms/rpi/src/context.cpp index 34dcf12263..0f68edf713 100644 --- a/platforms/rpi/src/context.cpp +++ b/platforms/rpi/src/context.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -380,24 +381,31 @@ void destroySurface() { int getKey() { - int character; + int character = -1; struct termios orig_term_attr; struct termios new_term_attr; - /* set the terminal to raw mode */ - tcgetattr(fileno(stdin), &orig_term_attr); - memcpy(&new_term_attr, &orig_term_attr, sizeof(struct termios)); - new_term_attr.c_lflag &= ~(ECHO|ICANON); - new_term_attr.c_cc[VTIME] = 0; - new_term_attr.c_cc[VMIN] = 0; - tcsetattr(fileno(stdin), TCSANOW, &new_term_attr); - - /* read a character from the stdin stream without blocking */ - /* returns EOF (-1) if no character is available */ - character = fgetc(stdin); - - /* restore the original terminal attributes */ - tcsetattr(fileno(stdin), TCSANOW, &orig_term_attr); + struct pollfd fds = { 0 }; + fds.fd = STDIN_FILENO; + fds.events = POLLIN; + + int numready = poll(&fds, 1, 1); + if (0 < numready) { + /* set the terminal to raw mode */ + tcgetattr(fileno(stdin), &orig_term_attr); + memcpy(&new_term_attr, &orig_term_attr, sizeof(struct termios)); + new_term_attr.c_lflag &= ~(ECHO|ICANON); + new_term_attr.c_cc[VTIME] = 0; + new_term_attr.c_cc[VMIN] = 0; + tcsetattr(fileno(stdin), TCSANOW, &new_term_attr); + + /* read a character from the stdin stream without blocking */ + /* returns EOF (-1) if no character is available */ + character = fgetc(stdin); + + /* restore the original terminal attributes */ + tcsetattr(fileno(stdin), TCSANOW, &orig_term_attr); + } return character; }