@@ -33,6 +33,9 @@ openmv --port /dev/ttyACM0 --quiet
3333
3434# Debug mode (verbose logging)
3535openmv --port /dev/ttyACM0 --debug
36+
37+ # Preview a custom data channel
38+ openmv --port /dev/ttyACM0 --channel ticks
3639```
3740
3841### Options
@@ -47,6 +50,7 @@ openmv --port /dev/ttyACM0 --debug
4750| ` --timeout SEC ` | 1.0 | Protocol timeout in seconds |
4851| ` --baudrate N ` | 921600 | Serial baudrate |
4952| ` --firmware FILE ` | None | Firmware ELF file for profiler symbol resolution |
53+ | ` --channel NAME ` | None | Custom data channel to poll and print |
5054| ` --quiet ` | False | Suppress script output text |
5155| ` --debug ` | False | Enable debug logging |
5256
@@ -108,6 +112,46 @@ with Camera('/dev/ttyACM0') as camera:
108112 print (text, end = ' ' )
109113```
110114
115+ ### Custom Channels
116+
117+ Custom channels allow bidirectional data exchange between the camera and host.
118+
119+ ** Camera-side script (MicroPython):**
120+
121+ ``` python
122+ import time
123+ import protocol
124+
125+ class TicksChannel :
126+ def size (self ):
127+ return 10
128+
129+ def read (self , offset , size ):
130+ return f ' { time.ticks_ms():010d } '
131+
132+ def poll (self ):
133+ return True
134+
135+ protocol.register(name = ' ticks' , backend = TicksChannel())
136+ ```
137+
138+ ** Host-side (Python):**
139+
140+ ``` python
141+ from openmv import Camera
142+
143+ with Camera(' /dev/ttyACM0' ) as camera:
144+ camera.exec(script)
145+
146+ while True :
147+ # Check if channel has data
148+ if camera.has_channel(' ticks' ):
149+ size = camera.channel_size(' ticks' )
150+ if size > 0 :
151+ data = camera.channel_read(' ticks' , size)
152+ print (f " Ticks: { data.decode()} " )
153+ ```
154+
111155## API Reference
112156
113157Full API documentation: [ docs/api.md] ( https://github.com/openmv/openmv-python/blob/master/docs/api.md )
0 commit comments