EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: bundling linenoise with base
From: Benjamin Franksen <[email protected]>
To: EPICS Core-Talk <[email protected]>
Date: Fri, 9 Feb 2018 17:54:38 +0100
Hi Everyone

I have just finished an experimental addition to EPICS base and wondered
if you might be interested. It began when I investigated building our
RTEMS IOCs statically -- presumably the way most people use RTEMS with
EPICS -- instead of using cexpsh and gesys and then loading modules at
runtime as we used to. So I am now stuck with the iocsh and found that I
missed things like command line completion and history.

The code in base (I haven't yet look at versions beyond 3.14) has a very
simple API (epicsReadline.h) for accessing the command line library
chosen by the user (by setting COMMANDLINE_LIBRARY). The wrapper code
(epicsReadline.c) is a bit messy/repetitive (#if ...# elif...) but
otherwise not hard to grok. It assume the COMMANDLINE_LIBRARY is
pre-installed system-wide, though. This is a pain, especially with
RTEMS, but also with various other host systems, see recurring questions
on tech-talk about libreadline in various versions, with or without
libcurses or libncurses. And as it turns out, almost none of the
advanced features offered by libreadline are used in the iocsh.

I looked around a bit and found a very nice and small library named
linenoise [1]. It has all the features, compiles against (and actually
works on, with a few minor modifications) RTEMS (only tested 4.9 so
far), and has no more than 820 lines of code (without comments,
according to cloc [2]). It has been expressly designed for being
bundled. So I added a copy to base and wrote the epicsReadline wrapper
code for it, adding another variant for COMMANDLINE_LIBRARY. In
addition, with a few additional lines of code in the wrapper for
linenoise I was able to implement command completion as well as argument
hints.

I think bundling linenoise with base and making it the default command
line library for the iocsh (except on vxWorks which apparently has no
termios) would be smart move. If there is interest, I can submit patches
(merge request, whatever) against the launchpad repo.

Another solution would be to change the epicsReadline API in such a way
that an EPICS support module can replace the three exported functions
with another implementation; this could be done inside the main
function, for instance.

[1] https://github.com/antirez/linenoise
[2] https://github.com/AlDanial/cloc

Cheers
Ben
-- 
"Make it so they have to reboot after every typo." ― Scott Adams

Attachment: signature.asc
Description: OpenPGP digital signature


Replies:
Re: bundling linenoise with base Johnson, Andrew N.
RE: bundling linenoise with base Laznovsky Michael (PSI)

Navigate by Date:
Prev: Re: Scanning on event number fails with EPICS 3.16 Johnson, Andrew N.
Next: Re: bundling linenoise with base Johnson, Andrew N.
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Scanning on event number fails with EPICS 3.16 Dirk Zimoch
Next: Re: bundling linenoise with base Johnson, Andrew N.
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
ANJ, 15 Mar 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·