Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79967

pySerial works in miniterm but not in my app

Newsgroups comp.lang.python
Date 2014-10-30 12:42 -0700
Message-ID <5cb7e219-cc34-4a4f-ae93-3a2bbfa9121a@googlegroups.com> (permalink)
Subject pySerial works in miniterm but not in my app
From Dario <d.corti@gmail.com>

Show all headers | View raw


Python 2.7.6 on Mint, pySerial 2.6

I'm trying to write a console app to control a certain device via a usb com port.

In miniterm (-p /dev/ttyUSB0 -e -b 19200), I can communicate correctly with this configuration:

--- Settings: /dev/ttyUSB0  19200,8,N,1
--- RTS: inactive  DTR: inactive  BREAK: inactive
--- CTS: inactive  DSR: inactive  RI: inactive  CD: inactive
--- software flow control: inactive
--- hardware flow control: inactive
--- data escaping: raw  linefeed: CR

sw o01 + <--- I send this
sw o01 + Command OK <--- device does what it should *and* I receive this


Now my code:

----
import serial

s = serial.serial_for_url(
	'/dev/ttyUSB0',
	19200,
	bytesize = 8,
	parity   = 'N',
	stopbits = 1,
	rtscts   = False,
	dsrdtr   = False,
	xonxoff  = False,
	timeout  = 1 # tried without
)
s.close() # tried without
s.open()
s.write('sw o01 +\r')
s.flush() # tried without
s.close() # tried with a sleep before close
----

With this I don't receive anything (tried with readline etc, omitted for readability), and the device doesn't react. Also, if I connect again with miniterm and issue the command, I first receive a "wrong command" message, as if some garbage was actually sent by my app, then it works again.

Isn't my config equivalent to the one in miniterm? Anything missing?

Thanks

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

pySerial works in miniterm but not in my app Dario <d.corti@gmail.com> - 2014-10-30 12:42 -0700
  Re: pySerial works in miniterm but not in my app Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-30 18:57 -0400
    Re: pySerial works in miniterm but not in my app Dario <d.corti@gmail.com> - 2014-10-31 01:21 -0700
      Re: pySerial works in miniterm but not in my app Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-31 14:00 -0400
        Re: pySerial works in miniterm but not in my app Dario <d.corti@gmail.com> - 2014-11-01 08:03 -0700
          Re: pySerial works in miniterm but not in my app Dario <d.corti@gmail.com> - 2014-11-01 08:30 -0700
            Re: pySerial works in miniterm but not in my app Dario <d.corti@gmail.com> - 2014-11-01 08:57 -0700

csiph-web