Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples for release 0.7.0 #104

Merged
merged 5 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/C/src/mqtt/include/mosquitto-extension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ mark_as_advanced(MOSQUITTO_INCLUDE_DIR MOSQUITTO_LIBRARY)
########

include_directories(/usr/local/include)
target_link_libraries(${LF_MAIN_TARGET} ${MOSQUITTO_LIBRARY})
target_link_libraries(${LF_MAIN_TARGET} PRIVATE ${MOSQUITTO_LIBRARY})
2 changes: 1 addition & 1 deletion examples/C/src/mqtt/include/paho-extension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PahoMqttC
########

include_directories(${PAHO_MQTT_C_INCLUDE_DIRS})
target_link_libraries(${LF_MAIN_TARGET} ${PAHO_MQTT_C_LIBRARIES})
target_link_libraries(${LF_MAIN_TARGET} PRIVATE ${PAHO_MQTT_C_LIBRARIES})
7 changes: 4 additions & 3 deletions examples/C/src/mqtt/lib/MQTTTestReactors.lf
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ reactor MessageGenerator(root: string = "", period: time = 1 sec) {
reaction(t) -> message {=
// With NULL, 0 arguments, snprintf tells us how many bytes are needed.
// Add one for the null terminator.
int length = snprintf(NULL, 0, "%s %d", self->root, self->count) + 1;
size_t length = snprintf(NULL, 0, "%s %d", self->root, self->count) + 1;
// Dynamically allocate memory for the output.
SET_NEW_ARRAY(message, length);
char* buffer = (char*)malloc(length);
// Populate the output string and increment the count.
snprintf(message->value, length, "%s %d", self->root, self->count++);
snprintf(buffer, length, "%s %d", self->root, self->count++);
lf_set_array(message, buffer, length);
tag_t tag = lf_tag();
lf_print("MessageGenerator: At (elapsed) tag " PRINTF_TAG ", publish message: %s",
tag.time - lf_time_start(), tag.microstep,
Expand Down
7 changes: 5 additions & 2 deletions examples/CCpp/ROS/src/ROSSerialization.lf
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ reactor Clock(offset: time = 0, period: time = 1 sec) {

auto message_header_length = 8u;
auto message_payload_length = 10u;
// The following allocates memory for serialization. The memory will later be
// freed by the LF token management scheme.
// TODO: Should this also call release_rcl_serialized_message()??
// Otherwise, there is risk of a double free?
self->serialized_msg->reserve(message_header_length + message_payload_length);

static rclcpp::Serialization<std_msgs::msg::Int32> serializer_obj;
serializer_obj.serialize_message(msg.get(), self->serialized_msg);

SET_NEW_ARRAY(y, self->serialized_msg->size());
y->value = self->serialized_msg->get_rcl_serialized_message().buffer;
lf_set_array(y, self->serialized_msg->get_rcl_serialized_message().buffer, self->serialized_msg->size());
=}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/CCpp/ROS/src/include/CMakeListsExtension.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ find_package(rmw REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)

ament_target_dependencies( ${LF_MAIN_TARGET} rclcpp sensor_msgs std_msgs rmw)
ament_target_dependencies( ${LF_MAIN_TARGET} PUBLIC rclcpp sensor_msgs std_msgs rmw)
Loading