all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacs: send break on serial port
@ 2014-06-10  6:59 Cédric Chépied
  2014-06-10  9:05 ` Andreas Schwab
  2014-06-10  9:13 ` Leo Liu
  0 siblings, 2 replies; 6+ messages in thread
From: Cédric Chépied @ 2014-06-10  6:59 UTC (permalink / raw)
  To: emacs-devel

Hello,

I'm using serial-term to open a serial connection with devices and I sometimes
need to send a break. This is very useful for sysrq keys on embedded Linux
systems. I can't find how to do this inside emacs so I need to use minicom.

Will this functionality be added in emacs? I started to write it but I don't
know emacs code at all (I only write lisp) so any advice is welcome. This code
will only work on Linux:


0b6ff13ef78daf8aadeeb8f74e6ae91a6cbec47c HEAD master
Author: Cédric Chépied <cedric.chepied@gmail.com>
Date:   Mon Jun 9 15:53:06 2014 +0200

    Add a function to send a break via serial process
    
    This is useful to use sysrq keys.

1 file changed, 17 insertions(+)
 src/process.c | 17 +++++++++++++++++

	Modified   src/process.c
diff --git a/src/process.c b/src/process.c
index b8b8eaa..ef24b88 100644
--- a/src/process.c
+++ b/src/process.c
@@ -844,6 +844,22 @@ record_deleted_pid (pid_t pid, Lisp_Object filename)
 
 }
 
+DEFUN ("send-break-process", Fsend_break_process, Ssend_break_process, 1, 1, 0,
+       doc: /* Send a break to a serial process. */)
+  (register Lisp_Object process)
+{
+  register struct Lisp_Process *p;
+
+  process = get_process (process);
+  p = XPROCESS (process);
+
+  if (SERIALCONN1_P (p) && p->outfd >= 0)
+	  ioctl(p->outfd, TCSBRK, 0);
+
+  return Qnil;
+}
+
+
 DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
        doc: /* Delete PROCESS: kill it and forget about it immediately.
 PROCESS may be a process, a buffer, the name of a process or buffer, or
@@ -7320,6 +7336,7 @@ The variable takes effect when `start-process' is called.  */);
 
   defsubr (&Sprocessp);
   defsubr (&Sget_process);
+  defsubr (&Ssend_break_process);
   defsubr (&Sdelete_process);
   defsubr (&Sprocess_status);
   defsubr (&Sprocess_exit_status);


Regards,
-- 
Cédric Chépied
<cedric.chepied@gmail.com>



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-10 20:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10  6:59 emacs: send break on serial port Cédric Chépied
2014-06-10  9:05 ` Andreas Schwab
2014-06-10 11:13   ` Cédric Chépied
2014-06-10 20:28     ` Stefan Monnier
2014-06-10  9:13 ` Leo Liu
2014-06-10 10:58   ` Cédric Chépied

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.