Hi,
On Thu, Aug 27, 2015 at 09:00:11PM +0000, Nacho Man wrote:
> I'm sorry if this is the wrong mailing list but I couldn't really find one
> specifically for libserialport.
No problem, this is the correct one, there's no specific one for
libserialport.
> I had some questions about it and was wondering if anyone here could help.
> I was looking for some examples, in C source code, of how to use it. I've
> been reading the API documentation but I've been having trouble figuring out
> how to build a program using libserialport.
>
> If I could just figure out how to scan the system for serial ports, I think
> I'd be able to figure the rest out myself. I wouldn't think it'd matter, but
> my program will be compiled on Windows using MinGW64 (32-bit and 64-bit) and
> Linux using GNU's gcc. Thanks.And again, if this is the wrong place, I do
> apologize.
Here's a quick example to get you started, it'll list all ports it can
detect. Tested on Linux, but libserialport also works fine on Windows.
You need MinGW-w64 (the "old" MinGW will not work).
#include <stdio.h>
#include <libserialport.h>
int main(void)
{
int i;
struct sp_port **ports;
sp_list_ports(&ports);
for (i = 0; ports[i]; i++)
printf("Found port: '%s'.\n",
sp_get_port_name(ports[i]));
sp_free_port_list(ports);
}
Hope that helps, Uwe.
--
http://hermann-uwe.de | http://randomprojects.org | http://sigrok.org
------------------------------------------------------------------------------
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel