Skip to content

Commit

Permalink
Squash merge: docs for Error handling, clearing errorstate auf servic…
Browse files Browse the repository at this point in the history
…es in ServiceInterface
  • Loading branch information
F-L-X-S committed Nov 9, 2024
1 parent 18069bb commit c20792f
Show file tree
Hide file tree
Showing 153 changed files with 2,839 additions and 1,493 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,41 @@ Conversely, the format, the information has after applying the rules of the next
### Stackprocessing
<img src="https://raw.githubusercontent.com/F-L-X-S/BusBricks/fa4a1927d184c56d71477509aa5243d7c93def95/docs/stackProcessing.svg" alt="stackProcessing" style="width:400px;">

### Error-handling
The Errors of a device are managed by a Service-derived [```ErrorService```](lib/ErrorService/ErrorService.h). Every component (no matter, if Service, ServiceInterface or CommInterface) can be enabled to raise errors by deriving the [```ErrorState```](lib/ErrorService/ErrorState.h) and calling ```raiseError()```. <br>
```cpp
class CommInterfaceBase: public ErrorState{
public:
CommInterfaceBase(): ErrorState(){};
}
```
The class-instance is now able to raise Errors and, if applicable, to handle them within the class itself. E.g.:<br>
```cpp
// wait for Frame-timeout to ensure frame is complete, raise Error, if the silence-time is violated
if((_clearRxBuffer()>0) & (receiveBuffer->getSize()!=0)){
(numBytes>=MAXFRAMESIZE) ? raiseError(frameLengthError):raiseError(arbitrationError);
}
// handle the Arbitration-Error with waiting for bus-silence
if(getErrorState()==arbitrationError) while(_clearRxBuffer()!=0);
```

To handle the Error outside the instance, the Error-state of the components has to be processed within the [```ServiceInterface```](lib/Interface/ServiceInterface.h) by checking the ErrorState of the called instances and, if applicable raising the Error with the same Error-code within the ServiceInterface: <br>

```cpp
errorCodes commInterfaceErrorState = comm_interface->getErrorState();
if (commInterfaceErrorState!=noError) raiseError(commInterfaceErrorState);
```

Only Errors raised in [```ServiceInterface```](lib/Interface/ServiceInterface.h) are forwarded to an eventually registered [```ErrorService```](lib/ErrorService/ErrorService.h), that can execute error-code-specific actions (like printing the Error or broadcasting errors to the network). <br>
After handling the Error of the called instance, the ErrorState has to be cleared:<br>
```cpp
comm_interface->clearErrorState();
```

The Error-codes are enumerated in the Content-derived [Error-class](lib/ErrorService/Error.h). To add new Error-cases, define a new Error-code in ```enum ErrorCodes``` and add an Error-message to the ```getErrorMessage(errorCodes code)```function within the [Error-class](lib/ErrorService/Error.h). The Error-Service will display those messages after an Error is either raised by another component on the local device or an Error-Frame was received.


## Deriving a custom Service
To derive a Layer-7-service, that can be used in combination with the predefined Layer-2-communication-interfaces, you have to
- [x] [define content to handle](#define-the-content)
Expand Down
3 changes: 3 additions & 0 deletions docs/html/_error_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
, <br />
&#160;&#160;<a class="el" href="#a88edd67ec29d18293fae821840fef3aca675e49e713e97b6ccc278709766f5e93">serviceNotFound</a> = '4'
, <a class="el" href="#a88edd67ec29d18293fae821840fef3acaebbf7bd809b94b7d0725f163a4d406a9">frameLengthError</a> = '5'
, <a class="el" href="#a88edd67ec29d18293fae821840fef3aca4faa9362458f0835d0b84183f40d7ce9">overflow</a> = '6'
, <a class="el" href="#a88edd67ec29d18293fae821840fef3aca24ab257f4bbf0618975b737474845b82">unknownError</a> = 'X'
<br />
}</td></tr>
Expand Down Expand Up @@ -203,6 +204,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#a88edd67ec29d18293fae8218
</td></tr>
<tr><td class="fieldname"><a id="a88edd67ec29d18293fae821840fef3acaebbf7bd809b94b7d0725f163a4d406a9" name="a88edd67ec29d18293fae821840fef3acaebbf7bd809b94b7d0725f163a4d406a9"></a>frameLengthError&#160;</td><td class="fielddoc"><p>Maximum framelength violated. </p>
</td></tr>
<tr><td class="fieldname"><a id="a88edd67ec29d18293fae821840fef3aca4faa9362458f0835d0b84183f40d7ce9" name="a88edd67ec29d18293fae821840fef3aca4faa9362458f0835d0b84183f40d7ce9"></a>overflow&#160;</td><td class="fielddoc"><p>Send- or Receivestack reached max. size of items. </p>
</td></tr>
<tr><td class="fieldname"><a id="a88edd67ec29d18293fae821840fef3aca24ab257f4bbf0618975b737474845b82" name="a88edd67ec29d18293fae821840fef3aca24ab257f4bbf0618975b737474845b82"></a>unknownError&#160;</td><td class="fielddoc"><p>Unknown <a class="el" href="class_error.html" title="Represents an error with it&#39;s error-content (error-code and an error-message), and provides methods f...">Error</a>. </p>
</td></tr>
</table>
Expand Down
1 change: 1 addition & 0 deletions docs/html/_error_8h.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var _error_8h =
[ "arbitrationError", "_error_8h.html#a88edd67ec29d18293fae821840fef3aca3d04e5ac1616b4f17188bf1cc86bdfd6", null ],
[ "serviceNotFound", "_error_8h.html#a88edd67ec29d18293fae821840fef3aca675e49e713e97b6ccc278709766f5e93", null ],
[ "frameLengthError", "_error_8h.html#a88edd67ec29d18293fae821840fef3acaebbf7bd809b94b7d0725f163a4d406a9", null ],
[ "overflow", "_error_8h.html#a88edd67ec29d18293fae821840fef3aca4faa9362458f0835d0b84183f40d7ce9", null ],
[ "unknownError", "_error_8h.html#a88edd67ec29d18293fae821840fef3aca24ab257f4bbf0618975b737474845b82", null ]
] ]
];
Loading

0 comments on commit c20792f

Please sign in to comment.