DelfiSpace / DelfiPQcore

0 stars 1 forks source link

DataMessage: Add get and set for Application Address and REQ/REP ( + CmdHandler) #37

Closed CasperBroekhuizen closed 4 years ago

CasperBroekhuizen commented 4 years ago

As discussed, extend the OSI Model to transportation level to application specific addresses (Services) This will need to be reflected by the PQ9Bus project, to add specific fields to the getters and setters of the PQ9 Protocol.

This field can then be processed in the CmdHandler to only respond to Requests.

CasperBroekhuizen commented 4 years ago

New feature on new branch:

Change in commandHandler declaration: CommandHandler<PQ9Frame, PQ9Message> cmdHandler(pq9bus, services, 5);

Merge planned after cleaning up core services with new getters and setters

CasperBroekhuizen commented 4 years ago

Updated DataMessage and PQ9Message with new function and renames. A user now sets the Payload of a Message size separate to the service and req/reply indicator.

a Message has:

When a user sets the payload size this does not include the Service number and REQ/REP indicator. (as the size of these fields can be different from a different Message 'protocol' than PQ9Message).

In PQ9Message specifically, the Service Number and REQ/REP indicator are both 1 byte big. Meaning that the total message size will be (PayloadSize + 2).

Commits regarding this change:

However this creates the following problem / ambiguity. In the older setup the entire message is called Payload. This is true, as it is the Payload of the Frame. However, services are limited to the message frames, thus their payload is within the message. Older services use the system where payload[0] is set with the service number and payload[1] is set with the message type. This system should become avoided as proper getters and setters are available. The following functions should be used:

Older services use getPayload()[i] = value, which directly accessed the entire message buffer, including service and type, hence should be avoided. And older services use setSize(value), which directly sets the size of the entire Message, and also should be avoided. Currently they are still available in order to be compatible with older services.

CasperBroekhuizen commented 4 years ago

The CommandHandler now performs a check if the message is a REQ, hence this check is no longer necessary in the services themselves and can be removed. The ERROR reply also no longer exists, hence the CommandHandler REPLYs with Service Number 0 and an error code on reply to a non-existing service (currently 1, but a define is available).

Housekeeping and Ping now always reply and have been cleaned and simplified. The Reset Service now expects a CommandCode in the Message Payload and REPLYs with a status number in it's payload (NO_ERROR: 0, UNKOWN_COMMAND: 1).

Commits regarding this:

CasperBroekhuizen commented 4 years ago

Aslo in MSP432P4111 https://github.com/DelfiSpace/DelfiPQcore/commit/8de41d23d8637a7a5c39d629c4787a84dce7e76c