I finally got the library to compile successfully using MSYS1.   It turns out 
libtool doesn't like spaces in the toolchain's directory.   by default, 
MinGW-w64 installs to C:\Program FIles or C:\Program Files (x86).   When I was 
trying to compile libtool, it was kind enough to tell me (and it was correct).  
 Anyway, I wanted to say thank you for the code.   I don't know if this is a 
bug with the code that you shown or if it's a bug with the library.  However, 
if no serial ports are hooked up to the system, the code below crashes the 
program.

I wonder if there's a way to prevent that.   It crashes the program regardless 
of whether I'm using the 32-bit version of the library or the 64-bit.  I 
haven't tried it in Linux yet though, just Windows 7.   Any suggestions?   
Thanks.      From: Uwe Hermann <u...@hermann-uwe.de>
 To: Nacho Man <nacho2...@yahoo.com> 
Cc: "sigrok-devel@lists.sourceforge.net" <sigrok-devel@lists.sourceforge.net> 
 Sent: Friday, August 28, 2015 6:18 AM
 Subject: Re: [sigrok-devel] A question or two about libserialport.
   
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
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to