|
CASP Python Libraries
This documentation primarily focuses on the usage of functions from 'casp', 'casp_be', 'casp_gpio' and 'casp_udio' namespaces.
|
This module defines functions to communicate with target hardware (i.e micro-controller board, SBC etc.) that is programmed with CASP GPIO protocol. More...
Functions | |
| Init () | |
| Initializes CASP GPIO subprocess. | |
| Close () | |
| Terminates CASP GPIO subprocess and releases the resources. | |
| bool | ConnectSerial (str serial_port="COM3", bool enable_dtr=True, int send_recv_delay=1, int baud=115200) |
| Initializes CASP GPIO connection process with the target over serial port. | |
| bool | ConnectEth (str ip, int port=42001, bool tcp=False, int send_recv_delay=1) |
| Initializes CASP GPIO connection process with the target over ethernet. | |
| SerialPorts () | |
| Displays available serial ports on the host. | |
| FolderUserData () | |
| Opens 'CASP User Data' directory from user's Documents folder. | |
| FolderTutorials () | |
| Opens CASP tutorials directory. | |
| FolderExamples () | |
| Opens CASP examples directory. | |
| HelpPython () | |
| Opens CASP Python Libraries documentation. | |
| int | Read (str pin_name) |
| Reads target GPIO raw pin value and returns the value as an integer. | |
| bool | Write (str pin_name, int value) |
| Writes value to the target's GPIO pin and returns whether the write operation is successful or not. | |
This module defines functions to communicate with target hardware (i.e micro-controller board, SBC etc.) that is programmed with CASP GPIO protocol.
Both serial and ethernet communication interfaces are supported. All functions in this module uses global object _casp_process.casp_gpio_proc from _casp_process.py module.
| casp_gpio.Init | ( | ) |
Initializes CASP GPIO subprocess.
This is the first function to be called before using any other function in this module.
Definition at line 8 of file casp_gpio.py.
| casp_gpio.Close | ( | ) |
Terminates CASP GPIO subprocess and releases the resources.
Definition at line 13 of file casp_gpio.py.
| bool casp_gpio.ConnectSerial | ( | str | serial_port = "COM3", |
| bool | enable_dtr = True, | ||
| int | send_recv_delay = 1, | ||
| int | baud = 115200 ) |
Initializes CASP GPIO connection process with the target over serial port.
Performs initial protocol hand shake and keep things ready for data read/write operations.
User can use SerialPorts() to know available serial ports on the device.
Arguments:
serial_port: Set serial port to which device is connected. enable_dtr: Set to True when serial data terminal ready (DTR) control signal is to be used. Default value is True. Set to False if device is not detectable (generally on old hardware). send_recv_delay: Set send receive time delay in milli seconds. Generally set between 1 to 5 msec. Smaller values reduces latency at the cost of increased CPU utilization and vice versa. Default value is 1 msec. baud: Set baud rate in bits per second. Default value is 115200 bps.
Return Value:
Returns True if connection is successful. Else returns False.
Definition at line 18 of file casp_gpio.py.
| bool casp_gpio.ConnectEth | ( | str | ip, |
| int | port = 42001, | ||
| bool | tcp = False, | ||
| int | send_recv_delay = 1 ) |
Initializes CASP GPIO connection process with the target over ethernet.
Performs initial protocol hand shake and keep things ready for data read/write operations.
Arguments:
ip: Set IP address of the target device. Both IP4 and IP6 are supported. port: Set port number of the target device. Mostly, better leave it to default. tcp: Set to True when TCP protocol is to be used else UDP protocol will be used during communication. send_recv_delay: Set send receive time delay in milli seconds. Generally set between 1 to 5 msec. Smaller values reduces latency at the cost of increased CPU utilization and vice versa. Default value is 1 msec.
Return Value:
Returns True if connection is successful. Else returns False.
Definition at line 48 of file casp_gpio.py.
| casp_gpio.SerialPorts | ( | ) |
Displays available serial ports on the host.
User can use this function before using the ConnectSerial() function.
Definition at line 76 of file casp_gpio.py.
| casp_gpio.FolderUserData | ( | ) |
Opens 'CASP User Data' directory from user's Documents folder.
Definition at line 84 of file casp_gpio.py.
| casp_gpio.FolderTutorials | ( | ) |
Opens CASP tutorials directory.
Definition at line 90 of file casp_gpio.py.
| casp_gpio.FolderExamples | ( | ) |
Opens CASP examples directory.
Definition at line 96 of file casp_gpio.py.
| casp_gpio.HelpPython | ( | ) |
Opens CASP Python Libraries documentation.
Definition at line 102 of file casp_gpio.py.
| int casp_gpio.Read | ( | str | pin_name | ) |
Reads target GPIO raw pin value and returns the value as an integer.
Arguments:
pin_name: Pin number/name from the selected module in 'casp_gpio_pins' folder from which the value is to be read.
Return Value:
Returns the pin value received from the target as an integer.
Definition at line 107 of file casp_gpio.py.
| bool casp_gpio.Write | ( | str | pin_name, |
| int | value ) |
Writes value to the target's GPIO pin and returns whether the write operation is successful or not.
Arguments:
pin_name: Pin number/name from the selected module in 'casp_gpio_pins' folder to which the value is written. value: Value to write.
Return Value:
Returns whether the write operation is successful or not.
Definition at line 128 of file casp_gpio.py.