pwitab / iec62056-21

A Python library for IEC62056-21, Local Data Readout of Energy Meters. Former IEC1107
BSD 3-Clause "New" or "Revised" License
65 stars 18 forks source link

readout of landis + gyr120AP #33

Open pfy opened 1 year ago

pfy commented 1 year ago

I tried to read the landis + gyr ZM120 and had some issues (on osx) With the code in the repository, no readout is possible. The read timouts. But if i remove the code to switch the baud rate, by commenting out self.transport.switch_baudrate(self.switchover_baudrate), everything works as expected.

should i prepare a pr with a flag for the client or transport to disable the baud rate switch ?

attached transcript without the actual data of my readings

INFO:iec62056_21.client:Staring init sequence
INFO:iec62056_21.client:Sending request message: RequestMessage(device_address='')
DEBUG:iec62056_21.transports:Sent b'/?!\r\n' over transport: SerialTransport
DEBUG:iec62056_21.client:Resting for 0.25 seconds
DEBUG:iec62056_21.transports:Received b'/LGZ4\\2ZMD120APt.G03\r\n' over transport: SerialTransport
INFO:iec62056_21.client:Received identification message: IdentificationMessage(identification='2ZMD120APt.G03', manufacturer='LGZ', switchover_baudrate_char='4')
INFO:iec62056_21.client:Sending AckOptionsSelect message: AckOptionSelectMessage(baud_char='4', mode_char='0')
DEBUG:iec62056_21.transports:Sent b'\x06040\r\n' over transport: SerialTransport
DEBUG:iec62056_21.client:Resting for 0.25 seconds
INFO:iec62056_21.client:Reading standard readout from device.
Krolken commented 1 year ago

OK. So the meter does not follow the baud rate it proposes?

A better solution would be to create a subclass of the serial transport where you make the switch_baudrate a no-op.

I rather not add more flags and options as it has been a wish for a long time to rewrite this library and bring it up to standard with our other communication libraries.