From 8b9f840232f47db197028b2c18856e0188167b0a Mon Sep 17 00:00:00 2001 From: uhi22 Date: Fri, 16 Dec 2022 13:03:36 +0100 Subject: [PATCH] feature: add relay control to hardwareInterface --- doc/installation_on_windows.md | 8 ++++++++ doc/todo.md | 2 +- hardwareInterface.py | 24 +++++++++++++++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 doc/installation_on_windows.md diff --git a/doc/installation_on_windows.md b/doc/installation_on_windows.md new file mode 100644 index 0000000..55a6bb9 --- /dev/null +++ b/doc/installation_on_windows.md @@ -0,0 +1,8 @@ +# Installation on Windows10 + +## Driver for the USB-to-Serial brigde + +For the USB-to-Serial bridge, which is sold as CP2102, the Windows 10 tries to install the driver when plugged-in. But +the device did not work together with the driver which windows found automatically. A root cause may be, that the +device is not an original CP2102, but a clone. Finally found a driver on https://www.pololu.com/docs/0J7/all, which works. + diff --git a/doc/todo.md b/doc/todo.md index 512285d..268f848 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -1,6 +1,6 @@ # Todos -- [ ] Decode CableCheckRes."DC_EVSEStatus.EVSEStatusCode": dinDC_EVSEStatusCodeType as readable text +- [x] Decode CableCheckRes."DC_EVSEStatus.EVSEStatusCode": dinDC_EVSEStatusCodeType as readable text - [ ] Decode CableCheckRes."DC_EVSEStatus.EVSEIsolationStatus": dinisolationLevelType as readable text - [ ] Encoder: PreChargeReq: is it possible to enable the units for EVTargetVoltage and EVTargetCurrent? - [ ] Find out, why Alpi reports CableCheckRes = Finished FAILED in v0.4 diff --git a/hardwareInterface.py b/hardwareInterface.py index 28153f5..91215c5 100644 --- a/hardwareInterface.py +++ b/hardwareInterface.py @@ -49,6 +49,14 @@ class hardwareInterface(): def setPowerRelayOff(self): self.addToTrace("Switching PowerRelay OFF.") self.outvalue &= ~2 + + def setRelay2On(self): + self.addToTrace("Switching PowerRelay ON.") + self.outvalue |= 4 + + def setRelay2Off(self): + self.addToTrace("Switching PowerRelay OFF.") + self.outvalue &= ~4 def getInletVoltage(self): #todo: get real measured voltage from the inlet @@ -122,16 +130,22 @@ def myPrintfunction(s): if __name__ == "__main__": print("Testing hardwareInterface...") hw = hardwareInterface(myPrintfunction) - for i in range(0, 300): + for i in range(0, 350): hw.mainfunction() - if (i==100): + if (i==50): hw.setStateC() + if (i==100): + hw.setStateB() + if (i==150): + hw.setStateC() + hw.setPowerRelayOn() if (i==200): hw.setStateB() + hw.setPowerRelayOff() if (i==250): - hw.setStateC() - if (i==280): - hw.setStateB() + hw.setRelay2On() + if (i==300): + hw.setRelay2Off() sleep(0.03) hw.close() print("finished.") \ No newline at end of file