From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Binary and XML serialization of types Date: Fri, 24 Jan 2014 16:22:15 +0100 Organization: cbb software GmbH Message-ID: <1txs6yifzioke$.30cghpl6qq1j$.dlg@40tude.net> References: <20a36d96-850e-4020-8dfa-777eb9c944f4@googlegroups.com> <9e27abb7-e944-4bd4-a10c-600fe4da7872@googlegroups.com> <56a5aeb6-8704-457c-a24f-b664746afe72@googlegroups.com> <13pvagjpwejni$.1e8ll5btxg1f5$.dlg@40tude.net> <5bf8c737-b99d-4069-885f-03fe82f06cc6@googlegroups.com> <14k7gbu5ws82b.3pn20kh5ci50.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: I5Na6+WsEzT8WoegI0VZTA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:18286 Date: 2014-01-24T16:22:15+01:00 List-Id: On Fri, 24 Jan 2014 06:44:39 -0800 (PST), hanslad@gmail.com wrote: >> In the case 2, you should consider using packets instead of a raw octet >> stream. Typically you would form an outgoing packet in the memory, using >> whatever means (e.g. by a string-mapped stream) and then send the packet >> out as a whole. It is especially important to do if you are going to use >> NO_DELAY socket option. > > This sounds interesting. Do you know any good examples of this? I am not sure I understand your question. Examples of what? Of the protocols using NO_DELAY? >> Is it a custom protocol you are going to invent? Anyway, the protocols >> usually deploy some sort of packet header to describe the request and the >> body of. The most efficient way is when the body length can be determined >> from the header. You read the body into memory and then parse it, e.g. >> using a string-mapped stream. > > The protocol is certanly not invented by me(OPC UA), but I want to > implement it in Ada as a long term hobby project. The base types(int, > IEEE-754 float) is encoded with the least significant byte appearing first > (i.e. little endian). In that case you can use the implementations from Simple Components. I cannot verify about endianness. I used OPC only once with a commercial client from Softing GmbH. OPC is too slow and uncomfortable to use in automation systems. Are you going to develop an OPC server or an OPC client? Are you sure you really want OPC? Because, for instance, an SPS can be communicated through ModBus or ITOT, both far easier and faster than OPC. >>> For me it would be locical to separate all the "wire information" from the >>> type information. Today, the binary and xml encoding scheme is defined, >>> and I had hope to be able to separate this in different packages. >> >> That is doable. > > A simple example would be great! > As a total Ada beginner, any code examples or references to it will help me alot. Well, it is not simple in general. You can take a look how Simple Components deal with TCP/IP servers in a protocol-independent way. http://www.dmitry-kazakov.de/ada/components.htm#multiple_GNAT.Sockets.Servers Specifically regarding Ada, there are many ways how to handle OSI hierarchy. Major approaches are: 1. Generics: other layers are formal parameters; 2. Inheritance, tagged types: other layers are parent or derived types; 3. Mix-in inheritance: other layers are access discriminants. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de