Skip to content

Commit 598286f

Browse files
committed
Update
1 parent a075d89 commit 598286f

File tree

1 file changed

+40
-11
lines changed
  • docs/operate/modules/support-hardware

1 file changed

+40
-11
lines changed

docs/operate/modules/support-hardware/_index.md

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ aliases:
3535
- /operate/get-started/other-hardware/hello-world-module/
3636
- /operate/modules/create-module/hello-world-module/
3737
- /operate/modules/supported-hardware/hello-world-module/
38+
date: "2025-10-30"
3839
---
3940

4041
If your physical or virtual hardware is not supported by an existing registry {{< glossary_tooltip term_id="module" text="module" >}}, you can create a new module to add support for it.
@@ -279,7 +280,9 @@ If you want to understand the module structure, here's what each file does:
279280

280281
- **<FILE>README.md</FILE>**: Documentation template that gets uploaded to the registry when you upload the module.
281282
- **<FILE>meta.json</FILE>**: Module metadata that gets uploaded to the registry when you upload the module.
282-
- TODO
283+
- **<FILE>module/main.go</FILE> and <FILE>module.go</FILE>**: Core code that registers the module and resource and provides the model implementation.
284+
- **<FILE>cli/main.go</FILE>**: You can run this file to test the model you are creating (`go run ./cmd/cli`).
285+
- **Makefile**: Build and setup commands.
283286

284287
{{% /tab %}}
285288
{{< /tabs >}}
@@ -371,8 +374,16 @@ Edit the `description` to include both models.
371374
"markdown_link": "README.md#model-exampleorghello-worldhello-sensor"
372375
}
373376
],
377+
"applications": null,
378+
"markdown_link": "README.md",
374379
"entrypoint": "./run.sh",
375-
"first_run": ""
380+
"first_run": "",
381+
"build": {
382+
"build": "./build.sh",
383+
"setup": "./setup.sh",
384+
"path": "dist/archive.tar.gz",
385+
"arch": ["linux/amd64", "linux/arm64", "darwin/arm64", "windows/amd64"]
386+
}
376387
}
377388
```
378389

@@ -457,8 +468,16 @@ Edit the `description` to include both models.
457468
"markdown_link": "README.md#model-exampleorghello-worldhello-sensor"
458469
}
459470
],
460-
"entrypoint": "./run.sh",
461-
"first_run": ""
471+
"applications": null,
472+
"markdown_link": "README.md",
473+
"entrypoint": "bin/hello-world",
474+
"first_run": "",
475+
"build": {
476+
"build": "make module.tar.gz",
477+
"setup": "make setup",
478+
"path": "module.tar.gz",
479+
"arch": ["linux/amd64", "linux/arm64", "darwin/arm64", "windows/amd64"]
480+
}
462481
}
463482
```
464483

@@ -813,19 +832,31 @@ You can find details about the return types at [go.viam.com/rdk/components](http
813832
{{< table >}}
814833
{{< tablestep start=1 >}}
815834

816-
The module generator created a stub for the `Image` function we want to implement in <file>hello-world/hello-camera.go</file>.
835+
The module generator created a stub for the `Images` function we want to implement in <file>hello-world/hello-camera.go</file>.
817836

818837
You need to replace `panic("not implemented")` with code to implement the method:
819838

820-
```go {class="line-numbers linkable-line-numbers" data-start="101" }
821-
func (s *helloWorldHelloCamera) Image(ctx context.Context, mimeType string, extra map[string]interface{}) ([]byte, camera.ImageMetadata, error) {
839+
```go {class="line-numbers linkable-line-numbers" data-start="111" }
840+
func (s *helloWorldHelloCamera) Images(ctx context.Context, filterSourceNames []string, extra map[string]interface{}) ([]camera.NamedImage, resource.ResponseMetadata, error) {
841+
var responseMetadataRetVal resource.ResponseMetadata
842+
822843
imgFile, err := os.Open(imagePath)
823844
if err != nil {
824-
return nil, camera.ImageMetadata{}, errors.New("Error opening image.")
845+
return nil, responseMetadataRetVal, errors.New("Error opening image.")
825846
}
826847
defer imgFile.Close()
848+
827849
imgByte, err := os.ReadFile(imagePath)
828-
return imgByte, camera.ImageMetadata{}, nil
850+
if err != nil {
851+
return nil, responseMetadataRetVal, err
852+
}
853+
854+
named, err := camera.NamedImageFromBytes(imgByte, "default", "image/png")
855+
if err != nil {
856+
return nil, responseMetadataRetVal, err
857+
}
858+
859+
return []camera.NamedImage{named}, responseMetadataRetVal, nil
829860
}
830861
```
831862

@@ -872,8 +903,6 @@ Add the following import to the list of imports at the top of <file>hello-world/
872903
"math/rand"
873904
```
874905

875-
Save the file.
876-
877906
{{% /tablestep %}}
878907
{{< tablestep >}}
879908

0 commit comments

Comments
 (0)