diff --git a/docs/classdiagram.svg b/docs/classdiagram.svg index 04442a6..01f6a67 100644 --- a/docs/classdiagram.svg +++ b/docs/classdiagram.svg @@ -1,3 +1,3 @@ -
<interface_type→SoftwareSerial>
CommInterface_modbusRTU
- deviceId: char
- charTimeout: uint
- frameTimeout: uint
- recTimeout: uint
+ send() 
+ receive()
+ getDeviceId()
- calulateTimeouts()
- clearRxBuffer()
Message
 
+ to_string()
<<struct>>
Message_content_t
- msg_text: string 
- receiver_id: char
- sender_id: char
MessageService
 
+ sendNewMessage()
+ stackProcessing()
+ getdestinationId
- sendAck()
- printMessage()
Abstract-Service-layer
Service-implementation-layer
Service-layer
ServiceInterface_modbusRTU
 
# getPDU_from_services()
# addPDU_to_service() 
+ communicate() 
CommInterface
- interface: interface_type
- receiveBuffer: CharArray*
- sendBuffer: CharArray*
# send() <<virtual>>
# receive() <<virtual>>
+ sendNewFrame()
+ finishedSending()
+ getReceivedFrame()
+ receivedNewFrame()
+ receiveCycle()
+ sendCycle()
Frame
- content: String
- representation: CharAray
 
ModbusRTU_Frame
- CRC16mask: short
- CRC16startval: short
- slaveId: char 
- functionCode: char
- rep_to_content() 
- content_to_rep() 
- calcCRC16()
+ check_crc()

+ getFunctionCode()
r/w dedicated memory →
←dedicates memory
<c→Message, s→2>
<<bind>>
<c→Message_content_t>
<r→String>
<<bind>>
ServiceCluster<n→1>
 
 
<<bind>>
<n→1>
ServiceClusterBase
 
+ getService_byID()
+ getService_byPos()
+ getNumberOfServices()
ServiceBase
 
+ get_response() 
+ responseAvailable()
+ clearResponse()
+ stackProcessing()
+ impart_pdu()  
+ get_ServiceId()
+ get_InstanceId()
<c→string, r→const char*>
<<bind>>
CommInterfaceBase
 
+ setup_interface() 
+ sendNewFrame()
+ finishedSending()
+ getReceivedFrame()
+ receivedNewFrame()
interface_type: typeName
<<bind>>
<CommInterfaceBase→CommInterface_modbusRTU>
<frameType→Frame_modbusRTU>
<<bind>>
Abstract-Communication-layer
Communication-implementation-layer
Communication-layer
ErrorService
 
+ raiseError()
+ stackProcessing()
- printError()
<c→Error, s→2>
<<bind>>
Error
 
+ to_string()
<<struct>>
ErrorContent_t
- code: errorCodes
- instanceId: char
- message: String
- getErrorMessage()
<<bind>>
<c→ErrorContent_t>
<r→String>
Content_stack
- elements: c[0..s]
- size: int
+ addElement()
+ deleteElement()
+ getElement()
+ empty()
+ full()
c: typeName
s: intExpression
Content
# content: c
# representation: r
+ get_content() 
+ get_representation() 
# rep_to_content() <<virtual>>
# content_to_rep() <<virtual>>
c, r: typeName
Service
# service_id: short 
# instance_id: short 
# response_pdu: String
# rec_stack: Content_stack<c→c, s→s>
# send_stack: Content_stack<c→c, s→s>
+ get_response() 
+ responseAvailable()
+ clearResponse()
+ stackProcessing()
+ impart_pdu()  
+ get_ServiceId()
+ get_InstanceId()
# write_response_pdu()
c: typeName
s: intExpression
ServiceCluster
- services: Service[1..n]
+ getService_byID()
+ getService_byPos()
+ getNumberOfServices()
n: intExpression
ServiceInterface
- comm_interface: CommInterfaceBase
- services: ServiceClusterBase
- sendItem: CharArray
- recItem: CharArray
- recStack: Content_stack <c→frameType, s→Stacksize>
- sendStack: Content_stack <c→frameType, s→Stacksize>
# getPDU_from_services() <<virtual>>
# addPDU_to_service() <<virtual>>
# proecessServices()
# processRecStack()
# processSendStack()
+ communicate() <<virtual>>
CommInterfaceBase: typeName
frameType: typeName
ErrorState
- code: errorCodes 
+ raiseError()
+ getErrorState()
+ clearErrorState()
<<enumeration>>
errorCodes
norError
framingError
crcError
arbitrationError
serviceNotFound
unknownError
2
CharArray
- data: char*
- size: int
- extendArray()
+ getSize()
+ getData()
+ getHexString()
\ No newline at end of file +
<interface_type→SoftwareSerial>
CommInterface_modbusRTU
- deviceId: char
- charTimeout: uint
- frameTimeout: uint
- recTimeout: uint
- nullByteSilence: uint
+ send() 
+ receive()
+ getDeviceId()
- calulateTimeouts()
- clearRxBuffer()
Message
 
+ to_string()
<<struct>>
Message_content_t
- msg_text: string 
- receiver_id: char
- sender_id: char
MessageService
 
+ sendNewMessage()
+ stackProcessing()
+ getdestinationId
- sendAck()
- printMessage()
Abstract-Service-layer
Service-implementation-layer
Service-layer
ServiceInterface_modbusRTU
 
- getPDU_from_services()
- discardInvalidFrames()
 
+ communicate() 
CommInterface
# interface: interface_type
# receiveBuffer: CharArray*
# sendBuffer: CharArray*
# send() <<virtual>>
# receive() <<virtual>>
+ sendNewFrame()
+ finishedSending()
+ getReceivedFrame()
+ receivedNewFrame()
+ receiveCycle()
+ sendCycle()
Frame


+ getServiceId() <<virtual>>
ModbusRTU_Frame
- slaveId: char 
- functionCode: char
- rep_to_content() 
- content_to_rep() 
- calcCRC16()
+ check_crc()
+ getServiceId()
r/w dedicated memory →
←dedicates memory
<c→Message, s→2>
<<bind>>
<c→Message_content_t>
<r→String>
<<bind>>
ServiceCluster<n→1>
 
 
<<bind>>
<n→1>
ServiceClusterBase
 
+ getService_byID() <<virtual>>
+ getService_byPos() <<virtual>>
+ getNumberOfServices() <<virtual>>
+ impart_pdu()  <<virtual>>
ServiceBase
 
+ get_response() <<virtual>>
+ responseAvailable() <<virtual>>
+ clearResponse() <<virtual>>
+ stackProcessing() <<virtual>>
+ impart_pdu() <<virtual>>
+ get_ServiceID() <<virtual>>
+ get_InstanceID() <<virtual>>
<c→string, r→const char*>
<<bind>>
CommInterfaceBase
 
+ setup_interface() 
+ sendNewFrame()
+ finishedSending()
+ getReceivedFrame()
+ receivedNewFrame()
interface_type: typeName
<<bind>>
<CommInterfaceBase→CommInterface_modbusRTU>
<frameType→Frame_modbusRTU>
<<bind>>
Abstract-Communication-layer
Communication-implementation-layer
Communication-layer
ErrorService
 
+ raiseError()
+ stackProcessing()
- printError()
<c→Error, s→2>
<<bind>>
Error
 
+ to_string()
<<struct>>
ErrorContent_t
- code: errorCodes
- instanceId: char
- message: String
- getErrorMessage()
<<bind>>
<c→ErrorContent_t>
<r→String>
Content_stack
- elements: c[0..s]
- size: int
+ addElement()
+ deleteElement()
+ getElement()
+ empty()
+ full()
c: typeName
s: intExpression
Content
# content: c
# representation: r
+ get_content() 
+ get_representation() 
+ isValid()
# rep_to_content() <<virtual>>
# content_to_rep() <<virtual>>
c, r: typeName
Service
# service_id: short 
# instance_id: short 
# response_pdu: String
# rec_stack: Content_stack<c→c, s→s>
# send_stack: Content_stack<c→c, s→s>
+ get_response() 
+ responseAvailable()
+ clearResponse()
+ stackProcessing()
+ impart_pdu()  
+ get_ServiceId()
+ get_InstanceId()
# write_response_pdu()
c: typeName
s: intExpression
ServiceCluster
- services: Service[1..n]
+ getService_byID()
+ getService_byPos()
+ getNumberOfServices()
+ impart_pdu()
n: intExpression
ServiceInterface
- comm_interface: CommInterfaceBase
- services: ServiceClusterBase
- sendItem: CharArray
- recItem: CharArray
- recStack: Content_stack <c→frameType, s→Stacksize>
- sendStack: Content_stack <c→frameType, s→Stacksize>
# getPDU_from_services() <<virtual>>
# proecessServices()
# raiseError()
# processSendStack()
# processRecStack()
# addPDU_to_services
+ communicate() <<virtual>>
CommInterfaceBase: typeName
frameType: typeName
ErrorState
- code: errorCodes 
+ raiseError()
+ getErrorState()
+ clearErrorState()
<<enumeration>>
errorCodes
noError
framingError
crcError
arbitrationError
serviceNotFound
unknownError
2
CharArray
- data: char*
- size: int
- extendArray()
+ getSize()
+ getData()
+ getHexString()
\ No newline at end of file diff --git a/docs/html/_content__stack_8h_source.html b/docs/html/_content__stack_8h_source.html index f8582bc..86e2519 100644 --- a/docs/html/_content__stack_8h_source.html +++ b/docs/html/_content__stack_8h_source.html @@ -186,23 +186,22 @@
116
123 bool empty(){
-
124 bool retVal = (size == 0) ? true:false;
-
125 return retVal;
-
126 }
+
124 return (size == 0);
+
125 }
-
127
-
-
134 bool full(){
-
135 bool retVal = (size == MaxSize) ? true:false;
-
136 return retVal;
-
137 }
+
126
+
+
133 bool full(){
+
134 bool retVal = (size == MaxSize) ? true:false;
+
135 return retVal;
+
136 }
-
138};
+
137};
-
139
-
140#endif // CONTENT_STACK_H
+
138
+
139#endif // CONTENT_STACK_H
Content_stack
Content-Stack-Template the content-stack stores the added items (call-by-value / copy) on internal ar...
Definition Content_stack.h:45
-
Content_stack::full
bool full()
Check if the Stack is full (size reached MaxSize)
Definition Content_stack.h:134
+
Content_stack::full
bool full()
Check if the Stack is full (size reached MaxSize)
Definition Content_stack.h:133
Content_stack::addElement
bool addElement(content_class element)
Add item to stack.
Definition Content_stack.h:72
Content_stack::empty
bool empty()
Check if the Stack is empty (size is 0)
Definition Content_stack.h:123
Content_stack::getElement
content_class * getElement(int index=0)
Get Pointer to element in the stack. Accepts positive and negative indexing.
Definition Content_stack.h:107
diff --git a/docs/html/_message_service_8h_source.html b/docs/html/_message_service_8h_source.html index 5e765c1..e6b363d 100644 --- a/docs/html/_message_service_8h_source.html +++ b/docs/html/_message_service_8h_source.html @@ -167,8 +167,8 @@
Message
Represents a message with information for sender and receiver, and provides methods for converting be...
Definition Message.h:109
MessageService
Service class for handling messages and acknowledgments.
Definition MessageService.h:68
MessageService::MessageService
MessageService(uint8_t instance_id)
Constructor for MessageService with default Service ID "m".
Definition MessageService.cpp:28
-
MessageService::sendMessage
void sendMessage(char receiverId, String messagetext)
Sends a new message.
Definition MessageService.cpp:77
-
MessageService::get_destinationId
uint8_t get_destinationId()
Retrieves the destination instance ID for the current response PDU in the send stack.
Definition MessageService.cpp:55
+
MessageService::sendMessage
void sendMessage(char receiverId, String messagetext)
Sends a new message.
Definition MessageService.cpp:72
+
MessageService::get_destinationId
uint8_t get_destinationId()
Retrieves the destination instance ID for the current response PDU in the send stack.
Definition MessageService.cpp:50
MessageService::stackProcessing
void stackProcessing() override
Processes all messages from the receive stack.
Definition MessageService.cpp:35
Service
Service-Template to derive a Service class by defining the Content (derived Class of "Content") to ha...
Definition Service.h:115
mockArduino.h
diff --git a/docs/html/_service_interface_8h_source.html b/docs/html/_service_interface_8h_source.html index 62991d8..62b286c 100644 --- a/docs/html/_service_interface_8h_source.html +++ b/docs/html/_service_interface_8h_source.html @@ -224,67 +224,68 @@
184 virtual void addPDU_to_services()
185 {
-
186 // abort, if no new PDU available
-
187 if (recStack.empty()) return;
-
188 // Add all received PDUs to the Services
-
189 while (!recStack.empty())
-
190 {
-
191 // Try to add Frame from rec-stack to Service
-
192 Frame* receivedFrame = recStack.getElement();
-
193 errorCodes ServicesErrorState = services->impartPdu(receivedFrame);
-
194
-
195 // handle the Service-Clusters error-state
-
196 if (ServicesErrorState != noError) raiseError(ServicesErrorState);
-
197
-
198 // clear Error-state after handling error
-
199 services->clearErrorState();
-
200
-
201 // Skip Discard and leave the rec-stack-processing
-
202 if (ServicesErrorState = overflow) break;
-
203
-
204 // discard frame
-
205 recStack.deleteElement();
-
206 };
-
207 };
+
186 // Add all received PDUs to the Services
+
187 while (!recStack.empty())
+
188 {
+
189 // Try to add Frame from rec-stack to Service
+
190 Frame* receivedFrame = recStack.getElement();
+
191 errorCodes ServicesErrorState = services->impartPdu(receivedFrame);
+
192
+
193 // handle the Service-Clusters error-state
+
194 if (ServicesErrorState != noError) raiseError(ServicesErrorState);
+
195
+
196 // clear Error-state after handling error
+
197 services->clearErrorState();
+
198
+
199 // Skip Discard and leave the rec-stack-processing
+
200 if (ServicesErrorState == overflow) break;
+
201
+
202 // discard frame
+
203 recStack.deleteElement();
+
204 };
+
205 };
-
208
-
209
-
-
223 virtual void processRecStack() {
-
224 // Serial debugging
-
225 #ifdef DEBUG
-
226 Serial.println("Processing Receive-Stack...");
-
227 #endif
-
228 // Handle receivebuffer
-
229 while (comm_interface->receivedNewFrame() && !recStack.full()){
-
230 if (recItem.getSize() != 0){ // Item not empty
-
231 frameType recItemFrame(&recItem); // Construct Frame-Class derived Object (nullptr if failed)
-
232 if (recItemFrame.isValid()){
-
233 recStack.addElement(recItemFrame); // Add the received element to the stack
-
234 }else{
-
235 raiseError(framingError);} // frame-construction failed
-
236 recItem = CharArray(); // Clear rec-Item
-
237 }
-
238
-
239 // check the commInterfaces ErrorState
-
240 errorCodes commInterfaceErrorState = comm_interface->getErrorState();
-
241 if (commInterfaceErrorState!=noError) raiseError(commInterfaceErrorState);
-
242 comm_interface->clearErrorState();
-
243
-
244 comm_interface->getReceivedFrame(&recItem); // Impart memory the received item has to be stored at
-
245 comm_interface->receiveCycle(); // Receive new frames from comm-interface
-
246 }
-
247 comm_interface->receiveCycle(); // Receive new frames from comm-interface
-
248
-
249 // check the commInterfaces ErrorState
-
250 errorCodes commInterfaceErrorState = comm_interface->getErrorState();
-
251 if (commInterfaceErrorState!=noError) raiseError(commInterfaceErrorState);
-
252 comm_interface->clearErrorState();
-
253 }
+
206
+
207
+
+
221 virtual void processRecStack() {
+
222 // Serial debugging
+
223 #ifdef DEBUG
+
224 Serial.println("Processing Receive-Stack...");
+
225 #endif
+
226 // exit if no space on rec-stack
+
227 if (recStack.full()) return;
+
228
+
229 // Handle receivebuffer
+ +
231 if (recItem.getSize() != 0){ // Item not empty
+
232 frameType recItemFrame(&recItem); // Construct Frame-Class derived Object (nullptr if failed)
+
233 if (recItemFrame.isValid()){
+
234 recStack.addElement(recItemFrame); // Add the received element to the stack
+
235 }else{
+
236 raiseError(framingError);} // frame-construction failed
+
237 recItem = CharArray(); // Clear rec-Item
+
238 }
+
239
+
240 // check the commInterfaces ErrorState
+
241 errorCodes commInterfaceErrorState = comm_interface->getErrorState();
+
242 if (commInterfaceErrorState!=noError) raiseError(commInterfaceErrorState);
+ +
244
+
245 // Impart memory the received item has to be stored at
+ +
247 }
+
248 comm_interface->receiveCycle(); // Receive new frames from comm-interface
+
249
+
250 // check the commInterfaces ErrorState
+
251 errorCodes commInterfaceErrorState = comm_interface->getErrorState();
+
252 if (commInterfaceErrorState!=noError) raiseError(commInterfaceErrorState);
+ +
254 }
-
254};
+
255};
-
255#endif // SERVICEINTERFACE_H
+
256#endif // SERVICEINTERFACE_H
CommInterface.h
Content_stack.h
errorCodes
errorCodes
Enumeration for various error codes.
Definition Error.h:47
@@ -303,7 +304,7 @@
CommInterfaceBase::finishedSending
virtual bool finishedSending()
Check, if the Frame was sent and the CommInterface is ready to send the next Frame.
Definition CommInterface.h:75
CommInterfaceBase::sendNewFrame
virtual void sendNewFrame(CharArray *sendFrame)
Add a new Frame to the send-buffer.
Definition CommInterface.h:67
Content_stack
Content-Stack-Template the content-stack stores the added items (call-by-value / copy) on internal ar...
Definition Content_stack.h:45
-
Content_stack::full
bool full()
Check if the Stack is full (size reached MaxSize)
Definition Content_stack.h:134
+
Content_stack::full
bool full()
Check if the Stack is full (size reached MaxSize)
Definition Content_stack.h:133
Content_stack::addElement
bool addElement(content_class element)
Add item to stack.
Definition Content_stack.h:72
Content_stack::empty
bool empty()
Check if the Stack is empty (size is 0)
Definition Content_stack.h:123
Content_stack::getElement
content_class * getElement(int index=0)
Get Pointer to element in the stack. Accepts positive and negative indexing.
Definition Content_stack.h:107
@@ -331,7 +332,7 @@
ServiceInterface::processServices
virtual void processServices()
start the stackProcessing of the registered services
Definition ServiceInterface.h:109
ServiceInterface::recItem
CharArray recItem
Item received last
Definition ServiceInterface.h:95
ServiceInterface::recStack
Content_stack< frameType, STACKSIZE > recStack
stack for received frames (instance of Content_stack-derived class, specified for type of frames,...
Definition ServiceInterface.h:86
-
ServiceInterface::processRecStack
virtual void processRecStack()
Add items received by the CommInterface to the recStack and execute the CommInterface's receiveCycle ...
Definition ServiceInterface.h:223
+
ServiceInterface::processRecStack
virtual void processRecStack()
Add items received by the CommInterface to the recStack and execute the CommInterface's receiveCycle ...
Definition ServiceInterface.h:221
ServiceInterface::comm_interface
CommInterfaceBase * comm_interface
pointer to Communication-Interface (instance of CommInterface-derived class)
Definition ServiceInterface.h:80
ServiceInterface::getPDU_from_services
virtual void getPDU_from_services()=0
Add all PDUs provided by the services to the sendstack, depending on how frametype stores the informa...
ServiceInterface::ServiceInterface
ServiceInterface(CommInterfaceBase *comm_interface, ServiceClusterBase *services)
Construct a new Service Interface object.
Definition ServiceInterface.h:64
diff --git a/docs/html/_service_interface__modbus_r_t_u_8h_source.html b/docs/html/_service_interface__modbus_r_t_u_8h_source.html index 3bc54f6..d4f5953 100644 --- a/docs/html/_service_interface__modbus_r_t_u_8h_source.html +++ b/docs/html/_service_interface__modbus_r_t_u_8h_source.html @@ -149,10 +149,12 @@
84 private:
102 void getPDU_from_services() override;
103
-
104};
+
109 void discardInvalidFrames();
+
110
+
111};
-
105
-
106#endif // SERVICEINTERFACE_MODBUSRTU
+
112
+
113#endif // SERVICEINTERFACE_MODBUSRTU
CommInterface_modbusRTU.h
Frame_modbusRTU.h
MessageService.h
@@ -162,7 +164,7 @@
ServiceInterface_modbusRTU
Service-Interface-class for Modbus-RTU: Impart incoming frames from the CommInterface to the designat...
Definition ServiceInterface_modbusRTU.h:47
ServiceInterface_modbusRTU::~ServiceInterface_modbusRTU
~ServiceInterface_modbusRTU()
Destroy the ServiceInterface_modbusRTU object.
Definition ServiceInterface_modbusRTU.cpp:31
ServiceInterface_modbusRTU::ServiceInterface_modbusRTU
ServiceInterface_modbusRTU(ServiceClusterBase *services, CommInterface_modbusRTU *comm_interface)
Construct a new ServiceInterface_modbusRTU object.
Definition ServiceInterface_modbusRTU.cpp:27
-
ServiceInterface_modbusRTU::communicate
void communicate() override
Manages data transfer between the CommInterface and services.
Definition ServiceInterface_modbusRTU.cpp:72
+
ServiceInterface_modbusRTU::communicate
void communicate() override
Manages data transfer between the CommInterface and services.
Definition ServiceInterface_modbusRTU.cpp:94
ServiceInterface
Template for generic Service-Interface Defines the handling of incoming frames from CommInterface to ...
Definition ServiceInterface.h:56
ServiceInterface< CommInterface_modbusRTU, Frame_modbusRTU >::comm_interface
CommInterface_modbusRTU * comm_interface
Definition ServiceInterface.h:80
ServiceInterface< CommInterface_modbusRTU, Frame_modbusRTU >::services
ServiceClusterBase * services
Definition ServiceInterface.h:83
diff --git a/docs/modbus_classdiagram.drawio b/docs/modbus_classdiagram.drawio index e7723c7..70def58 100644 --- a/docs/modbus_classdiagram.drawio +++ b/docs/modbus_classdiagram.drawio @@ -1,6 +1,6 @@ - + - + @@ -18,19 +18,19 @@ - + - - + + - + - + - + @@ -117,7 +117,7 @@ - + @@ -125,10 +125,10 @@ - - + + - + @@ -137,12 +137,12 @@ - + - + - + @@ -151,11 +151,16 @@ - - + + - + + + + + + @@ -166,17 +171,17 @@ - - + + - - + + - + - - + + @@ -187,24 +192,28 @@ - + - - + + - + - - + + - - + + - + - + + + + + @@ -288,8 +297,16 @@ - - + + + + + + + + + + @@ -297,10 +314,10 @@ - - + + - + @@ -309,7 +326,7 @@ - + @@ -320,13 +337,14 @@ - + + @@ -367,7 +385,7 @@ - + @@ -481,7 +499,7 @@ - + @@ -492,17 +510,11 @@ - - - - - - - - + + - - + + @@ -529,10 +541,10 @@ - + - + @@ -540,17 +552,17 @@ - - + + - + - + @@ -558,8 +570,8 @@ - - + + @@ -591,7 +603,7 @@ - + @@ -600,7 +612,7 @@ - + @@ -610,7 +622,7 @@ - +