User Tools

Site Tools

한국어

logicpython:cubloc_api:opencom

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
logicpython:cubloc_api:opencom [2026/04/10 07:24] mfranklinlogicpython:cubloc_api:opencom [2026/04/14 04:47] (current) – removed mfranklin
Line 1: Line 1:
-====== OpenCom ====== 
- 
-Enable serial communication on a CUBLOC-style ''channel''. 
- 
-===== Syntax ===== 
- 
-<code python> 
-from cubloc import OpenCom 
- 
-OpenCom(channel: int, baudRate: int, protocol: int, recvSize: int, sendSize: int) 
-</code> 
- 
-===== Parameters ===== 
- 
-  * **channel**: RS-232 ''channel'' number. ''Channel'' 0 maps to UART0 (GP0/GP1) and ''channel'' 1 maps to UART1 (GP4/GP5). 
-  * **baudRate**: Serial baud rate. The documentation allows values between 2400 and 230400. 
-  * **protocol**: Encoded bit field (see table below) -- Serial frame format: data bits, parity, and stop bits. 
-  * **recvSize**: Receive buffer size in bytes. Maximum documented value is 1024. 
-  * **sendSize**: Send buffer size in bytes. Maximum documented value is 1024. 
- 
-''protocol'' bit layout: 
- 
-^ Field ^ Bits ^ Meaning ^ 
-| Data bits | 1..0 | 00=5 bits, 01=6 bits, 10=7 bits, 11=8 bits | 
-| Stop bits | 2 | 0=1 stop bit, 1=2 stop bits | 
-| Parity | 4..3 | 00=None, 10=Even, 11=Odd (01 is reserved and raises ''ValueError'') | 
- 
-Common ''protocol'' values: 
- 
-^ protocol ^ Frame format ^ 
-| 3 | 8N1 | 
-| 11 | 8E1 | 
-| 19 | 8O1 | 
-| 7 | 8N2 | 
- 
-===== Exceptions ===== 
- 
-  * [[https://docs.micropython.org/en/latest/library/builtins.html#TypeError|TypeError]]: One of the arguments is not an integer. 
-  * [[https://docs.micropython.org/en/latest/library/builtins.html#ValueError|ValueError]]: The supplied values are outside the documented range. 
- 
-===== Example ===== 
- 
-<code python> 
-from cubloc import OpenCom 
- 
-# Example usage 
-OpenCom(0, 1, 1, 1, 1) 
-</code> 
- 
-===== Related APIs ===== 
- 
-  * [[logicpython:cubloc_api:setmodbus|SetModbus]] 
  
logicpython/cubloc_api/opencom.1775805868.txt.gz · Last modified: by mfranklin