1 /* Remote target communications for serial-line targets using SDS' protocol.
3 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* This interface was written by studying the behavior of the SDS
24 monitor on an ADS 821/860 board, and by consulting the
25 documentation of the monitor that is available on Motorola's web
29 #include "gdb_string.h"
38 #include "gdb-stabs.h"
39 #include "gdbthread.h"
46 extern void _initialize_remote_sds (void);
48 /* Declarations of local functions. */
50 static int sds_write_bytes (CORE_ADDR
, char *, int);
52 static int sds_read_bytes (CORE_ADDR
, char *, int);
54 static void sds_files_info (struct target_ops
*ignore
);
56 static int sds_xfer_memory (CORE_ADDR
, char *, int, int,
57 struct mem_attrib
*, struct target_ops
*);
59 static void sds_prepare_to_store (void);
61 static void sds_fetch_registers (int);
63 static void sds_resume (ptid_t
, int, enum target_signal
);
65 static int sds_start_remote (void *);
67 static void sds_open (char *, int);
69 static void sds_close (int);
71 static void sds_store_registers (int);
73 static void sds_mourn (void);
75 static void sds_load (char *, int);
77 static int getmessage (unsigned char *, int);
79 static int putmessage (unsigned char *, int);
81 static int sds_send (unsigned char *, int);
83 static int readchar (int);
85 static ptid_t
sds_wait (ptid_t
, struct target_waitstatus
*);
87 static void sds_kill (void);
89 static int fromhex (int);
91 static void sds_detach (char *, int);
93 static void sds_interrupt (int);
95 static void sds_interrupt_twice (int);
97 static void interrupt_query (void);
99 static int read_frame (char *);
101 static int sds_insert_breakpoint (CORE_ADDR
, char *);
103 static int sds_remove_breakpoint (CORE_ADDR
, char *);
105 static void init_sds_ops (void);
107 static void sds_command (char *args
, int from_tty
);
109 /* Define the target operations vector. */
111 static struct target_ops sds_ops
;
113 /* This was 5 seconds, which is a long time to sit and wait.
114 Unless this is going though some terminal server or multiplexer or
115 other form of hairy serial connection, I would think 2 seconds would
118 static int sds_timeout
= 2;
120 /* Descriptor for I/O to remote machine. Initialize it to NULL so
121 that sds_open knows that we don't have a file open when the program
124 static struct serial
*sds_desc
= NULL
;
126 /* This limit comes from the monitor. */
130 /* Maximum number of bytes to read/write at once. The value here
131 is chosen to fill up a packet (the headers account for the 32). */
132 #define MAXBUFBYTES ((PBUFSIZ-32)/2)
134 static int next_msg_id
;
136 static int just_started
;
138 static int message_pending
;
141 /* Clean up connection to a remote debugger. */
144 sds_close (int quitting
)
147 serial_close (sds_desc
);
151 /* Stub for catch_errors. */
154 sds_start_remote (void *dummy
)
157 unsigned char buf
[200];
159 immediate_quit
++; /* Allow user to interrupt it */
161 /* Ack any packet which the remote side has already sent. */
162 serial_write (sds_desc
, "{#*\r\n", 5);
163 serial_write (sds_desc
, "{#}\r\n", 5);
165 while ((c
= readchar (1)) >= 0)
166 printf_unfiltered ("%c", c
);
167 printf_unfiltered ("\n");
179 start_remote (); /* Initialize gdb process mechanisms */
183 /* Open a connection to a remote debugger.
184 NAME is the filename used for communication. */
187 sds_open (char *name
, int from_tty
)
190 error ("To open a remote debug connection, you need to specify what serial\n\
191 device is attached to the remote system (e.g. /dev/ttya).");
193 target_preopen (from_tty
);
195 unpush_target (&sds_ops
);
197 sds_desc
= serial_open (name
);
199 perror_with_name (name
);
203 if (serial_setbaudrate (sds_desc
, baud_rate
))
205 serial_close (sds_desc
);
206 perror_with_name (name
);
211 serial_raw (sds_desc
);
213 /* If there is something sitting in the buffer we might take it as a
214 response to a command, which would be bad. */
215 serial_flush_input (sds_desc
);
219 puts_filtered ("Remote debugging using ");
220 puts_filtered (name
);
221 puts_filtered ("\n");
223 push_target (&sds_ops
); /* Switch to using remote target now */
227 /* Start the remote connection; if error (0), discard this target.
228 In particular, if the user quits, be sure to discard it (we'd be
229 in an inconsistent state otherwise). */
230 if (!catch_errors (sds_start_remote
, NULL
,
231 "Couldn't establish connection to remote target\n",
236 /* This takes a program previously attached to and detaches it. After
237 this is done, GDB can be used to debug some other program. We
238 better not have left any breakpoints in the target program or it'll
239 die when it hits one. */
242 sds_detach (char *args
, int from_tty
)
247 error ("Argument given to \"detach\" when remotely debugging.");
250 /* Tell the remote target to detach. */
257 puts_filtered ("Ending remote debugging.\n");
260 /* Convert hex digit A to a number. */
265 if (a
>= '0' && a
<= '9')
267 else if (a
>= 'a' && a
<= 'f')
270 error ("Reply contains invalid hex digit %d", a
);
274 tob64 (unsigned char *inbuf
, char *outbuf
, int len
)
280 error ("bad length");
283 for (i
= 0; i
< len
; i
+= 3)
285 /* Collect the next three bytes into a number. */
286 sum
= ((long) *inbuf
++) << 16;
287 sum
|= ((long) *inbuf
++) << 8;
288 sum
|= ((long) *inbuf
++);
290 /* Spit out 4 6-bit encodings. */
291 *p
++ = ((sum
>> 18) & 0x3f) + '0';
292 *p
++ = ((sum
>> 12) & 0x3f) + '0';
293 *p
++ = ((sum
>> 6) & 0x3f) + '0';
294 *p
++ = (sum
& 0x3f) + '0';
300 fromb64 (char *inbuf
, char *outbuf
, int len
)
305 error ("bad length");
307 for (i
= 0; i
< len
; i
+= 4)
309 /* Collect 4 6-bit digits. */
310 sum
= (*inbuf
++ - '0') << 18;
311 sum
|= (*inbuf
++ - '0') << 12;
312 sum
|= (*inbuf
++ - '0') << 6;
313 sum
|= (*inbuf
++ - '0');
315 /* Now take the resulting 24-bit number and get three bytes out
317 *outbuf
++ = (sum
>> 16) & 0xff;
318 *outbuf
++ = (sum
>> 8) & 0xff;
319 *outbuf
++ = sum
& 0xff;
322 return (len
/ 4) * 3;
326 /* Tell the remote machine to resume. */
328 static enum target_signal last_sent_signal
= TARGET_SIGNAL_0
;
332 sds_resume (ptid_t ptid
, int step
, enum target_signal siggnal
)
334 unsigned char buf
[PBUFSIZ
];
336 last_sent_signal
= siggnal
;
337 last_sent_step
= step
;
339 buf
[0] = (step
? 21 : 20);
340 buf
[1] = 0; /* (should be signal?) */
345 /* Send a message to target to halt it. Target will respond, and send
346 us a message pending notice. */
349 sds_interrupt (int signo
)
351 unsigned char buf
[PBUFSIZ
];
353 /* If this doesn't work, try more severe steps. */
354 signal (signo
, sds_interrupt_twice
);
357 fprintf_unfiltered (gdb_stdlog
, "sds_interrupt called\n");
363 static void (*ofunc
) ();
365 /* The user typed ^C twice. */
368 sds_interrupt_twice (int signo
)
370 signal (signo
, ofunc
);
374 signal (signo
, sds_interrupt
);
377 /* Ask the user what to do when an interrupt is received. */
380 interrupt_query (void)
382 target_terminal_ours ();
384 if (query ("Interrupted while waiting for the program.\n\
385 Give up (and stop debugging it)? "))
387 target_mourn_inferior ();
388 throw_exception (RETURN_QUIT
);
391 target_terminal_inferior ();
394 /* If nonzero, ignore the next kill. */
397 /* Wait until the remote machine stops, then return, storing status in
398 STATUS just as `wait' would. Returns "pid" (though it's not clear
399 what, if anything, that means in the case of this target). */
402 sds_wait (ptid_t ptid
, struct target_waitstatus
*status
)
404 unsigned char buf
[PBUFSIZ
];
407 status
->kind
= TARGET_WAITKIND_EXITED
;
408 status
->value
.integer
= 0;
410 ofunc
= (void (*)()) signal (SIGINT
, sds_interrupt
);
412 signal (SIGINT
, ofunc
);
417 status
->kind
= TARGET_WAITKIND_STOPPED
;
418 return inferior_ptid
;
428 retlen
= sds_send (buf
, 1);
431 fprintf_unfiltered (gdb_stdlog
, "Signals: %02x%02x %02x %02x\n",
436 status
->kind
= TARGET_WAITKIND_STOPPED
;
437 status
->value
.sig
= TARGET_SIGNAL_TRAP
;
442 return inferior_ptid
;
445 static unsigned char sprs
[16];
447 /* Read the remote registers into the block REGS. */
448 /* Currently we just read all the registers, so we don't use regno. */
451 sds_fetch_registers (int regno
)
453 unsigned char buf
[PBUFSIZ
];
455 char *regs
= alloca (deprecated_register_bytes ());
457 /* Unimplemented registers read as all bits zero. */
458 memset (regs
, 0, deprecated_register_bytes ());
463 retlen
= sds_send (buf
, 3);
465 for (i
= 0; i
< 4 * 6; ++i
)
466 regs
[i
+ 4 * 32 + 8 * 32] = buf
[i
];
467 for (i
= 0; i
< 4 * 4; ++i
)
468 sprs
[i
] = buf
[i
+ 4 * 7];
473 retlen
= sds_send (buf
, 3);
475 for (i
= 0; i
< retlen
; i
++)
478 /* (should warn about reply too short) */
480 for (i
= 0; i
< NUM_REGS
; i
++)
481 regcache_raw_supply (current_regcache
, i
,
482 ®s
[DEPRECATED_REGISTER_BYTE (i
)]);
485 /* Prepare to store registers. Since we may send them all, we have to
486 read out the ones we don't want to change first. */
489 sds_prepare_to_store (void)
491 /* Make sure the entire registers array is valid. */
492 deprecated_read_register_bytes (0, (char *) NULL
, deprecated_register_bytes ());
495 /* Store register REGNO, or all registers if REGNO == -1, from the contents
496 of REGISTERS. FIXME: ignores errors. */
499 sds_store_registers (int regno
)
501 unsigned char *p
, buf
[PBUFSIZ
];
504 /* Store all the special-purpose registers. */
510 for (i
= 0; i
< 4 * 6; i
++)
511 *p
++ = deprecated_registers
[i
+ 4 * 32 + 8 * 32];
512 for (i
= 0; i
< 4 * 1; i
++)
514 for (i
= 0; i
< 4 * 4; i
++)
517 sds_send (buf
, p
- buf
);
519 /* Store all the general-purpose registers. */
525 for (i
= 0; i
< 4 * 32; i
++)
526 *p
++ = deprecated_registers
[i
];
528 sds_send (buf
, p
- buf
);
532 /* Write memory data directly to the remote machine. This does not
533 inform the data cache; the data cache uses this. MEMADDR is the
534 address in the remote memory space. MYADDR is the address of the
535 buffer in our space. LEN is the number of bytes.
537 Returns number of bytes transferred, or 0 for error. */
540 sds_write_bytes (CORE_ADDR memaddr
, char *myaddr
, int len
)
542 int max_buf_size
; /* Max size of packet output buffer */
544 unsigned char buf
[PBUFSIZ
];
548 /* Chop the transfer down if necessary */
555 todo
= min (len
, max_buf_size
);
559 buf
[2] = (int) (memaddr
>> 24) & 0xff;
560 buf
[3] = (int) (memaddr
>> 16) & 0xff;
561 buf
[4] = (int) (memaddr
>> 8) & 0xff;
562 buf
[5] = (int) (memaddr
) & 0xff;
566 for (i
= 0; i
< todo
; i
++)
567 buf
[i
+ 8] = myaddr
[i
];
569 sds_send (buf
, 8 + todo
);
571 /* (should look at result) */
580 /* Read memory data directly from the remote machine. This does not
581 use the data cache; the data cache uses this. MEMADDR is the
582 address in the remote memory space. MYADDR is the address of the
583 buffer in our space. LEN is the number of bytes.
585 Returns number of bytes transferred, or 0 for error. */
588 sds_read_bytes (CORE_ADDR memaddr
, char *myaddr
, int len
)
590 int max_buf_size
; /* Max size of packet output buffer */
592 unsigned char buf
[PBUFSIZ
];
596 /* Chop the transfer down if necessary */
603 todo
= min (len
, max_buf_size
);
607 buf
[2] = (int) (memaddr
>> 24) & 0xff;
608 buf
[3] = (int) (memaddr
>> 16) & 0xff;
609 buf
[4] = (int) (memaddr
>> 8) & 0xff;
610 buf
[5] = (int) (memaddr
) & 0xff;
611 buf
[6] = (int) (todo
>> 8) & 0xff;
612 buf
[7] = (int) (todo
) & 0xff;
615 retlen
= sds_send (buf
, 9);
617 if (retlen
- 2 != todo
)
622 /* Reply describes memory byte by byte. */
624 for (i
= 0; i
< todo
; i
++)
625 myaddr
[i
] = buf
[i
+ 2];
635 /* Read or write LEN bytes from inferior memory at MEMADDR,
636 transferring to or from debugger address MYADDR. Write to inferior
637 if SHOULD_WRITE is nonzero. Returns length of data written or
638 read; 0 for error. TARGET is unused. */
641 sds_xfer_memory (CORE_ADDR memaddr
, char *myaddr
, int len
, int should_write
,
642 struct mem_attrib
*attrib
, struct target_ops
*target
)
647 res
= sds_write_bytes (memaddr
, myaddr
, len
);
649 res
= sds_read_bytes (memaddr
, myaddr
, len
);
656 sds_files_info (struct target_ops
*ignore
)
658 puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
661 /* Stuff for dealing with the packets which are part of this protocol.
662 See comment at top of file for details. */
664 /* Read a single character from the remote end, masking it down to 7 bits. */
667 readchar (int timeout
)
671 ch
= serial_readchar (sds_desc
, timeout
);
673 if (remote_debug
> 1 && ch
>= 0)
674 fprintf_unfiltered (gdb_stdlog
, "%c(%x)", ch
, ch
);
679 error ("Remote connection closed");
681 perror_with_name ("Remote communication error");
689 /* An SDS-style checksum is a sum of the bytes modulo 253. (Presumably
690 because 253, 254, and 255 are special flags in the protocol.) */
693 compute_checksum (int csum
, char *buf
, int len
)
697 for (i
= 0; i
< len
; ++i
)
698 csum
+= (unsigned char) buf
[i
];
704 /* Send the command in BUF to the remote machine, and read the reply
708 sds_send (unsigned char *buf
, int len
)
710 putmessage (buf
, len
);
712 return getmessage (buf
, 0);
715 /* Send a message to the remote machine. */
718 putmessage (unsigned char *buf
, int len
)
721 unsigned char csum
= 0;
722 char buf2
[PBUFSIZ
], buf3
[PBUFSIZ
];
723 unsigned char header
[3];
726 /* Copy the packet into buffer BUF2, encapsulating it
727 and giving it a checksum. */
729 if (len
> 170) /* Prosanity check */
730 internal_error (__FILE__
, __LINE__
, "failed internal consistency check");
734 fprintf_unfiltered (gdb_stdlog
, "Message to send: \"");
735 for (i
= 0; i
< len
; ++i
)
736 fprintf_unfiltered (gdb_stdlog
, "%02x", buf
[i
]);
737 fprintf_unfiltered (gdb_stdlog
, "\"\n");
749 header
[1] = next_msg_id
;
753 csum
= compute_checksum (csum
, buf
, len
);
754 csum
= compute_checksum (csum
, header
+ 1, 2);
758 tob64 (header
, p
, 3);
760 enclen
= tob64 (buf
, buf3
, ((len
+ 2) / 3) * 3);
762 for (i
= 0; i
< enclen
; ++i
)
767 next_msg_id
= (next_msg_id
+ 3) % 245;
769 /* Send it over and over until we get a positive ack. */
776 fprintf_unfiltered (gdb_stdlog
, "Sending encoded: \"%s\"", buf2
);
777 fprintf_unfiltered (gdb_stdlog
,
778 " (Checksum %d, id %d, length %d)\n",
779 header
[0], header
[1], header
[2]);
780 gdb_flush (gdb_stdlog
);
782 if (serial_write (sds_desc
, buf2
, p
- buf2
))
783 perror_with_name ("putmessage: write failed");
789 /* Come here after finding the start of the frame. Collect the rest
790 into BUF. Returns 0 on any error, 1 on success. */
793 read_frame (char *buf
)
802 c
= readchar (sds_timeout
);
808 fputs_filtered ("Timeout in mid-message, retrying\n", gdb_stdlog
);
812 fputs_filtered ("Saw new packet start in middle of old one\n",
814 return 0; /* Start a new packet, count retries */
822 fprintf_unfiltered (gdb_stdlog
, "Received encoded: \"%s\"\n",
828 if (bp
< buf
+ PBUFSIZ
- 1)
835 puts_filtered ("Message too long: ");
837 puts_filtered ("\n");
844 /* Read a packet from the remote machine, with error checking,
845 and store it in BUF. BUF is expected to be of size PBUFSIZ.
846 If FOREVER, wait forever rather than timing out; this is used
847 while the target is executing user code. */
850 getmessage (unsigned char *buf
, int forever
)
855 int val
, i
, len
, csum
;
856 unsigned char header
[3];
857 unsigned char inbuf
[500];
859 strcpy (buf
, "timeout");
863 timeout
= watchdog
> 0 ? watchdog
: -1;
867 timeout
= sds_timeout
;
871 for (tries
= 1; tries
<= MAX_TRIES
; tries
++)
873 /* This can loop forever if the remote side sends us characters
874 continuously, but if it pauses, we'll get a zero from readchar
875 because of timeout. Then we'll count that as a retry. */
877 /* Note that we will only wait forever prior to the start of a packet.
878 After that, we expect characters to arrive at a brisk pace. They
879 should show up within sds_timeout intervals. */
883 c
= readchar (timeout
);
885 if (c
== SERIAL_TIMEOUT
)
887 if (forever
) /* Watchdog went off. Kill the target. */
889 target_mourn_inferior ();
890 error ("Watchdog has expired. Target detached.\n");
893 fputs_filtered ("Timed out.\n", gdb_stdlog
);
897 while (c
!= '$' && c
!= '{');
899 /* We might have seen a "trigraph", a sequence of three characters
900 that indicate various sorts of communication state. */
904 /* Read the other two chars of the trigraph. */
905 c2
= readchar (timeout
);
906 c3
= readchar (timeout
);
908 fprintf_unfiltered (gdb_stdlog
, "Trigraph %c%c%c received\n",
918 val
= read_frame (inbuf
);
922 fromb64 (inbuf
, header
, 4);
923 /* (should check out other bits) */
924 fromb64 (inbuf
+ 4, buf
, strlen (inbuf
) - 4);
929 csum
= compute_checksum (csum
, buf
, len
);
930 csum
= compute_checksum (csum
, header
+ 1, 2);
932 if (csum
!= header
[0])
933 fprintf_unfiltered (gdb_stderr
,
934 "Checksum mismatch: computed %d, received %d\n",
937 if (header
[2] == 0xff)
938 fprintf_unfiltered (gdb_stderr
, "Requesting resend...\n");
942 fprintf_unfiltered (gdb_stdlog
,
943 "... (Got checksum %d, id %d, length %d)\n",
944 header
[0], header
[1], header
[2]);
945 fprintf_unfiltered (gdb_stdlog
, "Message received: \"");
946 for (i
= 0; i
< len
; ++i
)
948 fprintf_unfiltered (gdb_stdlog
, "%02x", (unsigned char) buf
[i
]);
950 fprintf_unfiltered (gdb_stdlog
, "\"\n");
953 /* no ack required? */
957 /* Try the whole thing again. */
959 /* need to do something here */
963 /* We have tried hard enough, and just can't receive the packet. Give up. */
965 printf_unfiltered ("Ignoring packet error, continuing...\n");
972 /* Don't try to do anything to the target. */
978 unpush_target (&sds_ops
);
979 generic_mourn_inferior ();
983 sds_create_inferior (char *exec_file
, char *args
, char **env
, int from_tty
)
985 inferior_ptid
= pid_to_ptid (42000);
987 /* Clean up from the last time we were running. */
988 clear_proceed_status ();
990 /* Let the remote process run. */
991 proceed (bfd_get_start_address (exec_bfd
), TARGET_SIGNAL_0
, 0);
995 sds_load (char *filename
, int from_tty
)
997 generic_load (filename
, from_tty
);
999 inferior_ptid
= null_ptid
;
1002 /* The SDS monitor has commands for breakpoint insertion, although it
1003 it doesn't actually manage the breakpoints, it just returns the
1004 replaced instruction back to the debugger. */
1007 sds_insert_breakpoint (CORE_ADDR addr
, char *contents_cache
)
1010 unsigned char *p
, buf
[PBUFSIZ
];
1015 *p
++ = (int) (addr
>> 24) & 0xff;
1016 *p
++ = (int) (addr
>> 16) & 0xff;
1017 *p
++ = (int) (addr
>> 8) & 0xff;
1018 *p
++ = (int) (addr
) & 0xff;
1020 retlen
= sds_send (buf
, p
- buf
);
1022 for (i
= 0; i
< 4; ++i
)
1023 contents_cache
[i
] = buf
[i
+ 2];
1029 sds_remove_breakpoint (CORE_ADDR addr
, char *contents_cache
)
1032 unsigned char *p
, buf
[PBUFSIZ
];
1037 *p
++ = (int) (addr
>> 24) & 0xff;
1038 *p
++ = (int) (addr
>> 16) & 0xff;
1039 *p
++ = (int) (addr
>> 8) & 0xff;
1040 *p
++ = (int) (addr
) & 0xff;
1041 for (i
= 0; i
< 4; ++i
)
1042 *p
++ = contents_cache
[i
];
1044 retlen
= sds_send (buf
, p
- buf
);
1052 sds_ops
.to_shortname
= "sds";
1053 sds_ops
.to_longname
= "Remote serial target with SDS protocol";
1054 sds_ops
.to_doc
= "Use a remote computer via a serial line; using the SDS protocol.\n\
1055 Specify the serial device it is connected to (e.g. /dev/ttya).";
1056 sds_ops
.to_open
= sds_open
;
1057 sds_ops
.to_close
= sds_close
;
1058 sds_ops
.to_detach
= sds_detach
;
1059 sds_ops
.to_resume
= sds_resume
;
1060 sds_ops
.to_wait
= sds_wait
;
1061 sds_ops
.to_fetch_registers
= sds_fetch_registers
;
1062 sds_ops
.to_store_registers
= sds_store_registers
;
1063 sds_ops
.to_prepare_to_store
= sds_prepare_to_store
;
1064 sds_ops
.deprecated_xfer_memory
= sds_xfer_memory
;
1065 sds_ops
.to_files_info
= sds_files_info
;
1066 sds_ops
.to_insert_breakpoint
= sds_insert_breakpoint
;
1067 sds_ops
.to_remove_breakpoint
= sds_remove_breakpoint
;
1068 sds_ops
.to_kill
= sds_kill
;
1069 sds_ops
.to_load
= sds_load
;
1070 sds_ops
.to_create_inferior
= sds_create_inferior
;
1071 sds_ops
.to_mourn_inferior
= sds_mourn
;
1072 sds_ops
.to_stratum
= process_stratum
;
1073 sds_ops
.to_has_all_memory
= 1;
1074 sds_ops
.to_has_memory
= 1;
1075 sds_ops
.to_has_stack
= 1;
1076 sds_ops
.to_has_registers
= 1;
1077 sds_ops
.to_has_execution
= 1;
1078 sds_ops
.to_magic
= OPS_MAGIC
;
1081 /* Put a command string, in args, out to the monitor and display the
1085 sds_command (char *args
, int from_tty
)
1089 unsigned char buf
[1000];
1091 /* Convert hexadecimal chars into a byte buffer. */
1096 buf
[len
++] = fromhex (p
[0]) * 16 + fromhex (p
[1]);
1102 retlen
= sds_send (buf
, len
);
1104 printf_filtered ("Reply is ");
1105 for (i
= 0; i
< retlen
; ++i
)
1107 printf_filtered ("%02x", buf
[i
]);
1109 printf_filtered ("\n");
1113 _initialize_remote_sds (void)
1116 add_target (&sds_ops
);
1118 deprecated_add_show_from_set
1119 (add_set_cmd ("sdstimeout", no_class
,
1120 var_integer
, (char *) &sds_timeout
,
1121 "Set timeout value for sds read.\n", &setlist
),
1124 add_com ("sds", class_obscure
, sds_command
,
1125 "Send a command to the SDS monitor.");