pipecat.device.charger module

Data sources that retrieve information from battery chargers.

pipecat.device.charger.icharger208b(source)

Parse data from an iCharger 208B battery charger.

Parses data events emitted by the charger during charge, discharge, etc. Likely works with other models from iCharger, but this is untested. Consider Contributing to let us know.

This model battery charger comes with a USB cable that provides serial-over-USB communication with the host computer. To connect with the charger, you’ll need to open a handle to the appropriate serial port, the name of which will vary between platforms and based on the number of devices currently connected, and feed lines of text to the parser.

Examples

Open a serial port on a Mac OSX computer using pySerial, read lines from the serial port, parse them into records, and print them to stdout:

>>> pipe = serial.serial_for_url("/dev/cu.SLAB_USBtoUART", baudrate=128000)
>>> pipe = pipecat.utility.readline(pipe)
>>> pipe = pipecat.device.charger.icharger208b(pipe)
>>> for record in pipe:
...   print record
Parameters:source (Record generator returning records containing a “string” field.)
Yields:records (dict) – Records will contain information including the charge mode, supply voltage, battery voltage, battery current, internal and external charger temperature, and the total charged added-to / removed-from the battery.