python serial connection

Home Forums TinyG TinyG Support python serial connection

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4339
    pdh230
    Member

    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?

    #4346
    alden
    Member

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.