You should have a device driver for the communication. This should provide functions to setup the interface and read and write data (usually with a pointer for the data and a size parameter).
Quote:
In the protocol there is a lot of Octets(octetos) which consists of 8 bytes that the protocol asks for.
I guess that you misunderstand that and you have just bytes (8 bits).
If so, just declare a buffer of sufficient size (max. number of bytes per message) and fill that with the data according to the protocol (I don't know if the below applies to your protocol but a quick web research assumes it):
unsigned char buf[MAX_MSG_SIZE];
buf[0] = 0x2f; buf[n+1] = 0x21; buf[n+2] = 0x0d; buf[n+3] = 0x0a; buf[n+4] = 0; send_meter(buf, n+4);
The above assumes that also binary data may be part of the message. If not, you might also use a
char
buffer and use
strlen()
to get the message length (when creating a
NULL
terminated buffer).
Similar for the receive function. With string data, that usually returns when a CR-LF terminated line has been received. Than just access the portion that contains the data payload.
BTW:
Are you allowed to make the document available on the net?
If not, please remove the link from your question.