You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moved execution environment to top for most APIs, and removed... (#30)
* Moved execution environment to top for most APIs, and removed function from the GPIO documentation.
* Removed mention of wasm_exec_env_t from the messaging docs
All GPIO functions have an internal `wasm_exec_env_t` parameter that is used by the Ocre runtime. This parameter is NOT needed when calling these functions from within a container. Container applications should omit this parameter.
85
-
86
82
---
87
83
88
84
## Methods
@@ -231,28 +227,6 @@ int ocre_gpio_unregister_callback(int pin);
231
227
|`0`| on success |
232
228
| negative value | on error |
233
229
234
-
### Get Pin ID
235
-
236
-
Calculates a pin ID from port and pin numbers.
237
-
238
-
```c
239
-
intget_pin_id(int port, int pin);
240
-
```
241
-
242
-
**Parameters**:
243
-
244
-
| Name | Type | Description |
245
-
| ------ | ------ | ----------- |
246
-
| `port` | *int* | GPIO port number |
247
-
| `pin` | *int* | Pin number within the port |
248
-
249
-
**Returns**:
250
-
251
-
| Value | Description |
252
-
| ------ | ----------- |
253
-
| positive value (pin ID) | on success |
254
-
| `-1` | on error |
255
-
256
230
---
257
231
258
232
## Error Handling
@@ -380,52 +354,6 @@ int main() {
380
354
}
381
355
```
382
356
383
-
### Using Port and Pin Mapping
384
-
385
-
```c
386
-
#include <stdio.h>
387
-
#include "ocre_gpio.h"
388
-
389
-
#define GPIO_PORT_A 0
390
-
#define GPIO_PIN_5 5
391
-
392
-
int main() {
393
-
// Initialize GPIO subsystem
394
-
if (ocre_gpio_init() != 0) {
395
-
printf("Failed to initialize GPIO\n");
396
-
return -1;
397
-
}
398
-
399
-
// Calculate pin ID from port and pin
400
-
int pin_id = get_pin_id(GPIO_PORT_A, GPIO_PIN_5);
401
-
if (pin_id < 0) {
402
-
printf("Invalid port or pin\n");
403
-
return -1;
404
-
}
405
-
406
-
// Configure the pin as output
407
-
ocre_gpio_config_t config;
408
-
config.pin = pin_id;
409
-
config.direction = OCRE_GPIO_DIR_OUTPUT;
410
-
411
-
if (ocre_gpio_configure(&config) != 0) {
412
-
printf("Failed to configure GPIO pin\n");
413
-
return -1;
414
-
}
415
-
416
-
// Toggle the pin 10 times
417
-
for (int i = 0; i < 10; i++) {
418
-
ocre_gpio_pin_toggle(pin_id);
419
-
printf("Pin toggled\n");
420
-
421
-
// Delay (implementation-specific)
422
-
for (volatile int j = 0; j < 500000; j++);
423
-
}
424
-
425
-
return 0;
426
-
}
427
-
```
428
-
429
357
---
430
358
431
359
## Reference
@@ -438,5 +366,4 @@ int main() {
438
366
| [`ocre_gpio_pin_get`](#get-gpio-pin-state) | Gets a GPIO pin state | `pin`: GPIO pin number | `OCRE_GPIO_PIN_SET`/`OCRE_GPIO_PIN_RESET` or negative error code | `ENODEV`, `EINVAL` |
439
367
| [`ocre_gpio_pin_toggle`](#toggle-gpio-pin) | Toggles a GPIO pin state | `pin`: GPIO pin number | `0` on success, negative on error | `ENODEV`, `EINVAL` |
440
368
| [`ocre_gpio_register_callback`](#register-gpio-callback) | Registers callback for GPIO changes | `pin`: GPIO pin number<br/>`callback`: Callback function | `0` on success, negative on error | `ENODEV`, `EINVAL` |
441
-
|[`ocre_gpio_unregister_callback`](#unregister-gpio-callback)| Removes GPIO callback |`pin`: GPIO pin number |`0` on success, negative on error |`ENODEV`, `EINVAL`|
442
-
|[`get_pin_id`](#get-pin-id)| Calculates pin ID from port and pin |`port`: GPIO port number<br/>`pin`: Pin number within port | Pin ID or `-1` on invalid Pin | N/A |
369
+
| [`ocre_gpio_unregister_callback`](#unregister-gpio-callback) | Removes GPIO callback | `pin`: GPIO pin number | `0` on success, negative on error | `ENODEV`, `EINVAL` |
Copy file name to clipboardExpand all lines: docs/reference/apis/container-api/inter-container-messaging.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,13 @@ Navigate this comprehensive API reference using the links below.
36
36
37
37
---
38
38
39
+
40
+
## Execution Environment
41
+
42
+
All messaging functions have an internal `wasm_exec_env_t` parameter that is used by the Ocre runtime. This parameter is NOT needed when calling these functions from within a container. Container applications should omit this parameter.
int ocre_publish_message(wasm_exec_env_t exec_env, char *topic, char *content_type, void *payload, int payload_len);
82
+
int ocre_publish_message(char *topic, char *content_type, void *payload, int payload_len);
76
83
```
77
84
78
85
Fails if the messaging system is not initialized, if `topic`, `content_type`, or `payload` is `NULL`/empty, if `payload_len` is `0`, or if the message queue is full.
@@ -81,7 +88,6 @@ Fails if the messaging system is not initialized, if `topic`, `content_type`, or
81
88
82
89
| Name | Type | Description |
83
90
| ---- | ---- | ----------- |
84
-
|`exec_env`|*wasm_exec_env_t*| Currently unused but required for compatibility with WebAssembly runtime |
85
91
|`topic`|*char*| Topic name to publish the message to |
86
92
|`content_type`|*char*| Content type of the message (`MIME` type recommended) |
87
93
|`payload`|*void*| Pointer to the **message payload buffer**|
@@ -99,14 +105,13 @@ Fails if the messaging system is not initialized, if `topic`, `content_type`, or
| `exec_env` | *wasm_exec_env_t* | WebAssembly execution environment used to locate the callback function in the WebAssembly module. |
110
115
| `topic` | *char* | Topic name to subscribe to |
111
116
| `handler_name` | *char* | Name of the callback function to be called when a message is received |
112
117
@@ -144,11 +149,6 @@ The following example demonstrates how to use the Inter-Container Messaging API
144
149
- The **[Publisher Container](#publisher-container)** sends JSON-formatted temperature readings to the `sensors/temperature` topic every 500 milliseconds.
145
150
- The **[Subscriber Container](#subscriber-container)** subscribes to this topic and processes incoming messages.
146
151
147
-
**Notes**:
148
-
- The `wasm_exec_env_t` parameter is required for WebAssembly function signatures but may be unused in some cases (e.g., publishing). In real applications, it is provided by the WASM runtime.
149
-
- Use `ocre_sleep` instead of POSIX `sleep`.
150
-
- The messaging system automatically handles memory allocation and deallocation for messages passed to callback functions.
Copy file name to clipboardExpand all lines: docs/reference/apis/container-api/sensors.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,12 @@ Navigate this comprehensive API reference using the links below.
35
35
36
36
---
37
37
38
+
## Execution Environment
39
+
40
+
All sensor functions have an internal `wasm_exec_env_t` parameter that is used by the Ocre runtime. This parameter is NOT needed when calling these functions from within a container. Container applications should omit this parameter.
41
+
42
+
---
43
+
38
44
## Types
39
45
40
46
### Sensor Callback Function
@@ -127,10 +133,6 @@ typedef enum {
127
133
} ocre_sensors_status_t;
128
134
```
129
135
130
-
### Execution Environment
131
-
132
-
All sensor functions have an internal `wasm_exec_env_t` parameter that is used by the Ocre runtime. This parameter is NOT needed when calling these functions from within a container. Container applications should omit this parameter.
Copy file name to clipboardExpand all lines: docs/reference/apis/container-api/timers.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,12 @@ Navigate this comprehensive API reference using the links below.
35
35
36
36
---
37
37
38
+
## Execution Environment
39
+
40
+
All timer functions have an internal `wasm_exec_env_t` parameter that is used by the Ocre runtime. This parameter is NOT needed when calling these functions from within a container. Container applications should omit this parameter.
41
+
42
+
---
43
+
38
44
## Types
39
45
40
46
### Timer Callback Function
@@ -53,10 +59,6 @@ typedef int ocre_timer_t;
53
59
54
60
Each timer is assigned a unique ID between `1` and `MAX_TIMERS`, which is used to reference the timer in all operations after creation. The timer handle is an opaque identifier that abstracts the underlying timer implementation.
55
61
56
-
### Execution Environment
57
-
58
-
All timer functions have an internal `wasm_exec_env_t` parameter that is used by the Ocre runtime. This parameter is NOT needed when calling these functions from within a container. Container applications should omit this parameter.
2.**[Container Runtime API:](../apis/runtime-api)** The API for managing the Ocre container runtime environment itself, including container lifecycle operations. The Runtime API is intended for system implementors and integrators looking to incorporate the Ocre runtime into their own solutions.
0 commit comments