ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Please correct this python script to send data on USB0 port?

asked 2013-08-04 20:08:25 -0500

lifelonglearner gravatar image

updated 2013-08-05 01:19:18 -0500

#!/usr/bin/env python

from serial import Serial
from time import sleep

class Create:

    def __init__(self, tty="/dev/ttyUSB0"):

        self.timeout = 5
        self.port = Serial(tty, 57600, timeout= self.timeout)


    def start(self):


        self.__sendNow(P,0,0,0)
        sleep(1)
        self.__sendNow(V,0,0,100)
        sleep(10)


    def stop(self):

        self.__sendNow(V,0,0,0)

/home/admin-pc/mywork/test/scripts/create.py: line 1: This module provides a class wrapping an Exia.: command not found
from: can't read /var/mail/serial
from: can't read /var/mail/time
/home/admin-pc/mywork/test/scripts/create.py: line 6: class: command not found
/home/admin-pc/mywork/test/scripts/create.py: line 7: Wrapper class for the iRobot Create: command not found
/home/admin-pc/mywork/test/scripts/create.py: line 9: syntax error near unexpected token ('/home/admin-pc/mywork/test/scripts/create.py: line 9: def __init__(self, tty="/dev/ttyUSB0"):'

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-05 21:07:09 -0500

lifelonglearner gravatar image

updated 2013-08-05 21:07:55 -0500

Thank you viewers, I found the mistake and corrected it ....

this is just deceleration of class there is no command to write data on USB port.

there is just two line code to do the same

ser = serial.Serial('/dev/ttyS1', 19200, timeout=1)
ser.write('5')
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-08-04 20:08:25 -0500

Seen: 966 times

Last updated: Aug 05 '13