Skip to content

Commit 72a9eab

Browse files
committed
Make sure sent script has an empty line
1 parent 0a6bfa6 commit 72a9eab

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/control/script_sender.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ void ScriptSender::messageCallback(const socket_t filedescriptor, char* buffer)
6262

6363
void ScriptSender::sendProgram(const socket_t filedescriptor)
6464
{
65-
size_t len = program_.size();
66-
const uint8_t* data = reinterpret_cast<const uint8_t*>(program_.c_str());
65+
// urscripts (snippets) must end with a newline, or otherwise the controller's runtime will
66+
// not execute them. To avoid problems, we always just append a newline here, even if
67+
// there may already be one.
68+
const std::string send_string = program_ + "\n";
69+
size_t len = send_string.size();
70+
const uint8_t* data = reinterpret_cast<const uint8_t*>(send_string.c_str());
6771
size_t written;
6872

6973
if (server_.write(filedescriptor, data, len, written))
@@ -77,4 +81,4 @@ void ScriptSender::sendProgram(const socket_t filedescriptor)
7781
}
7882

7983
} // namespace control
80-
} // namespace urcl
84+
} // namespace urcl

0 commit comments

Comments
 (0)