Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C: cross-platform RS-232 serial library? [closed]

I am looking for an open source cross-platform library for working with the serial port in C, something along the lines of the awesome PySerial library (unfortunately I have to use C for this application).

I have only found this one: http://www.teuniz.net/RS-232/, and that doesn't seem to have mention OS X compatibility.

like image 685
Hamza Avatar asked Jun 04 '10 10:06

Hamza


People also ask

When did serial ports stop being used?

In 2004, most of the new PCs stopped shipping with an RS-232 serial interface as a part of their standard or base configuration. Common PC desktop peripherals such as printers, scanners, and fax machines are currently made with USB ports.

Is serial port still supported?

However, serial ports are still frequently used in applications demanding simple, low-speed interfaces, such as industrial automation systems, scientific instruments, point of sale systems and some industrial and consumer products.

Is RS-232 serial or parallel?

In telecommunications, RS-232 or Recommended Standard 232 is a standard originally introduced in 1960 for serial communication transmission of data.


2 Answers

You would think that a cross-platform C library for serial ports is something that would have existed for 20 years already, but as of 2013 there still wasn't one, so I created libserialport.

It is tested on Windows, Mac OS X, Linux (including Android), BSD and will probably build on other Unix systems also. It supports:

  • Port enumeration (obtaining a list of serial ports on the system)
  • Opening, closing and querying ports
  • Setting port parameters (baud rate, parity, etc.)
  • Port signalling operations (modem control lines, breaks, etc.)
  • Reading, writing, and flushing data
  • Waiting for events
  • Obtaining error information

The initial 0.1.0 release is in active use by the Sigrok project for supporting serial hardware and is packaged in several Linux distributions already. The git version also includes new API calls for getting information about USB serial adapters (VID/PID etc).

like image 160
Martin L Avatar answered Sep 28 '22 01:09

Martin L


This is a shameless plug, but I have a MIT licensed library for RS-232 communication which is portable to Windows and Linux and OS X here:

http://wjwwood.io/serial/

like image 32
wjwwood Avatar answered Sep 28 '22 02:09

wjwwood