tux-evse / iso15118-simulator-rs

EVCC/EVSE RUST injector for ISO15118-2-3-20 protocols
Apache License 2.0
4 stars 0 forks source link

Feature request: looping state machine until values changing #5

Open bananen-republik opened 5 days ago

bananen-republik commented 5 days ago

Hi everybody,

i tried with the TUX-EVSE a lot and it seems like that it is not great for end to end testing as an evcc simulator. It is great to test a single message fast with defined values in a simulated environment. The simulation needs every message defined in the scenario file which is to strict for testing with a real charging station. Instead it would be better to loop the current message with the expected response until the values changes. For example the Authorize message loop where the simulation expects a "Ongoing_WaitingForCustomerInteraction" and the very next Authorize message needs to be "Finished". The number of messages until new values needs to be variable for this.

Also with the ChargingStatus loop, i'm thinking of a key in the scenario file which tells the simulation how often the ChargingStatus message should be send until, for example, a PowerDelivery is send.

Best regards

fulup-bzh commented 4 days ago

@bananen-republik the injector support 3 modes:

Note: if the default injector mode does not fit your requirement. You may implement your own binding. Either in Python/Json or directly in rust. In this case you may obviously use your own state machine.

bananen-republik commented 4 days ago

@fulup-bzh thanks for your reply. Unfortunately the "Documentation" button only leads to redpesk starting page.

The minimal mode seems like what were looking for but i tried it and it only increases the time to wait for an answer but is not looping the message. For example the Authorize message: the charging station sends "Ongoing_WaitingForCustomerInteraction" to every AuthorizeReq until an external authorization was successfull, then it sends "Finished". Just delaying the answer to only send one AuthroizeResp is not an option.

Writing an own injector seems to be an option. It is documented somewhere?

Best regards

fulup-bzh commented 4 days ago

I agree the documentation could be improved.

In every case Minimal mode is looping until retry/count value. When running from WebUI/devtools you should see one event per request. I agree that looping mode is very basic and it only check for rcode, when it could check for more values. This would be simple to implement but would require people to manually edit scenario file (I will try to propose something)

The injector source is available at https://github.com/tux-evse/injector-binding-rs it is a generic injector/responder and could be improved. Please feel free to propose new feature.

fulup-bzh commented 4 days ago

@bananen-republik I updated compact mode to make it a little smarter. Minimal mode now allows you to check the field you're interested in. By default it tests 'rcode' only, but you may add what ever you're interested in. Nevertheless this impose you to edit your scenario file after extraction with following command

pcap-iso15118 --compact=minimal --pcap_in=./afb-test/trace-logs/audi-dc-iso2.pcap --json_out=xxx

This command should now place 'rcode' under 'expected' label and all effective return values under 'response'. Would you want to check more values. Simply add them under the 'expected' label. Don't forget to check 'retry/count' value as the end of the transaction. Queries are sent a maximum of 'count' time, after that simulator return an error.

           {
              "uid":"pkg:85",
              "verb":"iso2:cable_check_req",
              "delay":740,
              "query":{
                "status":{
                  "ready":true,
                  "error":"no_error",
                  "evresssoc":55
                },
                "tagid":"cable_check_req",
                "proto":"iso2",
                "msgid":9
              },
              "ruid":"pkg:87",
              "response":{
                "rcode":"ok",
                "status":{
                  "error":"ready",
                  "notification":"none",
                  "delay":0,
                  "isolation_status":"invalid"
                },
                "processing":"ongoing",
                "tagid":"cable_check_res",
                "proto":"iso2",
                "msgid":10
              },
              "expect":{
                "rcode":"ok"
              },
              "retry":{
                "timeout":3000,
                "delay":740,
                "count":32
              }
            },
fulup-bzh commented 4 days ago

@ronan22 could you please update binary packages.