Is there any library of OCaml to use Serial Port of PC?

opam
#1

I need to write a program to communicate with the STM32(a kind of microcontroller) via Serial Port. Is there any library of OCaml to use Serial Port?

0 Likes

#2

This is the third time where you ask if something exists in OCaml and response of this kind of question can be found in the OPAM website which has a list of all libraries/packages available in the OCaml ecosystem.

Then, opam search in your shell can give you a response too.

At the end, most of these projects are hosted on GitHub or GitLab otherwise.

0 Likes

#3

Assuming the serial interface is connected to your computer and it shows up as a /dev file you can simply open this file and use the Unix library bundled with OCaml.

More precisely the terminal interface will allow you to setup to baud rate, parity, etc.

Here’s a program I wrote a long time ago that may help you to get started.

0 Likes

#4

But I was on Windows.

0 Likes

#5

Which serial, USB or COM? If the latter, then COM devices provide files in basically any directory, so instead of /dev/ttyX you could read COM[0…9].

0 Likes