python serial connection

From the original Synthetos forum (2011–2025)

Started by pdh230 on in TinyG Support. 1 reply, last activity Jul 18, 2013.

#

I have both an Arduino Due and a TinyG running simultaneously for my project, and I'm talking to them both via windows (7 64-bit). Previous experience with coolterm has not been the most positive, and I need to be able to maintain the two connections in harmony on one program. Thus, I am employing python, with the pyserial module.
Here's a quick sketch of how I'm trying to accomplish my connection to tinyG:

from serial import Serial
from threading import Thread
tinyg = Serial("COM6", 115200)
def readState():
	while True:
		print(tinyg.readline().decode('ascii'))
readthread = Thread(target=readState)
readthread.start()
while True:
	x = input("send tinyg a command")
	tinyg.write(x.encode('ascii'))

When I do this for com7 (due), it communicates perfectly, but when I try it for tinyg, it does nothing. Now, I know that my message is getting there, because the diode does flash whenever I send a command (I think it is the tx diode that flashes, but I don't remember).
tinyg.readline() command hiccups every time it runs (as opposed to due.readline() in that portion of code, executes immediately and moves on), and it returns an empty string every time.

What is it that I am missing that will get this to properly connect and give me ability to control the tinyg from python?

Staff #

One possibility is that the Windows python readline requires a windows-style line termination. Try enabling CRLF on TinyG by setting $ec=1.

This topic is from the original forum (July 2013). Your reply starts a new discussion linked to it.

Reply

Different problem? Ask a new question

Back to TinyG Support or latest activity.