pywws.device_ctypes_hidapi

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

Introduction

This module handles low level communication with the weather station via ctypes and the hidapi library. It is one of several USB device modules, each of which uses a different USB library interface. See Installation - USB library for details.

Testing

Run pywws.TestWeatherStation with increased verbosity so it reports which USB device access module is being used:

python -m pywws.TestWeatherStation -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

Classes

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

Low level USB device access via hidapi library.

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

Receive data from the device.

If the read fails for any reason, an IOError exception is raised.

Parameters:size (int) – the number of bytes to read.
Returns:the data received.
Return type:list(int)
write_data(buf)[broncode]

Send data to the device.

Parameters:buf (list(int)) – the data to send.
Returns:success status.
Return type:bool

Comments or questions? Please subscribe to the pywws mailing list http://groups.google.com/group/pywws and let us know.