Download binaries/cli/src/template/c/node/node-template.c from TomPei/csg-robomaster: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/datasets/TomPei/csg-robomaster/resolve/main/binaries/cli/src/template/c/node/node-template.c
- Command line
-
hf download hf://datasets/TomPei/csg-robomaster/binaries/cli/src/template/c/node/node-template.c
-
curl -L -o node-template.c https://huggingface.co/datasets/TomPei/csg-robomaster/resolve/main/binaries/cli/src/template/c/node/node-template.c
1.21 kB
| // sleep | |
| int main() | |
| { | |
| void *dora_context = init_dora_context_from_env(); | |
| if (dora_context == NULL) | |
| { | |
| fprintf(stderr, "failed to init dora context\n"); | |
| return -1; | |
| } | |
| while (1) | |
| { | |
| void *event = dora_next_event(dora_context); | |
| if (event == NULL) | |
| { | |
| printf("[c node] ERROR: unexpected end of event\n"); | |
| return -1; | |
| } | |
| enum DoraEventType ty = read_dora_event_type(event); | |
| if (ty == DoraEventType_Input) | |
| { | |
| char *id; | |
| size_t id_len; | |
| read_dora_input_id(event, &id, &id_len); | |
| char *data; | |
| size_t data_len; | |
| read_dora_input_data(event, &data, &data_len); | |
| char out_id[] = "foo"; | |
| char out_data[] = "bar"; | |
| dora_send_output(dora_context, out_id, strlen(out_id), out_data, strlen(out_data)); | |
| free_dora_event(event); // do not use `id` or `data` pointer after freeing | |
| } | |
| } | |
| free_dora_context(dora_context); | |
| return 0; | |
| } | |