* [Caml-list] reading bytes into c-defined structs
@ 2004-08-28 23:00 henri dubois-ferriere
2004-08-28 23:32 ` Shishir Ramam
0 siblings, 1 reply; 3+ messages in thread
From: henri dubois-ferriere @ 2004-08-28 23:00 UTC (permalink / raw)
To: Ocaml
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] reading bytes into c-defined structs
2004-08-28 23:00 [Caml-list] reading bytes into c-defined structs henri dubois-ferriere
@ 2004-08-28 23:32 ` Shishir Ramam
2004-08-29 12:17 ` art yerkes
0 siblings, 1 reply; 3+ messages in thread
From: Shishir Ramam @ 2004-08-28 23:32 UTC (permalink / raw)
To: henri dubois-ferriere; +Cc: Ocaml
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
<henridf@gmail.com> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-08-29 12:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-28 23:00 [Caml-list] reading bytes into c-defined structs henri dubois-ferriere
2004-08-28 23:32 ` Shishir Ramam
2004-08-29 12:17 ` art yerkes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox