From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA29716; Sun, 29 Aug 2004 01:32:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA29728 for ; Sun, 29 Aug 2004 01:32:21 +0200 (MET DST) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i7SNWKtg023608 for ; Sun, 29 Aug 2004 01:32:21 +0200 Received: by mproxy.gmail.com with SMTP id 77so27295rnl for ; Sat, 28 Aug 2004 16:32:20 -0700 (PDT) Received: by 10.38.3.57 with SMTP id 57mr336861rnc; Sat, 28 Aug 2004 16:32:20 -0700 (PDT) Received: by 10.38.83.42 with HTTP; Sat, 28 Aug 2004 16:32:20 -0700 (PDT) Message-ID: <83f59968040828163251fb39f5@mail.gmail.com> Date: Sat, 28 Aug 2004 16:32:20 -0700 From: Shishir Ramam Reply-To: Shishir Ramam To: henri dubois-ferriere Subject: Re: [Caml-list] reading bytes into c-defined structs Cc: Ocaml In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: X-Miltered: at nez-perce with ID 41311604.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 structs:01 2004:99 henridf:01 structs:01 pointers:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 idl:01 caml-bugs:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Henri, One way to do this would be to 1. Write a C function that will actually read the bytes and populate the C data structure, and return that data structure. 2. Put this function in your idl file, and CamlIDL will generate the necessary code to make the C call *and* do the necessary translation into the Ocaml record. 3. All you then have to do it call the function in Ocaml whenever you'd like to read a packet. This is pretty neat, and works well in my experience. Hope this helps. -shishir On Sun, 29 Aug 2004 01:00:49 +0200, henri dubois-ferriere wrote: > Hi, > I have a little ocaml app which needs to read/write packets from a > serial device. > > The different packet types are originally defined as c structs and i > would like to be able to read the incoming bytes and convert them > into ocaml records with as much automation as possible. > > Is there any way to automate this process? CamlIDL will automate the > process of translating the c structs into ml, which is a first step, > but are there any tools which would allow me to then populate the ml > record from an incoming set of bytes? > > Any tips/pointers appreciated! > > Henri > > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners