Driver for Arizona USB Pressure Sensor
Project description
ARIZON USB APIServer
An APIServer for ARIZON USB force sensors.
Installation
Clone & cd
into this repository then:
python setup.py install
Or download from PyPI:
python -m pip install arizon-usb-apiserver
Get Started
The apiserver operates in two modes: RESTful and gRPC. They share the same configuration schema.
Basics
To read the sensor locally, use this snippet:
from serial import Serial
from arizon_usb_apiserver import Sensor
if __name__ == '__main__':
conn = Serial("COM16", 115200)
sensor = Sensor(conn)
sensor.reset()
while True:
print(sensor.read_once())
To generate configuration from command line interaction run:
python -m arizon_usb_apiserver configure
RESTful
To launch the apiserver in RESTful mode, set the API_SERVER_RESTFUL
to 1
before run:
export API_SERVER_RESTFUL=1
Or run with variable
API_SERVER_RESTFUL=1 python -m arizon_usb_apiserver apiserver
Powershell:
Set-Item -Path Env:API_SERVER_RESTFUL -Value 1
Init sensor
curl -X 'PUT' \
'http://127.0.0.1:8080/v1/arizon/force?flag=true' \
-H 'accept: application/json'
Read sensor
curl -X 'GET' \
'http://127.0.0.1:8080/v1/arizon/force' \
-H 'accept: application/json'
Shutdown sensor
curl -X 'PUT' \
'http://127.0.0.1:8080/v1/arizon/force?flag=false' \
-H 'accept: application/json'
gRPC
Run this command
python -m arizon_usb_apiserver apiserver
Generate Client
Restful
First launch the apiserver, then run openapi-python-client
:
openapi-python-client generate --url http://127.0.0.1:8080/openapi.json
rm -rf ./arizon_usb_driver/client/restful
mv fast-api-client/fast_api_client ./arizon_usb_driver/client/restful
rm -rf ./fast-api-client
GRPC
First cd arizon_usb_apiserver/grpc
, then run:
python -m grpc_tools.protoc -I../../manifests/protos --python_out=. --pyi_out=. --grpc_python_out=. ../../manifests/protos/force_packet.proto
You might need to replace import force_packet_pb2 as force__packet__pb2
with import arizon_usb_apiserver.grpc.force_packet_pb2 as force__packet__pb2
Serial Protocol
Field | Content |
---|---|
Head | 0xFE |
Status | 1 Byte |
Data | 3 Byte |
XOR checksum | 1 Byte |
- Status: 4 bits of address + 4 bits represents number of digits
- Data: 3 bytes of signed integers, no digit, big-endian.
- Checksum: xor() of first 5 bytes
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for arizon-usb-apiserver-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ad3e805621d606c652595742cbab82dcf9d632f286ddb837d44cff6ede1e4f |
|
MD5 | 61f09ccceee002eca116fdac791a0bf8 |
|
BLAKE2b-256 | 2d92e5d1e3f679b0c71603cbf848be246948e12c5fc2c4ab93170b3769bc7113 |
Hashes for arizon_usb_apiserver-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52d58f002070c2ed836ed38fc9a5d37b5bbd72f7403db575e47f992cbf6e3e7f |
|
MD5 | 868b367e9b2d3edab2cf0678b6af7f7d |
|
BLAKE2b-256 | 078dabd805881a2bbe176b5583c27f332033c52074862c202780a1626c975b1f |