pywws.device_ctypes_hidapi

Low level USB interface to weather station, using ctypes to access hidapi.

Introduzione

This module handles low level communication with the weather station via ctypes and the hidapi library. Alternative modules, pywws.device_cython_hidapi and pywws.device_pyusb, use other libraries. The choice of which module to use depends on which libraries are available for you computer.

Gli utenti delle recenti versioni di Mac OS non hanno altra scelta. Il sistema operativo rende molto difficile accedere direttamente, ai dispositivi HID (come la stazione meteorologica) così la libreria hidapi deve essere usata.

Users of OpenWRT and similar embedded Linux platforms will probably not be able to install ctypes or cython-hidapi, so are constrained to use libusb and its PyUSB Python interface.

Installazione

Alcuni di questi software potrebbero essere già installati sulla vostra macchina, quindi controllare prima di scaricare i sorgenti e compilarli da te.

  1. Install hidapi.

    Create a local copy of the git repository, change to the new directory and then follow the instructions in README.txt:

    git clone https://github.com/signal11/hidapi.git
    cd hidapi
    more README.txt
  2. Install ctypes.

    This should be available as a package for your operating system. For example:

    sudo zypper install python-ctypes

Collaudo

Eseguire TestWeatherStation.py con un livello di dettaglio maggiore così segnala quale modulo USB di accesso al dispositivo viene usato:

python TestWeatherStation.py -vv
18:10:27:pywws.WeatherStation.CUSBDrive:using pywws.device_ctypes_hidapi
0000 55 aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff 05 20 01 51 11 00 00 00 81 00 00 07 01 00 d0 56
0020 61 1c 61 1c 00 00 00 00 00 00 00 12 02 14 18 09 41 23 c8 00 32 80 47 2d 2c 01 2c 81 5e 01 1e 80
0040 a0 00 c8 80 a0 28 80 25 a0 28 80 25 03 36 00 05 6b 00 00 0a 00 f4 01 18 00 00 00 00 00 00 00 00
0060 00 00 54 1c 63 0a 2f 01 71 00 7a 01 59 80 7a 01 59 80 e4 00 f5 ff 69 54 00 00 fe ff 00 00 b3 01
0080 0c 02 d0 ff d3 ff 5a 24 d2 24 dc 17 00 11 09 06 15 40 10 03 07 22 18 10 08 11 08 30 11 03 07 12
00a0 36 08 07 24 17 17 11 02 28 10 10 09 06 30 14 29 12 02 11 06 57 09 06 30 14 29 12 02 11 06 57 08
00c0 08 31 14 30 12 02 14 18 04 12 02 01 10 12 11 09 13 17 19 11 08 21 16 53 11 09 13 17 19 12 01 18
00e0 07 17 10 02 22 11 06 11 11 06 13 12 11 11 06 13 12 11 11 10 11 38 11 11 10 11 38 10 02 22 14 43

API

Funzioni

find_library(name)

Classi

USBDevice(vendor_id, product_id) Low level USB device access via hidapi library.
class pywws.device_ctypes_hidapi.USBDevice(vendor_id, product_id)[source]

Low level USB device access via hidapi library.

Parametri:
  • idVendor (int) – the USB “vendor ID” number, for example 0x1941.
  • idProduct (int) – the USB “product ID” number, for example 0x8021.
read_data(size)[source]

Riceve i dati dalla stazione meteo.

Se la lettura non riesce per qualche motivo, IOError l’eccezione è restituita.

Parametri:size (int) – the number of bytes to read.
Ritorna:the data received.
Tipo di ritorno:
 list(int)
write_data(buf)[source]

Inviare dati al dispositivo.

Parametri:buf (list(int)) – the data to send.
Ritorna:success status.
Tipo di ritorno:
 bool

Tabella dei contenuti

Argomento precedente

pywws.WeatherStation

Argomento successivo

pywws.device_cython_hidapi