How to share the same serial port?

C. M. Heard/VVNET, Inc. heard@vvnet.com
Thu Apr 30 09:33:00 GMT 1998


On Thu, 30 Apr 1998, Tan Pinghui wrote:
>
> I use gdb to do remote debugging, but the target board has only one
> serial port,
> my problem is, how to use this port to run remote gdb and to use this
> port
> as the input/output port of the target program at the same time?

This depends on which remote protocol you are using.  If you are using
the gdb-specific protocol (the one implemented by remote.c), then the
remote stub in your target may send hex-encoded ascii data by using the
"O" response.  If it receives this response while the target is running,
gdb will translate the data and send it to the console, as indicated by
the following excerpt from the comments in remote.c:

        or...           OXX..XX XX..XX  is hex encoding of ASCII data. This can
                                        happen at any time while the program is
                                        running and the debugger should
                                        continue to wait for 'W', 'T', etc.

The processing of this response takes place in remote_wait (pid, status):

        case 'O':               /* Console output */
          for (p = buf + 1; *p; p +=2)
            {
              char tb[2];
              char c = fromhex (p[0]) * 16 + fromhex (p[1]);
              tb[0] = c;
              tb[1] = 0;
              if (target_output_hook)
                target_output_hook (tb);
              else
                fputs_filtered (tb, gdb_stdout);
            }
          continue;

CAVEAT:  the above excerpts are taken from gdb-4.16;  there may have
been changes to remote.c in gdb-4.17.  Also, I have not actually used
this feature myself, so I am not sure how well it works in practice.

Mike
-- 
C. M. Heard/VVNET, Inc.
heard@vvnet.com




More information about the crossgcc mailing list