1
0
mirror of https://github.com/pommi/python-itho-wpu.git synced 2024-11-21 13:52:15 +01:00
Commit Graph

20 Commits

Author SHA1 Message Date
ecc8bd123b Merge pull request #3 from WouterJN/patch-1
Update itho-wpu.py
2020-12-29 21:27:59 +01:00
WouterJN
ce846efb62 Update itho-wpu.py
Resolving issue with datatype 0xc (1 byte integer)
2020-12-27 22:57:22 +01:00
2a25e8148b feat(itho-wpu): use (hardcoded) datatype from getdatatype in datalog
Action "getdatatype" returns a list of bytes representing the datatype
for each field in action "getdatalog". This is a subset of these
datatypes:

* 0x0: integer (1 byte)
* 0xc: integer (1 byte)
* 0x10: unsigned integer (2 bytes)
* 0x92: 2 decimal signed float (2 bytes)
2020-12-03 14:48:50 +01:00
d40b0d94ff feat(itho-wpu): add manufacturer naming 2020-11-21 15:08:10 +01:00
273a22a4c0 refactor(itho-wpu): check messageclass in a central function 2020-11-16 14:04:54 +01:00
1a57a8bd9b feat(itho-wpu): implement getserial action 2020-11-15 15:26:25 +01:00
b0ea3a9473 refactor(itho-wpu): compose request + calculate checksum on the fly
Messages have 6 header bytes, data bytes and 1 checksum byte.

The 6 header bytes are:
1: i2c destination address (0x82)
2: i2c reply address (0x80)
3,4: message class
5: message type (0x04 = request)
6: data length (0x00 in case of a request)
2020-11-15 15:26:18 +01:00
58f35d988e feat(itho-wpu): implement getnodeid action 2020-11-15 15:18:12 +01:00
11ae0978b3 refactor(itho-wpu): check MessageType + move MessageClass check
MessageType 4th byte (5th if you include 0x80) is:
- 0x01: response
- 0x04: request
2020-11-14 15:31:37 +01:00
152b6021cf feat(itho-wpu): check message length
The 5th byte (6th if you include 0x80) contains the message length. To
double check if the message is correct we can check this against the
actual message length.
2020-11-14 15:10:59 +01:00
c43de957e9 feat(itho-wpu): export to influxdb support
Export getdatalog measurements to InfluxDB by giving the
'--export-to-influxdb' argument. Additionally configure the InfluxDB
credentials via environment variables:
- INFLUXDB_HOST (default: localhost)
- INFLUXDB_PORT (default: 8086)
- INFLUXDB_USERNAME (default: root)
- INFLUXDB_PASSWORD (default: root)
- INFLUXDB_DATABASE
2020-11-08 15:08:46 +01:00
c867203913 feat(itho-wpu): process getdatalog 2020-11-08 15:08:46 +01:00
d00e948208 feat(itho-wpu): rm slave thread + pass result to I2CMaster via a queue + add retry mechanism
Remove the slave thread, set_callback already spawns a thread.

I2CSlave.callback() now puts the result (if valid) in a queue. This item
can be picked up by I2CMaster for further processing.

I2CMaster will wait 0.21s for a result in the queue. 0.21s, because I
always see a response in < 0.2s. If there is no result, it will send the
request again (max 20 retries). This is because I don't get reliable
responses (via pigpiod?). In an earlier commit I mentioned to configure
pigpiod with -s 2 (sample rate 2 microseconds).  This doesn't seem to be
true. For example -s 10 gives the same reliability (and less CPU usage
by pigpiod).
2020-11-08 15:08:46 +01:00
e3bc670050 refactor(itho-wpu): rm wait type
The wait type is unreliable. No reason to keep maintaining this.
2020-11-05 13:42:21 +01:00
c7b5171a66 feat(itho-wpu): add checksum validation for received messages 2020-11-05 13:41:47 +01:00
f989b61789 feat(itho-wpu): cli arguments to run master/slave only + set slave timeout
--master-only allows to only run the I2C master functionality.
--slave-only allows to only run the I2C slave functionality.

The I2C slave functionality via the "set_callback" mechanism (--type
callback) just executes the pigpio "event_callback()" function and waits
for 2 seconds for a response. The amount of seconds can now be
configured via --slave-timeout.
2020-10-25 13:54:43 +01:00
ff3c705608 feat(itho-wpu): option to slave via event_callback()
Argument "--type [callback,wait]" is added to be able to switch between
"wait_for_event()" (previous functionality) and "event_callback()" in
the I2C slave functionality.

In a thread set_callback() executes event_callback() and just (very
dirty) sleeps 2 seconds to get a response or else cancels the event and
stops pigpio.

To get the most reliable output pigpiod is started with -s 2 (sample
rate 2 microseconds). Still most of the time too few bytes are received
on the "getdatalog" action (153 bytes expected).
2020-10-22 14:39:04 +02:00
15c6103820 feat(itho-wpu): basic slave functionality
This uses the pigpio library as I'm not quite sure yet how to read this
data directly from /dev/i2c-1, without polling and high CPU usage.
2020-10-22 14:38:43 +02:00
91913c4fe7 feat(itho-wpu): initial i2c master functionality
Writing directly to the /dev/i2c-1 device.

Support for 4 actions:
- getregelaar
- getserial
- getdatatype
- getdatalog
2020-10-17 18:05:56 +02:00
4e6d4c8666 docs(readme): initial commit 2020-10-16 19:17:51 +02:00