This version is relevant for Dobotlink 5.0.0 and python3.5+
DobotRPC is a dobotlink communication module based on websocket and JSON-RPC . It provides python ports to communicate with dobotlink and allows developers to communicate with the GUI.
APIS
-
RPCClient: RPCClient is a class that allows users to instantiate their own client, which uses WebSocket protocol to connect to a target IP and port, and then uses JSON format for data communication.
- set_ip: Version 4.7.4 or above is acceptable. The IP and port used to set the destination address.
-
RPCServer: RPCServer is a class that allows users to instantiate their own server, which waits for a client to connect using the WebSocket protocol, and then uses JSON format for data communication. The default port number is 9091.
-
loggers: Provide an instantiated loggers interface. The user can call the following interfaces to do the configuration.
- set_filename: Set log file name.
- set_level: Set the log output level.
- set_use_console: Set log output to the console.
- set_use_file: Set log output to a file.
-
DobotlinkAdapter: Provides an adapter for DobotLink RPC communication.
-
NormalAdapter: Provides an adapter for normal RPC communication
Examples
- Users can communicate synchronously or asynchronously.The asynchronous mode is as follows:
# Async demo
from DobotRPC import DobotlinkAdapter, RPCClient, loggers
# The asyncio module provides infrastructure for writing single-threaded concurrent code using coroutines, multiplexing I/O access over sockets and other resources, running network clients and servers, and other related primitives.
import asyncio
# Coroutines function
async def main(dobotlink_async):
# Display information with Dobotlink
await dobotlink_async.api.ShowMessage(title="Async Demo Message",
message="Async Demo is running.")
# Search for available ports
res = await dobotlink_async.Magician.SearchDobot()
# Get ports
if len(res) < 1:
return
port_name = res[0]["portName"]
# Connect
await dobotlink_async.Magician.ConnectDobot(portName=port_name)
# PTP
await dobotlink_async.Magician.SetPTPCmd(portName=port_name,
ptpMode=0,
x=230,
y=50,
z=0,
r=20)
# Disconnect
await dobotlink_async.Magician.DisconnectDobot(portName=port_name,
queueStop=True,
queueClear=True)
if __name__ == "__main__":
loggers.set_level(loggers.DEBUG)
# Get the Eventloop reference
loop = asyncio.get_event_loop()
# Initializes, connects to dobotlink, and is executed before the Loop runs
dobotlink_async = DobotlinkAdapter(RPCClient(loop=loop), is_sync=False)
# Perform coroutines
loop.run_until_complete(main(dobotlink_async))
- The synchronization mode is as follows:
# Sync Demo
from DobotRPC import RPCClient, DobotlinkAdapter, loggers
def main(dobotlink_sync):
# Display information with Dobotlink
dobotlink_sync.api.ShowMessage(title="Sync Demo Message",
message="Sync Demo is running.")
# Search for available ports
res = dobotlink_sync.Magician.SearchDobot()
# Get ports
if len(res) < 1:
return
port_name = res[0]["portName"]
# Connect
dobotlink_sync.Magician.ConnectDobot(portName=port_name)
# PTP
dobotlink_sync.Magician.SetPTPCmd(portName=port_name,
ptpMode=0,
x=230,
y=50,
z=0,
r=20)
# Disconnect
dobotlink_sync.Magician.DisconnectDobot(portName=port_name)
if __name__ == "__main__":
loggers.set_level(loggers.DEBUG)
# Initialize, connect to dobotlink
dobotlink_sync = DobotlinkAdapter(RPCClient(), is_sync=True)
main(dobotlink_sync)
Installtion
To install DobotRPC, type:
pip install DobotRPC
DobotRPC is a free software distributed under the Apache license
Usage
- Users can use the API: loggers, RPCClient, DobotlinkAdapter, NetworkError, client, aip
- Install Dobotlink 32bit 64bit
- Right-click the Dobotlink icon and click
help, pop up aDobotlink help documentation. - You can guide by
examples, reference theDobotlink help documentation. - Then go ahead and develop your first python script.
Metadata
Release files for DobotRPC 4.8.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| DobotRPC-4.8.8.tar.gz | 11.1 kB | Without provenance | Details for DobotRPC-4.8.8.tar.gz |
Release files / DobotRPC-4.8.8.tar.gz
| Download URL | DobotRPC-4.8.8.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3e9a6c341bb7fa75749d1c4905d42d25047ed481786e49e22529f3117dc065c
|
|
BLAKE2b-256 checksum How to use checksums |
b56c5f865cf8eb4fe555f9c59e8f593dc136570036d70fee3f89fc122615cd98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.0
|
Security for DobotRPC 4.8.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.