Newline in script to Arduino

This is the place for queries that don't fit in any of the other categories.

Newline in script to Arduino

Postby calph » Thu Aug 22, 2013 1:27 am

This should be simple but life never is. I know the print newline is \n and I have an Arduino that is looking for that input to finish a string build loop. Works fine with direct usb comms. Here is the script:

Code: Select all
#test script c5000.py
import serial
import time
time.sleep(1)
ser = serial.Serial(7)  # open serial port 8
print ser.portstr       # check which port was really used
ser.write ("#C5000\n"); # write a string with newline
#ser.write ("\n"); #added as test
time.sleep(5)
ser.close()             # close port
print ("Comm Closed");

If I do this directly in command line:
Code: Select all
import serial
import time
time.sleep(1)
ser = serial.Serial(7)  # open serial port 8
print ser.portstr       # check which port was really used
ser.write ("#C5000\n"); # write a string with newline

I still have to hit a return to finish the arduino string loop.

Any takers? TIA (Thanks In Advance)
Last edited by Mekire on Thu Aug 29, 2013 2:20 am, edited 1 time in total.
Reason: Code tags added. Please read the post regarding new members.
calph
 
Posts: 1
Joined: Thu Aug 22, 2013 1:17 am

Re: Newline in script to Arduino

Postby micseydel » Thu Aug 29, 2013 1:51 am

You should probably post the Arduino code too (in code tags next time).
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1393
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron