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

* Re: emacs: send break on serial port
  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  9:13 ` Leo Liu
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2014-06-10  9:05 UTC (permalink / raw)
  To: Cédric Chépied; +Cc: emacs-devel

Cédric Chépied <cedric.chepied@gmail.com> writes:

> +DEFUN ("send-break-process", Fsend_break_process, Ssend_break_process, 1, 1, 0,

process-send-break would be a better name.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



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

* Re: emacs: send break on serial port
  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  9:13 ` Leo Liu
  2014-06-10 10:58   ` Cédric Chépied
  1 sibling, 1 reply; 6+ messages in thread
From: Leo Liu @ 2014-06-10  9:13 UTC (permalink / raw)
  To: Cédric Chépied; +Cc: emacs-devel

On 2014-06-10 08:59 +0200, Cédric Chépied wrote:
> 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.

Should this be done via signal-process instead?

Leo



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

* Re: emacs: send break on serial port
  2014-06-10  9:13 ` Leo Liu
@ 2014-06-10 10:58   ` Cédric Chépied
  0 siblings, 0 replies; 6+ messages in thread
From: Cédric Chépied @ 2014-06-10 10:58 UTC (permalink / raw)
  To: Leo Liu; +Cc: emacs-devel

At Tue, 10 Jun 2014 17:13:14 +0800,
Leo Liu wrote:
> Should this be done via signal-process instead?

A break is not a signal for an UNIX process:
http://ltxfaq.custhelp.com/app/answers/detail/a_id/736/~/what-is-a-serial-break%3F

I think it could be ambiguous to do this in signal-process
-- 
Cédric Chépied
<cedric.chepied@gmail.com>



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

* Re: emacs: send break on serial port
  2014-06-10  9:05 ` Andreas Schwab
@ 2014-06-10 11:13   ` Cédric Chépied
  2014-06-10 20:28     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Cédric Chépied @ 2014-06-10 11:13 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

At Tue, 10 Jun 2014 11:05:02 +0200,
Andreas Schwab wrote:
> process-send-break would be a better name.

bf9d1518e58f8ffb2f009ad958a6e30f2037cd3f HEAD master
Author: Cédric Chépied <cedric.chepied@gmail.com>
Date:   Tue Jun 10 09:17:31 2014 +0200

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

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

	Modified   src/process.c
diff --git a/src/process.c b/src/process.c
index b8b8eaa..e1eea88 100644
--- a/src/process.c
+++ b/src/process.c
@@ -844,6 +844,24 @@ record_deleted_pid (pid_t pid, Lisp_Object filename)
 
 }
 
+DEFUN ("process-send-break", Fprocess_send_break, Sprocess_send_break, 1, 1, 0,
+       doc: /* Send a break to the serial process PROCESS.
+PROCESS may be a process, a buffer, the name of a process or buffer, or
+nil, indicating the current buffer's 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 +7338,7 @@ The variable takes effect when `start-process' is called.  */);
 
   defsubr (&Sprocessp);
   defsubr (&Sget_process);
+  defsubr (&Sprocess_send_break);
   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

* Re: emacs: send break on serial port
  2014-06-10 11:13   ` Cédric Chépied
@ 2014-06-10 20:28     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2014-06-10 20:28 UTC (permalink / raw)
  To: Cédric Chépied; +Cc: Andreas Schwab, emacs-devel

>     Add a function to send a break via serial process

Are there other such things that Emacs might want to send to a serial port?
Maybe we should share (some of) the code with process-send-eof
(e.g. the part that handles flushing the pending output).


        Stefan



^ permalink raw reply	[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.