martinling / libserialport

Unofficial personal repository for libserialport - see git://sigrok.org/libserialport for official repo
http://sigrok.org/wiki/Libserialport
GNU Lesser General Public License v3.0
65 stars 34 forks source link

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

Closed fabiovila closed 3 years ago

fabiovila commented 3 years ago

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?