Re: [ros-users] Serial Port Problems

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Blaise Gassend
Date:  
To: ros-users
Subject: Re: [ros-users] Serial Port Problems
Hi Titus,

You are opening your port with O_NDELAY, which means that you want
non-blocking IO. That means that if the port is currently unable to
accept data, write will return zero and not write anything. Your code
is failing to check that case. This probably works in the debugger
because you are slowing things way down, allowing buffers to empty
before you do the next write.

You either want to make your write blocking, or you need some strategy
for retrying the write if it didn't send the data.

Blaise

On Wed, Sep 15, 2010 at 8:45 AM, Titus Appel <> wrote:
> Hello,
>
> I'm using ROS with Eclipse and I'm trying to get the serial port to work so
> I can send commands to a robot platform.  I'm new to C++ so that might be a
> problem.  The code compiles ok, but the problem is when I write to the
> serial port what I wanted to write doesn't get written.  However when I set
> a breakpoint at this line:
>
> cnt = write(port,&this->packet[byteNum],1); in src/packet.cpp
>
> and run each time it stops, the serial port writes the correct data in the
> buffer.
> My code is posted on: http://code.google.com/p/txt-ros/source/browse/
>
> Any help would be appreciated.
> Thanks,
> Titus
>
> _______________________________________________
> ros-users mailing list
>
> https://code.ros.org/mailman/listinfo/ros-users
>
>