Shop OBEX P1 Docs P2 Docs Learn Events
Prop to Python troubles — Parallax Forums

Prop to Python troubles

AGCBAGCB Posts: 327
edited 2015-02-24 06:55 in Propeller 1
I'm just learning to use Python in some very simple programs. I have gotten Arduino to talk to the Python program, but can't seem to figure how to get Prop to do the same.

I've been trying to use the Full Duplex Serial object. (or FDS Plus, have also tried PST) Maybe I'm wrong on this.

Here is the simple Python program
import serial


PropData = serial.Serial('com4',115200)

while (True):
    
    if (PropData.inWaiting()>0):
        myData = PropData.readline()
        print myData
        

And here is the Arduino program that works
int cnt=0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  Serial.print("I am counting to: ");
  Serial.print(cnt);
  Serial.println(" Mississippi.");
  cnt= cnt+1;
  delay(1000);
}


And here is the prop program that doesn't work
CON       
  _clkmode = xtal1 + pll16x      '80 MHz system clock
  _xinfreq = 5_000_000

OBJ
  fds  : "fullduplexserialplus"
 'fds  : "parallax serial terminal" 
VAR
  byte num 
PUB main
  fds.start(31,30,0,115200)
  repeat   
    fds.dec(num)
    fds.str(string("  one-thousand  "))
    waitcnt(clkfreq+cnt)
    num++


I know it looks like baud rates are different (they are for the Arduino and prop programs) but they are right (matched) when I use them. The com port is also matched for each program.

So my ? is, am I using the FDS right or is there something better or easier? I get no errors but no output from the Python when using the Prop

Thanks
Aaron

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-24 06:42
    You are using println in the Arduino program but you are not sending out a new line in the Spin program. Perhaps your Python code needs to see a line termination (readline).
    Try fds.str(string(" one-thousand ",$0d,$0a))
  • AGCBAGCB Posts: 327
    edited 2015-02-24 06:47
    Thanks Peter. I'll try that right away (on a different computer)
    AAron
  • AGCBAGCB Posts: 327
    edited 2015-02-24 06:55
    Thanks Peter, That did it!!
Sign In or Register to comment.