GithubHelp home page GithubHelp logo

martinling / libserialport Goto Github PK

View Code? Open in Web Editor NEW
65.0 16.0 34.0 462 KB

Unofficial personal repository for libserialport - see git://sigrok.org/libserialport for official repo

Home Page: http://sigrok.org/wiki/Libserialport

License: GNU Lesser General Public License v3.0

Shell 0.52% Python 0.08% C 94.87% Makefile 1.20% M4 3.33%

libserialport's Introduction

-------------------------------------------------------------------------------
libserialport: cross-platform library for accessing serial ports
-------------------------------------------------------------------------------

libserialport is a minimal library written in C that is intended to take care
of the OS-specific details when writing software that uses serial ports.

By writing your serial code to use libserialport, you enable it to work
transparently on any platform supported by the library.

The operations that are supported are:

- Port enumeration (obtaining a list of serial ports on the system).
- Obtaining port metadata (USB device information, Bluetooth address, etc).
- Opening and closing ports.
- Setting port parameters (baud rate, parity, etc).
- Reading, writing and flushing data.
- Obtaining error information.

libserialport is an open source project released under the LGPL3+ license.

Status
======

The library should build and work on any Windows or Unix-based system. If it
does not, please submit a bug.

Enumeration is currently implemented on Windows, Mac OS X, FreeBSD and Linux.
On other systems enumeration is not supported, but ports can still be opened
by name and then used.

If you know how to enumerate available ports on another OS, please submit a bug
with this information, or better still a patch implementing it.

Dependencies
============

No other libraries are required.

Building
========

On Windows, libserialport can be built with Visual Studio 2019 or with
the standalone MSBuild tool, using the solution and project files provided.

For other environments, the package uses a GNU style build based on autotools.

Run "./autogen.sh" to generate the build system, "./configure" to setup, then
"make" to build the library and "make install" to install it.

Windows builds can also be created using the autotools build system, using the
MinGW-w64 toolchain from http://mingw-w64.sourceforge.net/ - either natively
in Windows with the MSYS2 environment, or cross-compiling from another system.

To build from MSYS2, the following packages must be installed: autoconf,
automake-wrapper, libtool, make, and either mingw-w64-i686-gcc (for 32-bit)
or mingw-w64-x86_64-gcc (for 64-bit). Open either the "MSYS2 MinGW 32-bit" or
"MSYS2 MinGW 64-bit" command window from the Start menu and use this when
configuring and building the package. Using the "MSYS2 MSYS" shell will build
against the Cygwin compatibility layer; this works, but port enumeration and
metadata will not be available, and binaries will depend on Cygwin. The builds
produced by MinGW-w64 are normal Windows DLLs without additional dependencies.

API
===

Doxygen API documentation is included.

It can also be viewed online at:

  http://sigrok.org/api/libserialport/unstable/

Bug reports
===========

You can report bugs for libserialport at https://sigrok.org/bugzilla.

Mailing list
============

 https://lists.sourceforge.net/lists/listinfo/sigrok-devel

IRC
===

You can find the developers in the #sigrok IRC channel on Freenode.

Website
=======

http://sigrok.org/wiki/Libserialport

libserialport's People

Contributors

anttinykanen avatar aurelj avatar biot avatar chris-se avatar danielkitta avatar dreamlayers avatar facchinm avatar jacksonmj avatar martinling avatar stefanct avatar uffejakobsen avatar uwehermann avatar zeldin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libserialport's Issues

Problem with CH340 on Windows

Devices with CH340 work just fine with libserialport on Linux, but not on Windows.

  • Python's pyserial package works for both Windows and Linux, leading me to believe the issue is with libserialport.

  • The issue doesn't happen with all chips, e.g. atmega16u2 works fine, but CH340 and CH341 don't.

This issue has been encountered by others, for example: https://github.com/iforce2d/thrustTester#arduino.

Environment:

  1. Arduino Nano clone that has a CH340 USB-Serial chip.
  2. Windows 10 with the latest CH340 drivers from the manufacturer's website.
  3. msys2 mingw64 built libserialport dll (https://github.com/Alexpux/MINGW-packages/pull/4841).

Reproduction:

Open port in read-write mode.
Write 1 byte
Read 1 byte
Write 1 byte
Read 1 byte
Write 2 bytes
Read 1 byte

All reads and writes are blocking, with large timeout (3 seconds).
The last read returns 0 (timeout) on Windows even though it shouldn't.

The exact same code on Linux works. pyserial implementation on Windows also works.

I didn't get very far with investigating this:

  1. There is nothing interesting in LIBSERIALPORT_DEBUG output.
  2. Running with gdb produces a segfault in a Windows syscall when opening the port but it doesn't result in a crash (not sure why). Nothing else that I could find but I know next to nothing about these things.

/cc @iforce2d @jamesljlster @facchinm

Windows 10

See the attached image with debug log enabled.
Retrieving VID & PID seems to be broken. On Windows XP SP3 it works well.
BTW I'm running Windows 10 in Parallels. The device is bridged from the host machine.
And the binary is generated by i686-mingw32-w64 cross compiler.
Code is like:

ret = sp_list_ports(&ports);
if (ret != SP_OK)
    return -1;
for (i = 0; ports[i]; i++) {
    int n, vid, pid;
    char sn[16];
    int ubus, uadd;

    ret = sp_get_port_usb_vid_pid(ports[i], &vid, &pid);
    if (ret != SP_OK)
        continue;
    ret = sp_get_port_usb_bus_address(ports[i], &ubus, &uadd);
    if (ret == SP_OK)
        sprintf(sn, "%04x:%04x", ubus, uadd);
    else
        strcpy(sn, "<unknown>");
    printf("vid=%04x&pid=%04x\n", vid, pid);
    for (n = 0; n < sizeof(g_models) / sizeof(g_models[0]); n++) {
        if (g_models[n].vid != vid ||
            g_models[n].pid != pid)
            continue;
        printf("[%s][+] detected model: %s.\n", sn, g_models[n].name);
        fflush(stdout);
        ret = sp_open(ports[i], SP_MODE_READ_WRITE);
        if (ret != SP_OK) {
            printf("[%s][-] failed to open port.\n", sn);
            fflush(stdout);
            continue;
        }
        ret = sp_setup(ports[i]);
        if (ret < 0) {
            printf("[%s][-] failed to configurate port.\n", sn);
            fflush(stdout);
            goto bail;
        }
        sp_close(ports[i]);
    }
}
sp_free_port_list(ports);
return 0;

send_receive.c Timed out, 0/7 bytes receive

Hello

Executing send_receive brings me a (Timed out, 0/7 bytes receive) response, as seen in the photo.

Sin título

I have windows 10, USB Serial Chipset CH340.

Under the knowledge database that they possess, that could be what generates this condition.

Question: Receive buffer sizes

Coming from the embedded world, I'm used to worrying about UART FIFO depth. In the PC world, I'm less clear how received data is buffered. While a few of my uses cases of libserialport still have physical UARTs, many are USB-serial.

How deep is the receive buffer internally? I realize this is going to be different between OS, computer hardware, and of course USB-serial vs. real UARTs.

default setting???

Hello, could you please show us the default setting of libserialport? I searched in the code and can't find it. Thanks.

Inquiry - Windows native linking

I've used and tested libserialport in our multiplatform project in Linux and Mac. I'm a little fuzzy on using it in Windows. I have successfully followed the build instructions (first building mex and then running the script from sigrok-util) to make the library.

But from reading the documentation, the expectation is that you will build your application entirely in mxe, like sigrok does, and that native building of sigrok is discouraged. What about native building of a non-sigrok application which only uses libserialport for serial communications? Is that possible? Since the building process that I went through only created linux library .a files, that suggests to me the answer is "no".

sp_wait issue under windows...

Hi:

I'm useing your library with my serialport tool which the one of the goals is cross platform ...

there's an issue with sp_wait function and sp_nonblocking_read under windows os,

first, when the input buffer is nothing, the sp_wait will block until some data was recived in driver's buffer,

and then i use sp_nonblocking_read until it return 0 ( read all buffer)

the next loops for call sp_wait , it will not block anymore...

i check it out it because of the calling below in sp_nonblocking_read:

if(bytes_read > 0)
{
if (WaitCommEvent(port->hdl, &port->events, &port->wait_ovl) == 0) {
if (GetLastError() != ERROR_IO_PENDING) {
sp_close(port);
RETURN_FAIL("WaitCommEvent() failed");
}
}
}

i modify the line :if(bytes_read > 0) to if(bytes_read == 0)

it works better now, but not perfect....

at last, thanks a lot for your job, and sorry for my bad english...

sp: get_flow returning SP_ERR_FAIL: Getting termiox failed: Inappropriate ioctl for device.

Hi,
I get error trying to open '/dev/ttyUSB0' from Arduino Nano.

sp: sp_open(0x558ef6b97500, 0x3) called.
sp: Opening port /dev/ttyUSB0.
sp: get_config(0x558ef6b97500, 0x7ffe33f54e30, 0x7ffe33f54e00) called.
sp: Getting configuration for port /dev/ttyUSB0.
sp: get_flow(3, 0x7ffe33f54e30) called.
sp: Getting advanced flow control.
sp: sp_last_error_message() called.
sp: sp_last_error_message returning Inappropriate ioctl for device.
sp: get_flow returning SP_ERR_FAIL: Getting termiox failed: Inappropriate ioctl for device.
sp: sp_free_error_message(Inappropriate ioctl for device) called.
sp: sp_free_error_message returning.
sp: get_config returning SP_ERR_FAIL.
sp: sp_close(0x558ef6b97500) called.
sp: Closing port /dev/ttyUSB0.

Maybe TCGETX is don't supported by device.
The device is Arduino Nano which use CH3400 chip.

My System:

Operating System: Arch Linux                      
 Kernel: Linux 5.12.6-arch1-1
 Architecture: x86-64
  enum sp_return result = check(sp_list_ports(&Porta),__LINE__);

  if (result != SP_OK) {
        printf("sp_list_ports() failed!\n");
        return NULL;
  }

  for (int i = 0; Porta[i] != NULL; i++) {
          struct sp_port *port = Porta[i];
          char *port_name = sp_get_port_name(port);
          printf("Found port: %i %s\n",i, port_name);
  }

  check(sp_open(Porta[0], SP_MODE_READ_WRITE), __LINE__);
  check(sp_set_baudrate(Porta[0], 115200), __LINE__);
  check(sp_set_bits(Porta[0], 8), __LINE__);
  check(sp_set_parity(Porta[0], SP_PARITY_NONE), __LINE__);
  check(sp_set_stopbits(Porta[0], 1), __LINE__);
  check(sp_set_flowcontrol(Porta[0], SP_FLOWCONTROL_NONE), __LINE__);

Any help?

Loss of parity setting under Windows OS.

This problem only applies to Windows OS!

There are two parameters member of dcb structure that control the Parity settings: fParity and Parity. Windows OS should have a bug with the function GetCommState: fParity return always FALSE: (see https://stackoverflow.com/a/36650872/12342329).

Every call of get_config (file serialport.c) resets the parity setting of the config structure which have previously made.

static enum sp_return get_config(struct sp_port *port, struct port_data *data,
	struct sp_port_config *config)
{
...
#ifdef _WIN32
	if (!GetCommState(port->hdl, &data->dcb))
		RETURN_FAIL("GetCommState() failed");
...
	if (data->dcb.fParity)
		switch (data->dcb.Parity) {
...		
	}
	else
		config->parity = SP_PARITY_NONE;
...

if (!GetCommState(port->hdl, &data->dcb))

if (data->dcb.fParity)

config->parity = SP_PARITY_NONE;

cant build on windows..

autogen and configure seem to work but when i run make i get these error..
unknown type name ‘fd_set’

am i missing something.. thank you

$ make
make all-am
CC serialport.lo
serialport.c: In function ‘sp_get_port_by_name’:
serialport.c:85:14: warning: implicit declaration of function ‘realpath’ [-Wimplicit-function-declaration]
85 | char *res = realpath(portname, pathbuf);
| ^~~~~~~~
serialport.c:85:14: warning: initialization of ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
serialport.c: In function ‘sp_blocking_write’:
serialport.c:811:2: error: unknown type name ‘fd_set’
811 | fd_set fds;
| ^~~~~~

Segmentation fault errors with port enumeration

Hello,

Using the code below I am getting a segfault error and I am starting to think my allocation is wrong somehow but I can't see where, am I missing something? My operating system is debian jessie and I am using a copy of the library built on the same machine. I have tried calling the resultant executable as normal and root user and get the same error so I don't think it is permissions related.

Best regards, kezl

/*
gcc `pkg-config  --cflags glib-2.0` -g -Wall -O3 -I/path-to/libserialport/ -o test2.o -c test2.c
gcc test2.o linux.o linux_termios.o serialport.o `pkg-config --libs glib-2.0` -ludev -o test2
*/

#include <glib.h>
#include <stdio.h>
#include <malloc.h>

#include <glib/gi18n.h>
#include <unistd.h>
#include <libudev.h>

#include "libserialport.h"

// Debug
// export LIBSERIALPORT_DEBUG=1
// ./test2


int main() {

    struct sp_port **ports = NULL;    

    //struct sp_port *port = NULL;
    int result = SP_OK;

    if (!(ports = malloc(sizeof(struct sp_port **)))) {
        printf("Port list malloc failed\n");
    } else {
        printf("Port list malloc succeeded\n");

    }

    result = sp_list_ports(&ports);
    //result = sp_list_ports((struct sp_port ***)&ports);

    if(result == SP_OK ) {
        printf("Operation completed successfully. \n");
    } else if(result == SP_ERR_ARG) {
        printf("Invalid arguments were passed to the function.\n");
    } else if(result == SP_ERR_FAIL) {
        printf("A system error occured while executing the operation.");
    } else if(result == SP_ERR_MEM ) {
        printf("A memory allocation failed while executing the operation.");
    } else if(result == SP_ERR_SUPP) {
        printf("The requested operation is not supported by this system or device. ");
    }

    //~ int i = 0;
    //~ while (ports[i] != NULL) {
        //~ port = ports[i];
        //~ const char* name = sp_get_port_name(port);
        //~ printf("%s\n", name);
        //~ i++;
    //~ }

    sp_free_port_list(ports);
    return 0;
}

Question about sp_wait

The way I understand the sp_wait function is that it returns indication as to for which port an event occured?
Is this correct?
If so, is there any way to 'select' multiple ports and wait for any of them to become readable without having to check every port or input when sp_wait returns?

Non-ASCII character in header file

I noticed a warning on libserialport.h when compiling with VS2019. Digging deeper, I saw that the bash utility file reports the format as UTF-8, whereas all the other header and source files are reported as ASCII. Digging even deeper, it seems that in line 233, the leading letter s in the word sets:

* any time. If your existing code sets @c O_NONBLOCK, you should use

is not actually an s, but rather Unicode point u0455, which is the Cyrillic small letter DZE.
This letter displays as a normal Latin letter s, so it isn't obvious at first glance.

Is this a glitch?

-Chris

Add support for WSL1

It is now possible to access windows serial devices from WSL. It would be great to see support for this in libserialport.

The first issue I ran into when attempting to use libserialport on WSL was port enumeration using sp_list_ports. The directory /sys/class/tty doesn't exist on WSL. I was using the Ubuntu 18.04 image.

Windows 10

I'm trying to read and write data from an Arduino microcontroller. My computer runs Windows 10. The code below worked on Windows 7, but no more after the upgrade. As there are many examples of libserialport, I wonder if there are any errors in my code:

uint8_t Arduino :: LocalizarSimulador(){
int vid = 0, pid = 0;

if (sp_list_ports(&lista_portas) == SP_OK){
    numero_portas = sizeof(lista_portas)/sizeof(struct sp_port *);

    for (uint8_t i = 0; i < numero_portas; i++){
        sp_copy_port(lista_portas[i], &porta);
        if (sp_get_port_usb_vid_pid(porta, &vid, &pid) == SP_OK){
            /*     usb_vid = 0x2341;
                   usb_pid = 0x42; 
            */
            if (vid == usb_vid && pid == usb_pid){
                if (lista_portas != NULL){
                    sp_free_port_list(lista_portas);
                    lista_portas = NULL;
                }
                nome_porta = std::string(sp_get_port_name(porta));
                return SIMULATOR_FOUND;
            }

...
}

uint8_t Arduino :: Conectar(){
if (uint8_t retorno = LocalizarSimulador() != SIMULATOR_FOUND){
return retorno;
}

if(sp_open(porta, (sp_mode) (SP_MODE_WRITE | SP_MODE_READ)) == SP_OK){
    if ((sp_set_baudrate(porta, 921600) == SP_OK) &&
        (sp_set_bits(porta, 8) == SP_OK) &&
        (sp_set_stopbits(porta, 1) == SP_OK) &&
        (sp_set_flowcontrol(porta, SP_FLOWCONTROL_NONE) == SP_OK)){
            conectado = true;
            return CONNECT_SUCCESS;
    }

...
}

Although I can locate the Arduino and connect to it, the following code always returns an error:

int retorno = sp_nonblocking_read(porta, &buffer_entrada[posicao_buffer], sizeof(AquisicaoEquipamentos_t) - posicao_buffer); /* always return -1 (SP_ERR_ARG). I'm sure there is no NULL pointer */

I tried to modify the code, using sp_blocking_read with the same results. Is there any error in my code? Thanks

Cannot compile Ubuntu Server

I have installed libserialport with the instructions provided. Upon installing, I copied the example program from here. When I try to compile that with
gcc example.c
I get the errors:

/tmp/cc8fDDwV.o: In function `main':
example.c:(.text+0x10): undefined reference to `sp_list_ports'
example.c:(.text+0x35): undefined reference to `sp_get_port_name'
example.c:(.text+0x70): undefined reference to `sp_free_port_list'
collect2: error: ld returned 1 exit status

Any help with this would be greatly appreciated.

read opportunity on windows

Hi:

i find when i writing data to serialport, and waiting at once, the waiting will block forever...

but after writing if i sleep 100ms or longer, it will be ok.

i'm not very good at serialport communication, is it normal on windows?

thanks and best regards!

Question: SP_MODE_READ_WRITE

In your API, http://sigrok.org/api/libserialport/unstable/index.html, the type SP_MODE_READ_WRITE = 3 is defined for the enum sp_mode. However, this seems to be missing in the available libserial.h file (repo and zip download). I was able to call sp_open(port, 3) and successfully establish a connection to my serial device, and proceeded to read and write data. [This in XCode5 on OSX 10.9]

It seems as if this block

if (flags > (SP_MODE_READ | SP_MODE_WRITE))
    RETURN_ERROR(SP_ERR_ARG, "Invalid flags");

should prevent the open call from executing, but does not. What is going on here? I need to implement this library to build a windows .dll library and was hoping to understand better before I proceeded. Thank you!

cannot open port although port is hsown as available ports

I am following this example code

#include <stdio.h>
#include <string.h>
#include <math.h>

#include <unistd.h> // for sleep function

#include <libserialport.h> // cross platform serial port lib
//#include "protocol.h"

const char* desired_port = "/dev/ttyUSB0";

struct sp_port *port;

void list_ports() {
  int i;
  struct sp_port **ports;

  sp_return error = sp_list_ports(&ports);
  if (error == SP_OK) {
    for (i = 0; ports[i]; i++) {
      printf("Found port: '%s'\n", sp_get_port_name(ports[i]));
    }
    sp_free_port_list(ports);
  } else {
    printf("No serial devices detected\n");
  }
  printf("\n");
}

void parse_serial(char *byte_buff, int byte_num) {
  for(int i = 0; i < byte_num;i++){
    printf("%c", byte_buff[i]);
  }
  printf("\n");
}

int main() {
  list_ports();

  printf("Opening port '%s' \n", desired_port);
  sp_return error = sp_get_port_by_name(desired_port,&port);
  if (error == SP_OK) {
    error = sp_open(port,SP_MODE_READ);
    if (error == SP_OK) {
      sp_set_baudrate(port,57600);
      while(true) {

        sleep(0.5); // can do something else in mean time
        int bytes_waiting = sp_input_waiting(port);
        if (bytes_waiting > 0) {
          printf("Bytes waiting %i\n", bytes_waiting);
          char byte_buff[512];
          int byte_num = 0;
          byte_num = sp_nonblocking_read(port,byte_buff,512);
          parse_serial(byte_buff,byte_num);
        }
        fflush(stdout);
      }

      sp_close(port);
    } else {
      printf("Error opening serial device\n");
    }
  } else {
    printf("Error finding serial device\n");
  }


  return 0;
}

after compiling with libserialport and executing this code on Ubuntu desktop here is the output

Found port: '/dev/ttyUSB0'

Opening port '/dev/ttyUSB0' 
Error opening serial device

I am not able to understand why and how to fix it!

request basic example code please

Hi, can you make an example folder and include a few basic examples, please? I'm trying to use this library and I'm struggling with it. Having to google a lot. I"m not familiar with "opaque structs" for instance.

A basic read/write example, list ports example, etc, would be really helpful.

Many thanks,

Gabriel.

ASCII DC1 (0x11) character isn't received

I am not able to receive the DC1 (0x11) character using the library.
Here's the relevant code:

enum sp_return error = sp_get_port_by_name("/dev/ttyS0", &port);
if (error == SP_OK) {
    error = sp_open(port, SP_MODE_READ);
    if (error == SP_OK) {
        sp_set_baudrate(port, 115200);
        while (1) {
            usleep(5000); 
            int bytes_waiting = sp_input_waiting(port);
            if (bytes_waiting > 0) {
                unsigned char byte;
                error = sp_nonblocking_read(port, &byte, 1);
                printf("%02X ", byte);
            }
            fflush(stdout);
        }

        sp_close(port);
    } else {
        printf("Error opening serial device\n");
    }
} else {
    printf("Error finding serial device\n");
}

It works fine for all most characters but somehow eats up a few control characters like DC1, DC3, DC4. I found this related stackoverflow question where the OP had a similar problem which was solved by calling tcsetattr/tcgetattr after opening the port.

FWIW, I'm running the code on a LEDE linux ARM embedded system and the same code works fine on a Mac.
Any idea how I can solve this?

Add a note about building libserialport on Windows to README file

Please, add a note, that make should be run with LDFLAGS=-no-undefined to be able to build shared library:
$ make LDFLAGS=-no-undefined

Otherwise, without LDFLAGS you will get:
$ make
CC serialport.lo
CCLD libserialport.la
libtool: link: warning: undefined symbols not allowed in i686-pc-cygwin shared libraries

Suggestion about moving sp_port structure definition or documenting it.

I suggest moving the definition to libserialport.h.in.
So that it won't be neccesary to keep the sources (libserialport_internal.h, in particular) for reference.

In other words, sp_port structure should be public.

I can't dereference pointer to sp_port to access its' members name and description because the structure is treated as incomplete type. What is a workaround? Or have I messed up something?

build failed under cygwin64

STEP 1:
$ ./autogen.sh
autoreconf-2.69: Entering directory .' autoreconf-2.69: configure.ac: not using Gettext autoreconf-2.69: running: aclocal --force -I autostuff autoreconf-2.69: configure.ac: tracing autoreconf-2.69: running: libtoolize --copy --force libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'autostuff'. libtoolize: copying file 'autostuff/ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'autostuff'. libtoolize: copying file 'autostuff/libtool.m4' libtoolize: copying file 'autostuff/ltoptions.m4' libtoolize: copying file 'autostuff/ltsugar.m4' libtoolize: copying file 'autostuff/ltversion.m4' libtoolize: copying file 'autostuff/lt~obsolete.m4' autoreconf-2.69: running: /usr/bin/autoconf-2.69 --force autoreconf-2.69: running: /usr/bin/autoheader-2.69 --force autoreconf-2.69: running: automake --add-missing --copy --force-missing Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake-1.14 line 3930. configure.ac:46: installing 'autostuff/compile' configure.ac:54: installing 'autostuff/config.guess' configure.ac:54: installing 'autostuff/config.sub' configure.ac:44: installing 'autostuff/missing' Makefile.am: installing 'autostuff/depcomp' autoreconf-2.69: Leaving directory .'

STEP 2:
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking whether ln -s works... yes
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/x86_64-pc-cygwin/bin/ld.exe
checking if the linker (/usr/x86_64-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 8192
checking how to convert x86_64-unknown-cygwin file names to x86_64-unknown-cygwin format... func_convert_file_noop
checking how to convert x86_64-unknown-cygwin file names to toolchain format... func_convert_file_noop
checking for /usr/x86_64-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for dlltool... dlltool
checking how to associate runtime and link libraries... func_cygming_dll_for_implib
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/x86_64-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for size_t... yes
checking for struct termios2... no
checking for struct termiox... no
checking for struct termios.c_ispeed... no
checking for struct termios.c_ospeed... no
checking for struct termios2.c_ispeed... no
checking for struct termios2.c_ospeed... no
checking whether BOTHER is declared... no
checking for struct serial_struct... no
checking for visibility control... declspec
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libserialport.pc
config.status: creating config.h
config.status: creating libserialport.h
config.status: executing depfiles commands
config.status: executing libtool commands

libserialport configuration summary:

  • Package version (major.minor.micro): 0.1.1
  • Library version (current:revision:age): 0:0:0
  • Prefix: /usr/local
  • Building on: x86_64-unknown-cygwin
  • Building for: x86_64-unknown-cygwin

STEP 3:
$ make
make all-am
CC serialport.lo
serialport.c: In function ‘sp_blocking_write’:
serialport.c:779:2: error: unknown type name ‘fd_set’
fd_set fds;
^
serialport.c:789:3: warning: implicit declaration of function ‘timeradd’ [-Wimplicit-function-declaration]
timeradd(&start, &delta, &end);
^
serialport.c:792:2: warning: implicit declaration of function ‘FD_ZERO’ [-Wimplicit-function-declaration]
FD_ZERO(&fds);
^
serialport.c:793:2: warning: implicit declaration of function ‘FD_SET’ [-Wimplicit-function-declaration]
FD_SET(port->fd, &fds);
^
serialport.c:804:8: warning: implicit declaration of function ‘timercmp’ [-Wimplicit-function-declaration]
if (timercmp(&now, &end, >))
^
serialport.c:804:29: error: expected expression before ‘>’ token
if (timercmp(&now, &end, >))
^
serialport.c:807:4: warning: implicit declaration of function ‘timersub’ [-Wimplicit-function-declaration]
timersub(&end, &now, &delta);
^
serialport.c:809:12: warning: implicit declaration of function ‘select’ [-Wimplicit-function-declaration]
result = select(port->fd + 1, NULL, &fds, NULL, timeout_ms ? &delta : NULL);
^
serialport.c: In function ‘sp_blocking_read’:
serialport.c:1005:2: error: unknown type name ‘fd_set’
fd_set fds;
^
serialport.c:1030:29: error: expected expression before ‘>’ token
if (timercmp(&now, &end, >))
^
serialport.c: In function ‘sp_blocking_read_next’:
serialport.c:1143:2: error: unknown type name ‘fd_set’
fd_set fds;
^
serialport.c:1168:29: error: expected expression before ‘>’ token
if (timercmp(&now, &end, >))
^
serialport.c: In function ‘sp_output_waiting’:
serialport.c:1303:22: error: ‘TIOCOUTQ’ undeclared (first use in this function)
if (ioctl(port->fd, TIOCOUTQ, &bytes_waiting) < 0)
^
serialport.c:1303:22: note: each undeclared identifier is reported only once for each function it appears in
serialport.c: In function ‘sp_wait’:
serialport.c:1471:29: error: expected expression before ‘>’ token
if (timercmp(&now, &end, >)) {
^
serialport.c:1476:57: error: expected expression before ‘>’ token
if ((timeout_overflow = timercmp(&delta, &max_delta, >)))
^
make[1]: *** [Makefile:517: serialport.lo] Error 1
make: *** [Makefile:387: all] Error 2

The build script seems to use w32 socket head file under cygwin?
And it's strange that no timercmp macro in /usr/include/sys/time.h ...

Any help needed pls tell me.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.