Mirage ha | 3 Jan 12:20
Picon

Re: g++ not found after build armv4tl-softfloat-linux-gnueabi



On Mon, Dec 28, 2009 at 12:11 AM, Ahmed Ammar <b33fc0d3-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> wrote:
On Wed, 2009-12-23 at 11:01 +0200, Mirage . wrote:

Mirage,

First, please don't top post ... it ruins everyone's formatting.

Ok I've hit this issue before, a while back (regarding s4 not producing
a complete stage4 compiler) but never really looked into it, I have some
more queries;

     * What are the contents
       of: /etc/portage/package.*/cross-armv4tl-softfloat-linux-gnueabi
     * Whats the output of: emerge --info -v

Temporarily you could try the following <after you saved the above output>:

# crossdev -s4 --ex-only --ex-gcc --target armv4tl-softfloat-linux-gnueabi
 
A.



Ahmed,
First, sorry for late reply.

I tried the above command but i still don't have g++ command
below are the results for your queries:

/etc/portage/package.*/cross-armv4tl-softfloat-linux-gnueabi


cross-armv4tl-softfloat-linux-gnueabi/binutils arm ~arm -x86 -~x86
cross-armv4tl-softfloat-linux-gnueabi/gcc arm ~arm -x86 -~x86
cross-armv4tl-softfloat-linux-gnueabi/linux-headers arm ~arm -x86 -~x86
cross-armv4tl-softfloat-linux-gnueabi/glibc arm ~arm -x86 -~x86
cross-armv4tl-softfloat-linux-gnueabi/gdb arm ~arm -x86 -~x86
cross-armv4tl-softfloat-linux-gnueabi/insight arm ~arm -x86 -~x86
cross-armv4tl-softfloat-linux-gnueabi/binutils -selinux
cross-armv4tl-softfloat-linux-gnueabi/linux-headers -selinux
cross-armv4tl-softfloat-linux-gnueabi/glibc -selinux
cross-armv4tl-softfloat-linux-gnueabi/gcc -selinux -boundschecking -d -gtk -gcj -libffi -mudflap -objc -objc++ -objc-gc -openmp

emerge --info -v:

System uname: Linux-2.6.28-rc9-i686-Intel-R-_Core-TM-2_Duo_CPU_E4600_ <at> _2.40GHz-with-gentoo-2.0.1
Timestamp of tree: Tue, 22 Dec 2009 14:15:01 +0000
ccache version 2.4 [disabled]
app-shells/bash:     4.0_p35
dev-java/java-config: 1.3.7-r1, 2.1.6-r1
dev-lang/python:     2.4.4-r15, 2.5.2-r8, 2.6.4, 3.1.1-r1
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r8
dev-util/cmake:      2.6.2
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.6.0
sys-apps/sandbox:    2.2
sys-devel/autoconf:  2.13, 2.64
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.3, 1.11.1
sys-devel/binutils:  2.20
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="* - <at> EULA"
ACCEPT_PROPERTIES="*"
ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci"
ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
ANT_HOME="/usr/share/ant"
APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
ARCH="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe"
CHOST="i686-pc-linux-gnu"
CLASSPATH="."
CLEAN_DELAY="5"
COLLISION_IGNORE="/lib/modules"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CVS_RSH="ssh"
CXXFLAGS="-O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
EDITOR="vim"
ELIBC="glibc"
EMERGE_WARNING_DELAY="10"
EPREFIX=""
EROOT="/"
FEATURES="assume-digests autoaddcvs buildpkg cvs distlocks keepwork metadata-transfer news noclean parallel-fetch preserve-libs protect-owned sfperms strict unmerge-logs unmerge-orphans userfetch"
FETCHCOMMAND="/usr/bin/wget -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
FOO2ZJS_DEVICES="hp1018"
GCC_SPECS=""
GDK_USE_XFT="1"
GENTOO_MIRRORS="http://mirror.ovh.net/gentoo-distfiles/"
HG="/usr/bin/hg"
HOME="/home/mirage"
INFOPATH="/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.20/info:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/info"
INPUT_DEVICES="keyboard mouse kbd"
JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
JAVACC_HOME="/usr/share/javacc/"
JAVA_HOME="/etc/java-config-2/current-system-vm"
JDK_HOME="/etc/java-config-2/current-system-vm"
KERNEL="linux"
LANG="en_GB.utf8"
LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
LC_ALL="en_GB.utf8"
LDFLAGS="-Wl,-O1,--enable-new-dtags,--sort-common,--hash-style=gnu -Wl,--as-needed"
LESS="-R -M --shift 5"
LESSOPEN="|lesspipe.sh %s"
LINGUAS="en en_GB"
LOGNAME="mirage"
LS_COLORS="rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"
MAIL="/var/mail/mirage"
MAKEOPTS="-j4"
MANPATH="/etc/java-config-2/current-system-vm/man:/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.20/man:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/man:/etc/java-config/system-vm/man/"
NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
OMNIORB_CONFIG="/etc/omniorb/omniORB.cfg"
OPENGL_PROFILE="xorg-x11"
PAGER="/usr/bin/less"
PATH="/usr/local/bin:/usr/bin:/bin:/usr/i686-pc-linux-gnu/armv4tl-softfloat-linux-gnueabi/gcc-bin/4.3.4:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.4:/usr/games/bin"
PKGDIR="/usr/portage/packages"
PORTAGE_ARCHLIST="ppc x86-openbsd ppc-openbsd ppc64 x86-winnt x86-fbsd ppc-aix alpha arm x86-freebsd s390 amd64 arm-linux x86-macos x64-openbsd ia64-hpux hppa x86-netbsd amd64-linux ia64-linux x86 sparc-solaris x64-freebsd sparc64-solaris x86-linux x64-macos sparc m68k-mint ia64 mips ppc-macos x86-interix hppa-hpux amd64-fbsd x64-solaris mips-irix m68k sh x86-solaris sparc-fbsd"
PORTAGE_BINHOST_CHUNKSIZE="3000"
PORTAGE_BIN_PATH="/usr/lib/portage/bin"
PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
PORTAGE_CONFIGROOT="/"
PORTAGE_DEBUG="0"
PORTAGE_DEPCACHEDIR="/var/cache/edb/dep"
PORTAGE_ELOG_CLASSES="log warn error"
PORTAGE_ELOG_MAILFROM="portage <at> localhost"
PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}"
PORTAGE_ELOG_MAILURI="root"
PORTAGE_ELOG_SYSTEM="save_summary echo"
PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5"
PORTAGE_FETCH_RESUME_MIN_SIZE="350K"
PORTAGE_GID="250"
PORTAGE_INST_GID="0"
PORTAGE_INST_UID="0"
PORTAGE_NICENESS="10"
PORTAGE_PYM_PATH="/usr/lib/portage/pym"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_RSYNC_RETRIES="3"
PORTAGE_TMPDIR="/var/tmp"
PORTAGE_VERBOSE="1"
PORTAGE_WORKDIR_MODE="0700"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
PORT_LOGDIR="/var/log/portage"
PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
PWD="/home/mirage"
RESUMECOMMAND="/usr/bin/wget -c -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
ROOT="/"
ROOTPATH="/opt/bin:/usr/i686-pc-linux-gnu/armv4tl-softfloat-linux-gnueabi/gcc-bin/4.3.4:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.4"
RPMDIR="/usr/portage/rpm"
RUBY_TARGETS="ruby18"
SGML_CATALOG_FILES="/etc/sgml/xml-docbook-4.5.cat:/etc/sgml/xml-docbook-4.2.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/xml-docbook-4.1.2.cat:/etc/sgml/xml-simple-docbook-4.1.2.4.cat:/etc/sgml/xml-simple-docbook-1.0.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/sgml-docbook-3.0.cat:/etc/sgml/xml-docbook-4.3.cat:/etc/sgml/sgml-docbook-4.5.cat:/etc/sgml/sgml-lite.cat:/etc/sgml/sgml-ent.cat:/etc/sgml/xml-docbook-4.4.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-docbook-4.1.cat:/etc/sgml/sgml-docbook-4.0.cat"
SHELL="/bin/bash"
SHLVL="1"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
TERM="xterm"
USE="X a52 aac acl acpi alsa bash-completion berkdb bluetooth bzip2 cairo cdr cli consolekit cracklib crypt cscope cups custom-optimization cxx dbus dri dts dvd dvdr eds emboss encode evo extras fam flac fortran gdbm gif glitz gnome gpm gstreamer gtk hal iconv java5 java6 jpeg ldap libnotify mad mikmod mng modules mp3 mp4 mpeg mudflap nautilus ncurses nls nptl nptlonly nsplugin ogg opengl openmp oss pam pcre pdf perl png policykit ppds pppd python qt3support quicktime readline reflection samba sdl session spell spl sse ssl startup-notification svg sysfs tcpd threads thunar tiff truetype ttif unicode usb vorbis win32codecs x264 x86 xcb xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling statCOXXus unique_id userdir usertrack vhost_alias" ELIBC="glibc" FOO2ZJS_DEVICES="hp1018" INPUT_DEVICES="keyboard mouse kbd" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_GB" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="intel"
USER="mirage"
USERLAND="GNU"
USE_EXPAND="ALSA_CARDS ALSA_PCM_PLUGINS APACHE2_MODULES APACHE2_MPMS CAMERAS CROSSCOMPILE_OPTS DVB_CARDS ELIBC FCDSL_CARDS FOO2ZJS_DEVICES FRITZCAPI_CARDS INPUT_DEVICES KERNEL LCD_DEVICES LINGUAS LIRC_DEVICES MISDN_CARDS NETBEANS_MODULES QEMU_SOFTMMU_TARGETS QEMU_USER_TARGETS RUBY_TARGETS SANE_BACKENDS USERLAND VIDEO_CARDS"
USE_EXPAND_HIDDEN="CROSSCOMPILE_OPTS ELIBC KERNEL USERLAND"
USE_ORDER="env:pkg:conf:defaults:pkginternal:env.d"
VIDEO_CARDS="intel"
XSESSION="Gnome"
_="/usr/bin/emerge"





--
Never Think Hard About Past,It brings"Tears" Don't think more about future, It brings"Fears" Live this moment with a Smile, It brings"Cheers", And I Wish U HaPpY New Year :).

Regards,
Mirage
Mirage ha | 5 Jan 09:09
Picon

Re: g++ not found after build armv4tl-softfloat-linux-gnueabi



On Sun, Jan 3, 2010 at 2:13 PM, Ahmed Ammar <b33fc0d3-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> wrote:
On Sun, 2010-01-03 at 13:20 +0200, Mirage ha wrote:
> FEATURES="assume-digests autoaddcvs buildpkg cvs distlocks keepwork
> metadata-transfer news noclean parallel-fetch preserve-libs
> protect-owned sfperms strict unmerge-logs unmerge-orphans userfetch"

Ok I think this could be it.

You have 'keepwork' enabled which would prolly make crossdev just jump
right through recompiling gcc for anything past s1.

Remove that FEATURE and try again.

A.






Thanks Ahmed, It finally works.
And thank you all for your help.

Regards,
Mirage
--
Never Think Hard About Past,It brings"Tears" Don't think more about future, It brings"Fears" Live this moment with a Smile, It brings"Cheers", And I Wish U HaPpY New Year :).
David Relson | 14 Jan 00:52
Favicon

serial port handling question

G'day,

I'm porting some old DOS code to Linux for a medical device that is
being upgraded.  Among other goodies, it has a sensor that sends data at
115KB to an onboard NS16550A (or equivalent).  

The sensor is controlled (in part) by setting RTS on and off. I looked
high and low (pun intended) for an ioctl or similar call that would
allow this level of control and couldn't find anything. I finally ended
up using the ollowing lines of code: 

 outb(inportb(MCR) |  0x02, MCR);  //DTR,RTS=ON
 outb(inportb(MCR) & ~0x02, MCR);  //DTR=ON,RTS=OFF

Directly tweaking the I/O port runs against the grain, but it's the
only thing I've found that works.

Is there a better way to control the chip?

Regards,

David

Peter Stuge | 14 Jan 03:55
Picon

Re: serial port handling question

David Relson wrote:
> I'm porting some old DOS code to Linux for a medical device that is
> being upgraded.

Interesting, this business.

> The sensor is controlled (in part) by setting RTS on and off.

What is controlled, exactly? What is RTS being used for? If it is
indeed flow control then you are lucky and can simply enable hardware
flow control for the serial port, and Linux will then take care of
everything for you.

If not flow control and some other signalling, you have to write a
line discipline driver. I have done both this and serial drivers
(also related to DOS era equipment) and documentation is not the
greatest. Let me know if you would like some help.

> I looked high and low (pun intended) for an ioctl or similar call
> that would allow this level of control and couldn't find anything.

The best thing out there is tcsetattr() and friends.

By switching between baud rate 0 and something else you can reliably
and easily control both RTS and DTR, and nothing but RTS and DTR, but
always both at the same time.

Line disciplines can call the tty_throttle() and tty_unthrottle()
functions in the serial driver, which will then control RTS
accordingly, but the default TTY line discipline does not expose any
API that will result in throttle function calls.

>  outb(inportb(MCR) |  0x02, MCR);  //DTR,RTS=ON
>  outb(inportb(MCR) & ~0x02, MCR);  //DTR=ON,RTS=OFF
> 
> Directly tweaking the I/O port runs against the grain, but it's the
> only thing I've found that works.

Not only against the grain, it can mess up internal state in the
kernel serial layer and worst case lead to a kernel BUG_ON (kernel
hangs) or best case serial port hang (unhang e.g. by closing all file
handles for the port and opening again). It is not at all nice to
change these signals behind Linux' back.

//Peter

Daniel Stonier | 14 Jan 03:56
Picon
Gravatar

Re: serial port handling question

I've never actually used the RTS on - always had it off. But just in
case you didn't find the details there's a setting in the termios
options structure for rts - have you tried that?

'man termios' - look for CRTSCTS.

I usually use a bit of code to set the flag off for my connections:

*******************************

termios options;
// Disable Flow control
#if defined(CRTSCTS)
    options.c_cflag &= ~CRTSCTS; // Disable hardware flow control (old)
#elif defined (CNEW_RTSCTS)
    options.c_cflag &= ~CNEW_RTSCTS; // Disable hardware flow control (new)
#endif
tcsetattr(file_descriptor,TCSAFLUSH,&options);

*******************************

Above, file_descriptor is the handle you get back from the previously
called open(...).

2010/1/14 David Relson <relson@...>
>
> G'day,
>
> I'm porting some old DOS code to Linux for a medical device that is
> being upgraded.  Among other goodies, it has a sensor that sends data at
> 115KB to an onboard NS16550A (or equivalent).
>
> The sensor is controlled (in part) by setting RTS on and off. I looked
> high and low (pun intended) for an ioctl or similar call that would
> allow this level of control and couldn't find anything. I finally ended
> up using the ollowing lines of code:
>
>  outb(inportb(MCR) |  0x02, MCR);  //DTR,RTS=ON
>  outb(inportb(MCR) & ~0x02, MCR);  //DTR=ON,RTS=OFF
>
> Directly tweaking the I/O port runs against the grain, but it's the
> only thing I've found that works.
>
> Is there a better way to control the chip?
>
> Regards,
>
> David
>

--
Phone : +82-10-5400-3296 (010-5400-3296)
HomePage: http://snorriheim.dnsdojo.com/
Yujin Robot: http://www.yujinrobot.com/
Projects: http://snorriheim.dnsdojo.com/redmine/projects
Embedded Control Libraries: http://snorriheim.dnsdojo.com/redmine/wiki/ecl

Peter Stuge | 14 Jan 04:47
Picon

Re: serial port handling question

Daniel Stonier wrote:
> there's a setting in the termios options structure for rts - have
> you tried that?
> 
> 'man termios' - look for CRTSCTS.

Note that this flag does not directly control RTS, but rather it
instructs the kernel whether RTS/CTS signalling should be used for
flow control or not.

As David noticed, there is no API for directly controlling RTS in
Linux, it can only be done by the serial driver itself or a line
discipline driver.

//Peter

David Relson | 14 Jan 05:09
Favicon

Re: serial port handling question

On Thu, 14 Jan 2010 04:47:53 +0100
Peter Stuge wrote:

> Daniel Stonier wrote:
> > there's a setting in the termios options structure for rts - have
> > you tried that?
> > 
> > 'man termios' - look for CRTSCTS.
> 
> Note that this flag does not directly control RTS, but rather it
> instructs the kernel whether RTS/CTS signalling should be used for
> flow control or not.
> 
> As David noticed, there is no API for directly controlling RTS in
> Linux, it can only be done by the serial driver itself or a line
> discipline driver.
> 
> 
> //Peter

Hello Peter and Daniel,

Information greatly appreciated.  I'll digest it tomorrow when I'm more
alert.

After bashing my head against the wall (including experimentation with
CRTSCTS), I spent a while reading drivers/serial/8250.c and found that
CRTSCTS used only for enabling AFE (automatic flowcontrol enabled).
Not having adequate specs for the protocol or hardware involved,
there's some mystery as to exactly why RTS is used as it is.

For certain, it'll be interesting tomorrow to learn more of termios and
line discipline drivers (a new term for me).

Ciao,

David

David Relson | 14 Jan 05:30
Favicon

Re: serial port handling question

On Thu, 14 Jan 2010 03:55:07 +0100
Peter Stuge wrote:

> David Relson wrote:
> > I'm porting some old DOS code to Linux for a medical device that is
> > being upgraded.
> 
> Interesting, this business.

And it feels so good when one stops banging one's head against the wall.

> > The sensor is controlled (in part) by setting RTS on and off.
> 
> What is controlled, exactly? What is RTS being used for? If it is
> indeed flow control then you are lucky and can simply enable hardware
> flow control for the serial port, and Linux will then take care of
> everything for you.

Not sure (insufficient documentation).  The functions setting and
clearing RTS have names like RS485_RTS_Receiver_Enable and
RS485_RTS_Transmitter_Enable.  My query as to the meaning/purpose of
the routines is awaiting an answer..

> If not flow control and some other signalling, you have to write a
> line discipline driver. I have done both this and serial drivers
> (also related to DOS era equipment) and documentation is not the
> greatest. Let me know if you would like some help.
> 
> 
> > I looked high and low (pun intended) for an ioctl or similar call
> > that would allow this level of control and couldn't find anything.
> 
> The best thing out there is tcsetattr() and friends.
> 
> By switching between baud rate 0 and something else you can reliably
> and easily control both RTS and DTR, and nothing but RTS and DTR, but
> always both at the same time.

The RS485 routines mentionned above only change RTS.  DTR remains on.
Attempts to change both (using CRTSCTS and tcsetattr()) didn't work.

> Line disciplines can call the tty_throttle() and tty_unthrottle()
> functions in the serial driver, which will then control RTS
> accordingly, but the default TTY line discipline does not expose any
> API that will result in throttle function calls.
>  
> >  outb(inportb(MCR) |  0x02, MCR);  //DTR,RTS=ON
> >  outb(inportb(MCR) & ~0x02, MCR);  //DTR=ON,RTS=OFF
> > 
> > Directly tweaking the I/O port runs against the grain, but it's the
> > only thing I've found that works.
> 
> Not only against the grain, it can mess up internal state in the
> kernel serial layer and worst case lead to a kernel BUG_ON (kernel
> hangs) or best case serial port hang (unhang e.g. by closing all file
> handles for the port and opening again). It is not at all nice to
> change these signals behind Linux' back.

I'm well aware of the hackish nature of my "solution".  It'll be
interesting to see what unwanted side effects show up to bite me.

David

Peter Stuge | 14 Jan 06:08
Picon

Re: serial port handling question

David Relson wrote:
> > > The sensor is controlled (in part) by setting RTS on and off.
> > 
> > What is controlled, exactly? What is RTS being used for? If it is
> > indeed flow control then you are lucky and can simply enable
> > hardware flow control for the serial port, and Linux will then
> > take care of everything for you.
> 
> Not sure (insufficient documentation).  The functions setting and
> clearing RTS have names like RS485_RTS_Receiver_Enable and
> RS485_RTS_Transmitter_Enable.

That definately suggests that RTS/CTS would be used for flow control.

> My query as to the meaning/purpose of the routines is awaiting an
> answer..

Hopefully they will confirm that it's for flow control.

Then you can simply ignore everything related to RTS, as Linux will
take care of it for you. Just read from the opened tty device and
you'll get data when there is some. Linux also buffers writes, so if
a write() call succeeds then data will eventually go out on the port.

> The RS485 routines mentionned above only change RTS.  DTR remains on.
> Attempts to change both (using CRTSCTS and tcsetattr()) didn't work.

With tcsetattr() you'd use B0 in the CBAUD field to unset both
signals, and any B value other than B0 to set them. You can use
cfsetispeed() and cfsetospeed() to conveniently change only the
baudrate in a struct termios, but since it will also affect DTR I
don't think that this will work.

> I'm well aware of the hackish nature of my "solution".

What happens if you remove the code that touches the registers and
simply let Linux handle flow control? I suspect you could remove some
of the code surrounding the outb() calls as well, since the Linux
serial layer implements very thorough flow control.

> It'll be interesting to see what unwanted side effects show up to
> bite me.

Unfortunately the problems may not show up until far into the future,
with lots of installations possibly out in the field..

//Peter

Bob Dunlop | 14 Jan 11:05
Picon
Favicon

Re: serial port handling question

On Wed, Jan 13 at 06:52, David Relson wrote:
...
> Directly tweaking the I/O port runs against the grain, but it's the
> only thing I've found that works.
> 
> Is there a better way to control the chip?

I know others have commented on using automatic settings for flow control 
etc, but if you need to control the lines directly there are an often
neglected set of ioctls to do this. 

Some snippets of code, last used on x86 four years ago but it looks like
the hooks are still in the kernel and a fair number of device drivers.

    unsigned int flags;

    /* Raise RTS and DTR.
     * Linux will have already done this but some Unix system don't and
     * some wait for DCD before doing so, so make it explicit.
     */
    flags = TIOCM_RTS | TIOCM_DTR;
    if ( ioctl( fd, TIOCMBIS, &flags ) != 0 )
    {
        fprintf( stderr,"Failed to raise RTS and DTR.  Errno %d\n", errno );
        /* Possibly not fatal so we continue */
    }

    ... 

    /* Drop RTS */
    flags = TIOCM_RTS;
    if ( ioctl( fd, TIOCMBIC, &flags ) != 0 )
    {
        fprintf( stderr,"Failed to clear RTS.  Errno %d\n", errno );
    }

As well as set and clear there is a get (TIOCMGET) useful for checking DCD.


Gmane