Shop OBEX P1 Docs P2 Docs Learn Events
Eddie Robot Python cmds — Parallax Forums

Eddie Robot Python cmds

MjgMjg Posts: 2
edited 2013-11-15 15:52 in Robotics
I am trying to make a simple python project to send commands to an eddie platform along these line:

import serial
import ctypes
import sys
import os
import time

ser = serial.Serial("COM3",115200)

print ser.name
cmd="go 20 20"
ser.write(cmd)

ser.close()

I know that the port is open and is working, but the commands that I have been sending do not execute. I have tried using ascii and hex but still nothing. I am guessing that I need a wrapper of some sort but I am at a loss right now. Any info/help would be greatly appreciated.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-11-13 13:34
    You need to follow the Command Set.. In particular, the format of a command is
    <cmd>[<WS><param1>...<WS><paramN>]<CR>
    

    You're missing the tail CR.
  • MjgMjg Posts: 2
    edited 2013-11-15 14:02
    I miss typed the string when pasting the code but you are correct. I should have "go 20 20\r". The problem was that there was no time to process the string by char. In the Parallax Serial Terminal, sending a char flashes a blue light on the board, and a red light flashes on a carriage return.When I sent the string to the serial port using python, the string would not process char by char as is. I added a time.sleep(1) so that python will take some time to process the string.

    import serial
    import ctypes
    import sys
    import os
    import time

    ser = serial.Serial("COM3",115200)

    print ser.name
    cmd="go 20 20\r"
    ser.write(cmd)
    time.sleep(.01)

    ser.close()
  • SRLMSRLM Posts: 5,045
    edited 2013-11-15 15:52
    Are you saying that the Eddie board is dropping characters on receive? That's interesting, because it uses FDS as it's driver. IIRC FDS has a 16 byte buffer, so that should be sufficient to hold everything. And I think FDS is fast enough to get each byte with the minimum of spacing.

    But if not, I'd suggest swapping it out for FFDS1 from lonesock. I've tested it up to 460800 baud at full half duplex saturation and it does fine.
Sign In or Register to comment.