Skip to main content

Driver for Arizona USB Pressure Sensor

Project description

HIPNUC USB APIServer

Upload Python Package Pypi

Installation

Clone & cd into this repository then:

python setup.py install

Or download from PyPI:

python -m pip install hipnuc-usb-apiserver

Get Started

To generate configuration from command line interaction run:

python -m hipnuc_usb_apiserver configure

To launch the apiserver, run:

python -m hipnuc_usb_apiserver apiserver

To use the gRPC api on localhost:8080, use this snippet:

import grpc
import hipnuc_usb_apiserver.grpc.imu_packet_pb2 as imu_packet_pb2
import hipnuc_usb_apiserver.grpc.imu_packet_pb2_grpc as imu_packet_pb2_grpc
import time
import tqdm

def run():
    channel = grpc.insecure_channel('localhost:8080')
    stub = imu_packet_pb2_grpc.IMUPacketServiceStub(channel)
    
    response = stub.SetStatus(imu_packet_pb2.IMUSetStatusRequest(
        status=True))
    print("SetStatus client received: " + str(response))
    
    response = stub.GetPacket(imu_packet_pb2.IMUPacketRequest(
        timestamp=time.time_ns()))
    print("GetPacket client received: " + str(response))

    response = stub.GetPacketArray(
        imu_packet_pb2.IMUPacketArrayRequest(timestamp=time.time_ns()))
    print("GetPacketArray client received: " + str(response))

    response = stub.GetPacketStream(
        imu_packet_pb2.IMUPacketRequest(timestamp=time.time_ns()))
    print("GetPacketStream client received: " + str(response))

    try:
        with tqdm.tqdm() as pbar:
            while True:
                # time.sleep(0.0005)
                data = next(response)
                pbar.set_description(str(data.yaw) + ' - ' + str(data.index))
                pbar.update(1)
                # print)
    except KeyboardInterrupt as e:
        response.cancel()
    
    response = stub.SetStatus(imu_packet_pb2.IMUSetStatusRequest(
    status=False))
    print("SetStatus client received: " + str(response))


if __name__ == '__main__':
    run()

for custom port configuration, change the localhost:8080

Developping

For developping purpose, read this section.

Build gRPC

To update gRPC defs, run:

cd hipnuc_usb_apiserver/grpc
python -m grpc_tools.protoc -I../../manifests/protos --python_out=. --pyi_out=. --grpc_python_out=. ../../manifests/protos/imu_packet.proto

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

hipnuc-usb-apiserver-0.3.0.tar.gz (16.3 kB view hashes)

Uploaded Source

Built Distribution

hipnuc_usb_apiserver-0.3.0-py3-none-any.whl (19.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page