openOBD function composition
It is possible to construct complex openOBD functions by combining several functional building blocks. Every building block can be seen on its own as a separate function. Every function is executed within its own context. A function call in openOBD means that the control over the openOBD session is temporarily handed over from one function to another. Once the latter function finishes its execution, the calling function regains control over the openOBD session. These separate functions (or functional blocks) do not necessarily need to be hosted at the same location. It is possible to combine functions from third parties that are hosted at different locations.
Here we will illustrate how this technically works.
sequenceDiagram
autonumber
participant DEFAULT as Default function
participant F1 as Function x<br/>Towbar coding
participant F2 as Function y<br/>Unlock ECU
box lightgray
participant OS as openOBD session
end
note over OS: default context<br/>available
DEFAULT->>OS: createFunctionContext(x)
note over OS: context x<br/>available
OS->>DEFAULT: sessionInfo_x
DEFAULT->>F1: runFunction(x, sessionInfo_x)
F1->>OS: createFunctionContext(y)
note over OS: context y<br/>available
OS->>F1: sessionInfo_y
F1->>F2: runFunction(y, sessionInfo_y)
F2->>OS: authenticate(y)
activate OS
note over OS: context y<br/>active
OS-->>F2: session_token
activate F2
rect rgb(200, 150, 255)
Note right of F2: OBD communication<br/>to unlock ECU
F2-->OS: OBD communication
end
F2->>OS: finish(y)
deactivate OS
deactivate F2
OS-->>F1: authentication_token
note over OS: context x<br/>available
F1->>OS: authenticate(x)
activate OS
note over OS: context x<br/>active
OS-->>F1: session_token
activate F1
rect rgb(200, 150, 255)
Note right of F1: OBD communication<br/>to code towbar
F1-->OS: OBD communication
end
F1->>OS: finish()
deactivate OS
deactivate F1
OS-->>DEFAULT: authentication_token
note over OS: default context<br/>available
Note right of DEFAULT: Evaluate results<br/>and finish session
DEFAULT->>OS: finish()