Python: serialHelper with rospy (threading conflict?)

asked 2017-12-01 01:30:24 -0500

vKuehn gravatar image

updated 2017-12-03 07:59:59 -0500

Hi,

here a little script which works fine until I remove the remark for init of the roc node

#!/usr/bin/env python

import threading
from time import sleep
import rospy

import serialHelper


sh = serialHelper.SerialHelper()
NODE_NAME ='SerialHelperTestRos'

if __name__ == '__main__':
    try:
        t = threading.Thread(target=sh.serialReader)
        t.setDaemon(True)
        t.start()
        h = 0
        #rospy.init_node(NODE_NAME, anonymous=True)
        while True:
            sh.writeToSerial('Hello Nr' + str(h))
            h = h + 1
            resp = sh.getResponse()
            print ('response ' + resp)
            sleep(3)
    except Exception as e:
        print (e)

it's on ubuntu mate with python 2.7. Any idea why I don't see serial input when rod did init ? I am new to python and ros so any input is greatly appreciated

edit retag flag offensive close merge delete

Comments

1

@vKuehn: I've edited the title of your post to better reflect the question. "not working" is too vague.

gvdhoorn gravatar image gvdhoorn  ( 2017-12-01 03:08:41 -0500 )edit

thanks, hopefully someone has at least any hint

vKuehn gravatar image vKuehn  ( 2017-12-01 09:46:53 -0500 )edit