Giter Club home page Giter Club logo

pyslac's People

Contributors

mdwcrft avatar santiagosalamandri avatar tropxy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyslac's Issues

SLAC_SETTLE_TIME

Can someone explain where the SLAC_SETTLE_TIME value is coming from and why it is required?

MyPy type errors

Running MyPy through poetry gives the following output:

poetry run mypy --config-file pyproject.toml pyslac tests
pyslac/messages.py:159: error: Module "ctypes" is not valid as a type
pyslac/messages.py:175: error: Value of type ctypes? is not indexable
pyslac/messages.py:176: error: Value of type ctypes? is not indexable
pyslac/messages.py:177: error: Value of type ctypes? is not indexable
pyslac/messages.py:178: error: Value of type ctypes? is not indexable
pyslac/messages.py:179: error: Value of type ctypes? is not indexable
pyslac/messages.py:180: error: Value of type ctypes? is not indexable
pyslac/messages.py:181: error: Value of type ctypes? is not indexable
pyslac/messages.py:237: error: Module "ctypes" is not valid as a type
pyslac/messages.py:239: error: Value of type ctypes? is not indexable
pyslac/messages.py:240: error: Value of type ctypes? is not indexable
pyslac/messages.py:241: error: Value of type ctypes? is not indexable
pyslac/messages.py:338: error: Module "ctypes" is not valid as a type
pyslac/messages.py:341: error: Value of type ctypes? is not indexable
pyslac/messages.py:342: error: Value of type ctypes? is not indexable
pyslac/messages.py:343: error: Value of type ctypes? is not indexable
pyslac/messages.py:344: error: Value of type ctypes? is not indexable
pyslac/messages.py:345: error: Value of type ctypes? is not indexable
pyslac/messages.py:346: error: Value of type ctypes? is not indexable
pyslac/messages.py:347: error: Value of type ctypes? is not indexable
pyslac/messages.py:348: error: Value of type ctypes? is not indexable
pyslac/messages.py:423: error: Module "ctypes" is not valid as a type
pyslac/messages.py:425: error: Value of type ctypes? is not indexable
pyslac/messages.py:426: error: Value of type ctypes? is not indexable
pyslac/messages.py:427: error: Value of type ctypes? is not indexable
pyslac/messages.py:428: error: Value of type ctypes? is not indexable
pyslac/messages.py:429: error: Value of type ctypes? is not indexable
pyslac/messages.py:430: error: Value of type ctypes? is not indexable
pyslac/messages.py:431: error: Value of type ctypes? is not indexable
pyslac/messages.py:508: error: Module "ctypes" is not valid as a type
pyslac/messages.py:510: error: Value of type ctypes? is not indexable
pyslac/messages.py:511: error: Value of type ctypes? is not indexable
pyslac/messages.py:512: error: Value of type ctypes? is not indexable
pyslac/messages.py:513: error: Value of type ctypes? is not indexable
pyslac/messages.py:514: error: Value of type ctypes? is not indexable
pyslac/messages.py:515: error: Value of type ctypes? is not indexable
pyslac/messages.py:516: error: Value of type ctypes? is not indexable
pyslac/messages.py:578: error: Module "ctypes" is not valid as a type
pyslac/messages.py:579: error: Value of type ctypes? is not indexable
pyslac/messages.py:581: error: Value of type ctypes? is not indexable
pyslac/messages.py:583: error: Value of type ctypes? is not indexable
pyslac/messages.py:584: error: Value of type ctypes? is not indexable
pyslac/messages.py:671: error: Module "ctypes" is not valid as a type
pyslac/messages.py:672: error: Value of type ctypes? is not indexable
pyslac/messages.py:674: error: Value of type ctypes? is not indexable
pyslac/messages.py:675: error: Value of type ctypes? is not indexable
pyslac/messages.py:676: error: Value of type ctypes? is not indexable
pyslac/messages.py:677: error: Value of type ctypes? is not indexable
pyslac/messages.py:678: error: Value of type ctypes? is not indexable
pyslac/messages.py:679: error: Value of type ctypes? is not indexable
pyslac/messages.py:680: error: Value of type ctypes? is not indexable
pyslac/messages.py:682: error: Value of type ctypes? is not indexable
pyslac/messages.py:760: error: Module "ctypes" is not valid as a type
pyslac/messages.py:762: error: Value of type ctypes? is not indexable
pyslac/messages.py:763: error: Value of type ctypes? is not indexable
pyslac/messages.py:764: error: Value of type ctypes? is not indexable
pyslac/messages.py:765: error: Value of type ctypes? is not indexable
pyslac/messages.py:766: error: Value of type ctypes? is not indexable
pyslac/messages.py:767: error: Value of type ctypes? is not indexable
pyslac/messages.py:768: error: Value of type ctypes? is not indexable
pyslac/messages.py:846: error: Module "ctypes" is not valid as a type
pyslac/messages.py:848: error: Value of type ctypes? is not indexable
pyslac/messages.py:849: error: Value of type ctypes? is not indexable
pyslac/messages.py:850: error: Value of type ctypes? is not indexable
pyslac/messages.py:851: error: Value of type ctypes? is not indexable
pyslac/messages.py:852: error: Value of type ctypes? is not indexable
pyslac/messages.py:853: error: Value of type ctypes? is not indexable
pyslac/messages.py:854: error: Value of type ctypes? is not indexable
pyslac/messages.py:855: error: Value of type ctypes? is not indexable
pyslac/messages.py:856: error: Value of type ctypes? is not indexable
pyslac/messages.py:951: error: Module "ctypes" is not valid as a type
pyslac/messages.py:953: error: Value of type ctypes? is not indexable
pyslac/messages.py:954: error: Value of type ctypes? is not indexable
pyslac/messages.py:955: error: Value of type ctypes? is not indexable
pyslac/messages.py:956: error: Value of type ctypes? is not indexable
pyslac/messages.py:957: error: Value of type ctypes? is not indexable
pyslac/messages.py:958: error: Value of type ctypes? is not indexable
pyslac/messages.py:959: error: Value of type ctypes? is not indexable
pyslac/messages.py:960: error: Value of type ctypes? is not indexable
pyslac/messages.py:961: error: Value of type ctypes? is not indexable
pyslac/messages.py:962: error: Value of type ctypes? is not indexable
pyslac/messages.py:963: error: Value of type ctypes? is not indexable
pyslac/messages.py:964: error: Value of type ctypes? is not indexable
pyslac/utils.py:204: error: Incompatible types in assignment (expression has type "Task[Any]", variable has type "Coroutine[Any, Any, Any]")
pyslac/utils.py:209: error: Incompatible types in assignment (expression has type "Task[Any]", variable has type "Coroutine[Any, Any, Any]")
pyslac/utils.py:212: error: Incompatible types in assignment (expression has type "Task[Any]", variable has type "Coroutine[Any, Any, Any]")
pyslac/utils.py:214: error: "Coroutine[Any, Any, Any]" has no attribute "result"
pyslac/sockets/async_linux_socket.py:6: error: Module "socket" has no attribute "AF_PACKET"
pyslac/session.py:164: error: Bracketed expression "[...]" is not valid as a type
pyslac/session.py:164: note: Did you mean "List[...]"?
pyslac/session.py:182: error: Incompatible types in assignment (expression has type "float", variable has type "int")
pyslac/session.py:475: error: Missing return statement
pyslac/session.py:496: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior
pyslac/session.py:677: error: Assignment to variable "e" outside except: block
pyslac/session.py:686: error: Assignment to variable "e" outside except: block
pyslac/session.py:729: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior
pyslac/session.py:815: error: Value of type "Coroutine[Any, Any, Any]" is not indexable
Found 96 errors in 4 files (checked 18 source files)

This isn't currently run within the GitHub actions. The issues should be fixed and then MyPy added to the PR GHA flow.

Pause Communication

The EV can request a Pause of the communication by sending and PowerDeliveryReq to Stop charging and a StopSession Req with ChargingSession = "Pause".

According to this requirement:

7.6.1 Entering the sleep mode
[V2G3-M07-20] - With receiving D-LINK_Pause.request, the EVSE shall switch to state X1 and may switch the low-layer communication module into low-power mode. The logical network parameter set shall be stored for continuing the data link after the sleeping phase.

[V2G3-M07-22] -  If the EVSE or EV is in “Matched state” and has been woken up from the counter-part station, the low-layer communication module shall be configured to the last known logical network parameter set

iso15118 shall send a message to the application that controls the CP requesting the PWM to be turned off (state X1)
The last NMK and NID shall be saved, so that once the EV/EVSE wakes up the network parameter set can be set directly into the PLC chip without the need of performing the matching process again.

iso15118 shall send a message to the application that controls the CP requesting the PWM to be turned off (state X1)

This also means that the iso15118 needs to have a new method in its interface to do this request (e.g. pause_dlink_session)

`make build` hangs, possible because of old version of Poetry

The README.md instructs users to run make build. In turn, docker-compse build which builds the Dockerfile.

Building the Dockerfile never finishes. The flow hangs at Dockerfile:27.

RUN poetry update

While debugging this issue, I noticed that the Dockerfile is using Poetry 1.1.11. This is a very old version of Poetry.
The latest version is 1.6.x.

Updating to Poetry 1.6 prevents the hanging.

`make dev` fails with `SetKey Timeout`.

Running make dev fails with a SetKey Timeout.

pyslac-slac-1  | DEBUG:asyncio:Using selector: EpollSelector
pyslac-slac-1  | INFO:slac_session:
pyslac-slac-1  |
pyslac-slac-1  | #################################################
pyslac-slac-1  |  ###### Starting PySlac version: 0.8.3 #######
pyslac-slac-1  | #################################################
pyslac-slac-1  |
pyslac-slac-1  |
pyslac-slac-1  | DEBUG:slac_session:Session created for evse_id DE*SWT*E123456789 on interface eth0
pyslac-slac-1  | INFO:slac_session:CM_SET_KEY: Started...
pyslac-slac-1  | DEBUG:slac_session:New NMK: b'3cac08b812cab1e1d71cf8c8056539bc'
pyslac-slac-1  | DEBUG:slac_session:New NID: b'db55c016546d05'
pyslac-slac-1  | ERROR:/venv/lib/python3.10/site-packages/pyslac/examples/single_slac_session.py:PLC chip initialization failed for EVSE DE*SWT*E123456789, interface eth0: SetKey Timeout raised.
pyslac-slac-1  | Please check your settings.

The SlacSessionController operators on the network interfaces as defined in pyslac/examples/cs_configuration.json. The defaults are eth0 and eth1.

The issue issue two fold:

  1. Interface eth0 doesn't exists in my Docker container. Instead, the interface name follows the format eth0@<number>. For example eth0@127. The <number> is not predictable.
  2. The Docker container doesn't have an eth1 interface.

I suggest to change the defaults from eth0 and eth1 to lo, that's the loop back interface. Now make dev is executed without any issues.

pyslac ModuleNotFoundError

root@ubuntu-linux-20-04-desktop:~/pyslac# make run-local-single
python pyslac/examples/single_slac_session.py
Traceback (most recent call last):
File "/root/pyslac/pyslac/examples/single_slac_session.py", line 1, in
from pyslac.utils import is_distro_linux
ModuleNotFoundError: No module named 'pyslac'
make: *** [Makefile:65: run-local-single] Error 1

Autocharge MAC EVSE ID extraction (plcstat)

AB#1525 AB#1526

For Autocharge it is possible to extract the PLC unique MAC Address from the EV, which is useful for Autocharge use case

Menno's answer:

Hi @André Duarte as mentioned during the meeting, below is the info I added to our ticket to retrieve the EV PLC node MAC address. I will also add a Wireshark trace.
Quote from ticket:
Even though the EV PLC node MAC address is not present in the high-level communication, there is a method to retrieve it. This is only possible though after SLAC matching has succeeded, because it uses specific messages defined in the HomePlug standard to retrieve the network configuration.
In open-plc-utils (the QCA reference implementation) there are two commands:

$ plcstat -t -i vensb1
 P/L NET TEI ------ MAC ------ ------ BDA ------  TX  RX CHIPSET FIRMWARE
 LOC CCO 001 00:01:87:10:A1:C0 DE:8F:A8:F8:30:76 n/a n/a QCA7000 MAC-QCA7000-1.2.5.3207-00-20180927-CS
 REM STA 002 02:26:00:00:00:22 FF:FF:FF:FF:FF:FF 009 009 QCA7000 MAC-QCA7005-1.2.5.3207-00-20180927-CS
and
plctool -m -i vensb1
vensb1 00:B0:52:00:00:01 Fetch Network Information
vensb1 00:01:87:10:A1:C0 Found 1 Network(s)
source address = 00:01:87:10:A1:C0
network->NID = 76:DE:7D:2E:84:D4:00
network->SNID = 13
network->TEI = 1
network->ROLE = 0x02 (CCO)
network->CCO_DA = 00:01:87:10:A1:C0
network->CCO_TEI = 1
network->STATIONS = 1
	station->MAC = 02:26:00:00:00:22
	station->TEI = 2
	station->BDA = FF:FF:FF:FF:FF:FF
	station->AvgPHYDR_TX = 009 mbps Primary
	station->AvgPHYDR_RX = 009 mbps Primary

which both reveal that 02:26:00:00:00:22 is the EV PLC node MAC address.
The underlying HomePlug message that can be used to retrieve the logical network information is NW_INFO.REQ. If the EVSECC sends that request to the generic HomePlug destination MAC 00:b0:52:00:00:01, the EVSE PLC node will return the network information with connected stations, including the MAC address.
Clearly, this only works after the logical network is formed, so SLAC must complete first.

Verisco_network_info.pcapng.txt

Endianness of MVF Length in CM_SLAC_MATCH.CNF

Hi everyone,

In the MatchCnf class, it is stated that:

MVF is sent in little endian

I checked the Din SPEC 70121 and ISO 15118-3 documents, and I could not find such a thing. Have I missed something? Is there any
other document you can refer me to for that?

Check if we are compliant

In a cable plug-out and plug-in event, where no new SLAC process was started, section A.9.7 of 15118-3 mentions the following about Leaving the logical network:
[V2G3-A09-121]: the low-layer communication module shall leave the logical network, reset the NMK and switch to matching state 'Unmatched'.
By resetting the NMK, the next cable plug-in will likely result in a new SLAC process as this will make sure the EV properly detects no existing logical network anymore.

Workflow 'code-quality-check' fails during set up.

The workflow 'code-quality-check' fails while configuring the runner:

Run actions/setup-python@v2
Version 3.10.0 was not found in the local cache
Error: Version 3.10.0 with arch x64 not found
The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json

See https://github.com/SwitchEV/pyslac/actions/runs/6096941630/job/16543788145

This job uses runner ubuntu-latest which refers to Ubuntu 22.04. This runner has Python 3.10.12 installed by default, not Python 3.10.0.

`make dev` fails `EnvValidationError`

Executing make dev runs pyslac/examples/single_slac_session.py. Starting this script fails with:

pyslac-slac-1  | DEBUG:asyncio:Using selector: EpollSelector
pyslac-slac-1  | Traceback (most recent call last):
pyslac-slac-1  |   File "/venv/lib/python3.10/site-packages/pyslac/examples/single_slac_session.py", line 92, in <module>
pyslac-slac-1  |     run()
pyslac-slac-1  |   File "/venv/lib/python3.10/site-packages/pyslac/examples/single_slac_session.py", line 88, in run
pyslac-slac-1  |     asyncio.run(main())
pyslac-slac-1  |   File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
pyslac-slac-1  |     return loop.run_until_complete(main)
pyslac-slac-1  |   File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
pyslac-slac-1  |     return future.result()
pyslac-slac-1  |   File "/venv/lib/python3.10/site-packages/pyslac/examples/single_slac_session.py", line 77, in main
pyslac-slac-1  |     slac_config.load_envs(env_path)
pyslac-slac-1  |   File "/venv/lib/python3.10/site-packages/pyslac/environment.py", line 47, in load_envs
pyslac-slac-1  |     env.seal()  # raise all errors at once, if any
pyslac-slac-1  |   File "/venv/lib/python3.10/site-packages/environs/__init__.py", line 447, in seal
pyslac-slac-1  |     raise EnvValidationError(f"Environment variables invalid: {error_messages}", error_messages)
pyslac-slac-1  | environs.EnvValidationError: Environment variables invalid: {'ATTEN_RESULTS_TIMEOUT': ['Must be less than or equal to 1050.']}

Unable to process unexpected `CM_SLAC_PARM` message

According to the spec, at any point in time, if a CM_SLAC_PARM.REQ is received, the application must interpret it as a reset of the Slac process and process the Slac parameter message (this means a reset of the state machine).

The issue is that with the current code, the application is unable to jump to a state where processes the slac parm request and continues with the rest of the flow. This is a design flaw and requires refactoring.

A state design pattern may be the best fit for the job:

evse_id value

Hello and thank you for you work.
I am testing the iso15118 repo using this QCA7000 board (evse mode - model 2) with RaspberryPi 4b
https://www.aliexpress.com/item/1005003956180603.html?gatewayAdapt=Msite2Pc

I am trying to setup your software in SECC mode.
I have been able to get the ISO15118 module run up and now i am trying the pyslac module run up.

I get this message when i try to start a SLAC session (with out a car connected and without the 5% duty cycle running).
This is just the first run up to test if i implemented the software properly on the Rasp. Pi.

"
mark@raspberrypi:~/myprogs/iso15118/pyslac $ python pyslac/examples/single_slac_session.py
DEBUG:asyncio:Using selector: EpollSelector
INFO:slac_session:

#################################################

Starting PySlac version: 0.8.3

#################################################

DEBUG:slac_session:Session created for evse_id DESWTE5131456589 on interface eth1
ERROR:/home/mark/myprogs/iso15118/pyslac/pyslac/examples/single_slac_session.py:PLC chip initialization failed for EVSE DESWTE5131456589, interface eth1: [Errno 1] Operation not permitted.
Please check your settings.
"

The setting "evse_id": "DESWTE5131456589" in cs_configuration.json is wrong for me.
I have one ethernet port (eth1) used for the QCA7000 communications and so i deleted the second port (eth0) in the cs_configuration file.
Given the above message, i am not sure how to find what the evse_id should be for my hardware.
I was able to connect this same hardware using a different Repo to this one and it worked fine through the SLAC phase.
I didn't have to specify an evse_id for that other approach and i am wondering if you are able to help me determine what it should be for my hardware in this case.

`make build` fails with flake8 related errors.

make build fails.

make build                                                                                                                                                                                                      master ✱
/bin/sh: 1: pip: not found
/bin/sh: 1: pip: not found
docker-compose build
[+] Building 1.4s (16/20)                                                                                                                                                                                               docker:default
 => [slac internal] load .dockerignore                                                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                                                                   0.0s
 => [slac internal] load build definition from Dockerfile                                                                                                                                                                         0.0s
 => => transferring dockerfile: 2.00kB                                                                                                                                                                                            0.0s
 => [slac internal] load metadata for docker.io/library/python:3.10.0-buster                                                                                                                                                      0.7s
 => [slac build  1/12] FROM docker.io/library/python:3.10.0-buster@sha256:bb76a025d1ba1820c33197637d21484e439347cb18c59d1858f06425d0a3b403                                                                                        0.0s
 => [slac internal] load build context                                                                                                                                                                                            0.1s
 => => transferring context: 297.27kB                                                                                                                                                                                             0.1s
 => CACHED [slac build  2/12] WORKDIR /usr/src/app                                                                                                                                                                                0.0s
 => CACHED [slac stage-1 3/6] RUN python -m venv /venv                                                                                                                                                                            0.0s
 => CACHED [slac build  3/12] RUN pip install "poetry==1.6"                                                                                                                                                                       0.0s
 => CACHED [slac build  4/12] RUN poetry config virtualenvs.create false                                                                                                                                                          0.0s
 => CACHED [slac build  5/12] COPY .coveragerc pyproject.toml poetry.lock ./                                                                                                                                                      0.0s
 => CACHED [slac build  6/12] RUN poetry update -vvvvv                                                                                                                                                                            0.0s
 => CACHED [slac build  7/12] COPY . ./                                                                                                                                                                                           0.0s
 => CACHED [slac build  8/12] RUN mv .env.dev.docker .env                                                                                                                                                                         0.0s
 => CACHED [slac build  9/12] RUN poetry install --no-interaction --no-ansi                                                                                                                                                       0.0s
 => CACHED [slac build 10/12] RUN pytest -vv --cov-config .coveragerc --cov-report term-missing  --durations=3 --cov=.                                                                                                            0.0s
 => ERROR [slac build 11/12] RUN flake8 --config .flake8 pyslac tests 
 => ERROR [slac build 11/12] RUN flake8 --config .flake8 pyslac tests                                                                                                                                                             0.6s
------
 > [slac build 11/12] RUN flake8 --config .flake8 pyslac tests:
0.540 pyslac/session.py:925:89: E501 line too long (105 > 88 characters)
0.540 pyslac/session.py:939:89: E501 line too long (136 > 88 characters)
------
failed to solve: process "/bin/sh -c flake8 --config .flake8 pyslac tests" did not complete successfully: exit code: 1

EV simulator support

I'm going to design an EV simulator.
iso155118 looks support both EV and SECC sides, pyslac looks tailored for SECC (based on available docs).

Is it possible to use pyslac for implement EV simulator?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.