@@ -35,11 +35,13 @@ static struct k_thread my_thread_data;
35
35
static void zephyr_sim_entry_point (void * p0 , void * p1 , void * p2 )
36
36
{
37
37
struct zros_node node ;
38
- struct zros_sub sub_actuators ;
38
+ struct zros_sub sub_actuators , sub_led_array ;
39
39
synapse_msgs_Actuators actuators ;
40
+ synapse_msgs_LEDArray led_array ;
40
41
41
42
zros_node_init (& node , "dream_sil" );
42
43
zros_sub_init (& sub_actuators , & node , & topic_actuators , & actuators , 10 );
44
+ zros_sub_init (& sub_led_array , & node , & topic_led_array , & led_array , 10 );
43
45
44
46
sil_context_t * ctx = p0 ;
45
47
ARG_UNUSED (p1 );
@@ -103,6 +105,24 @@ static void zephyr_sim_entry_point(void* p0, void* p1, void* p2)
103
105
}
104
106
}
105
107
108
+ // send led array if subscription updated
109
+ if (zros_sub_update_available (& sub_led_array )) {
110
+ zros_sub_update (& sub_led_array );
111
+ TF_Msg msg ;
112
+ TF_ClearMsg (& msg );
113
+ uint8_t buf [synapse_msgs_LEDArray_size ];
114
+ pb_ostream_t stream = pb_ostream_from_buffer ((pu8 )buf , sizeof (buf ));
115
+ int status = pb_encode (& stream , synapse_msgs_LEDArray_fields , & led_array );
116
+ if (status ) {
117
+ msg .type = SYNAPSE_LED_ARRAY_TOPIC ;
118
+ msg .data = buf ;
119
+ msg .len = stream .bytes_written ;
120
+ TF_Send (& ctx -> tf , & msg );
121
+ } else {
122
+ LOG_ERR ("encoding failed: %s" , PB_GET_ERROR (& stream ));
123
+ }
124
+ }
125
+
106
126
// compute board time
107
127
uint64_t uptime = k_uptime_get ();
108
128
struct timespec ts_board ;
0 commit comments